blob: a97d87d3e3fc1199313de52b03621d9a45120ef6 [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 /**
Steve McKayc78bcb82015-07-31 14:35:22 -0700661 * Activity Action: Quick view the data.
662 * <p>Input: {@link #getData} is URI from which to retrieve data.
663 * <p>Output: nothing.
664 * @hide
665 */
666 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
667 public static final String ACTION_QUICK_VIEW = "android.intent.action.QUICK_VIEW";
668
669 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700670 * Used to indicate that some piece of data should be attached to some other
671 * place. For example, image data could be attached to a contact. It is up
672 * to the recipient to decide where the data should be attached; the intent
673 * does not specify the ultimate destination.
674 * <p>Input: {@link #getData} is URI of data to be attached.
675 * <p>Output: nothing.
676 */
677 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
678 public static final String ACTION_ATTACH_DATA = "android.intent.action.ATTACH_DATA";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800679
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700680 /**
681 * Activity Action: Provide explicit editable access to the given data.
682 * <p>Input: {@link #getData} is URI of data to be edited.
683 * <p>Output: nothing.
684 */
685 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
686 public static final String ACTION_EDIT = "android.intent.action.EDIT";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800687
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700688 /**
689 * Activity Action: Pick an existing item, or insert a new item, and then edit it.
690 * <p>Input: {@link #getType} is the desired MIME type of the item to create or edit.
691 * The extras can contain type specific data to pass through to the editing/creating
692 * activity.
693 * <p>Output: The URI of the item that was picked. This must be a content:
694 * URI so that any receiver can access it.
695 */
696 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
697 public static final String ACTION_INSERT_OR_EDIT = "android.intent.action.INSERT_OR_EDIT";
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: Pick an item from the data, returning what was selected.
701 * <p>Input: {@link #getData} is URI containing a directory of data
702 * (vnd.android.cursor.dir/*) from which to pick an item.
703 * <p>Output: The URI of the item that was picked.
704 */
705 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
706 public static final String ACTION_PICK = "android.intent.action.PICK";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800707
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700708 /**
709 * Activity Action: Creates a shortcut.
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800710 * <p>Input: Nothing.</p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700711 * <p>Output: An Intent representing the shortcut. The intent must contain three
712 * extras: SHORTCUT_INTENT (value: Intent), SHORTCUT_NAME (value: String),
713 * and SHORTCUT_ICON (value: Bitmap) or SHORTCUT_ICON_RESOURCE
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800714 * (value: ShortcutIconResource).</p>
715 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700716 * @see #EXTRA_SHORTCUT_INTENT
717 * @see #EXTRA_SHORTCUT_NAME
718 * @see #EXTRA_SHORTCUT_ICON
719 * @see #EXTRA_SHORTCUT_ICON_RESOURCE
720 * @see android.content.Intent.ShortcutIconResource
721 */
722 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
723 public static final String ACTION_CREATE_SHORTCUT = "android.intent.action.CREATE_SHORTCUT";
724
725 /**
726 * The name of the extra used to define the Intent of a shortcut.
727 *
728 * @see #ACTION_CREATE_SHORTCUT
729 */
730 public static final String EXTRA_SHORTCUT_INTENT = "android.intent.extra.shortcut.INTENT";
731 /**
732 * The name of the extra used to define the name of a shortcut.
733 *
734 * @see #ACTION_CREATE_SHORTCUT
735 */
736 public static final String EXTRA_SHORTCUT_NAME = "android.intent.extra.shortcut.NAME";
737 /**
738 * The name of the extra used to define the icon, as a Bitmap, of a shortcut.
739 *
740 * @see #ACTION_CREATE_SHORTCUT
741 */
742 public static final String EXTRA_SHORTCUT_ICON = "android.intent.extra.shortcut.ICON";
743 /**
744 * The name of the extra used to define the icon, as a ShortcutIconResource, of a shortcut.
745 *
746 * @see #ACTION_CREATE_SHORTCUT
747 * @see android.content.Intent.ShortcutIconResource
748 */
749 public static final String EXTRA_SHORTCUT_ICON_RESOURCE =
750 "android.intent.extra.shortcut.ICON_RESOURCE";
751
752 /**
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800753 * Represents a shortcut/live folder icon resource.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700754 *
755 * @see Intent#ACTION_CREATE_SHORTCUT
756 * @see Intent#EXTRA_SHORTCUT_ICON_RESOURCE
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800757 * @see android.provider.LiveFolders#ACTION_CREATE_LIVE_FOLDER
758 * @see android.provider.LiveFolders#EXTRA_LIVE_FOLDER_ICON
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700759 */
760 public static class ShortcutIconResource implements Parcelable {
761 /**
762 * The package name of the application containing the icon.
763 */
764 public String packageName;
765
766 /**
767 * The resource name of the icon, including package, name and type.
768 */
769 public String resourceName;
770
771 /**
772 * Creates a new ShortcutIconResource for the specified context and resource
773 * identifier.
774 *
775 * @param context The context of the application.
Tor Norbye7b9c9122013-05-30 16:48:33 -0700776 * @param resourceId The resource identifier for the icon.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700777 * @return A new ShortcutIconResource with the specified's context package name
Tor Norbye7b9c9122013-05-30 16:48:33 -0700778 * and icon resource identifier.``
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700779 */
Tor Norbye7b9c9122013-05-30 16:48:33 -0700780 public static ShortcutIconResource fromContext(Context context, @AnyRes int resourceId) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700781 ShortcutIconResource icon = new ShortcutIconResource();
782 icon.packageName = context.getPackageName();
783 icon.resourceName = context.getResources().getResourceName(resourceId);
784 return icon;
785 }
786
787 /**
788 * Used to read a ShortcutIconResource from a Parcel.
789 */
790 public static final Parcelable.Creator<ShortcutIconResource> CREATOR =
791 new Parcelable.Creator<ShortcutIconResource>() {
792
793 public ShortcutIconResource createFromParcel(Parcel source) {
794 ShortcutIconResource icon = new ShortcutIconResource();
795 icon.packageName = source.readString();
796 icon.resourceName = source.readString();
797 return icon;
798 }
799
800 public ShortcutIconResource[] newArray(int size) {
801 return new ShortcutIconResource[size];
802 }
803 };
804
805 /**
806 * No special parcel contents.
807 */
808 public int describeContents() {
809 return 0;
810 }
811
812 public void writeToParcel(Parcel dest, int flags) {
813 dest.writeString(packageName);
814 dest.writeString(resourceName);
815 }
816
817 @Override
818 public String toString() {
819 return resourceName;
820 }
821 }
822
823 /**
824 * Activity Action: Display an activity chooser, allowing the user to pick
825 * what they want to before proceeding. This can be used as an alternative
826 * to the standard activity picker that is displayed by the system when
827 * you try to start an activity with multiple possible matches, with these
828 * differences in behavior:
829 * <ul>
830 * <li>You can specify the title that will appear in the activity chooser.
831 * <li>The user does not have the option to make one of the matching
832 * activities a preferred activity, and all possible activities will
833 * always be shown even if one of them is currently marked as the
834 * preferred activity.
835 * </ul>
836 * <p>
837 * This action should be used when the user will naturally expect to
838 * select an activity in order to proceed. An example if when not to use
839 * it is when the user clicks on a "mailto:" link. They would naturally
840 * expect to go directly to their mail app, so startActivity() should be
841 * called directly: it will
842 * either launch the current preferred app, or put up a dialog allowing the
843 * user to pick an app to use and optionally marking that as preferred.
844 * <p>
845 * In contrast, if the user is selecting a menu item to send a picture
846 * they are viewing to someone else, there are many different things they
847 * may want to do at this point: send it through e-mail, upload it to a
848 * web service, etc. In this case the CHOOSER action should be used, to
849 * always present to the user a list of the things they can do, with a
850 * nice title given by the caller such as "Send this photo with:".
851 * <p>
Dianne Hackborne302a162012-05-15 14:58:32 -0700852 * If you need to grant URI permissions through a chooser, you must specify
853 * the permissions to be granted on the ACTION_CHOOSER Intent
854 * <em>in addition</em> to the EXTRA_INTENT inside. This means using
855 * {@link #setClipData} to specify the URIs to be granted as well as
856 * {@link #FLAG_GRANT_READ_URI_PERMISSION} and/or
857 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION} as appropriate.
858 * <p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700859 * As a convenience, an Intent of this form can be created with the
860 * {@link #createChooser} function.
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -0700861 * <p>
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -0700862 * Input: No data should be specified. get*Extra must have
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700863 * a {@link #EXTRA_INTENT} field containing the Intent being executed,
864 * and can optionally have a {@link #EXTRA_TITLE} field containing the
865 * title text to display in the chooser.
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -0700866 * <p>
867 * Output: Depends on the protocol of {@link #EXTRA_INTENT}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700868 */
869 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
870 public static final String ACTION_CHOOSER = "android.intent.action.CHOOSER";
871
872 /**
873 * Convenience function for creating a {@link #ACTION_CHOOSER} Intent.
874 *
Dianne Hackborne302a162012-05-15 14:58:32 -0700875 * <p>Builds a new {@link #ACTION_CHOOSER} Intent that wraps the given
876 * target intent, also optionally supplying a title. If the target
877 * intent has specified {@link #FLAG_GRANT_READ_URI_PERMISSION} or
878 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, then these flags will also be
879 * set in the returned chooser intent, with its ClipData set appropriately:
880 * either a direct reflection of {@link #getClipData()} if that is non-null,
John Spurlock33900182014-01-02 11:04:18 -0500881 * or a new ClipData built from {@link #getData()}.
Dianne Hackborne302a162012-05-15 14:58:32 -0700882 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700883 * @param target The Intent that the user will be selecting an activity
884 * to perform.
885 * @param title Optional title that will be displayed in the chooser.
886 * @return Return a new Intent object that you can hand to
887 * {@link Context#startActivity(Intent) Context.startActivity()} and
888 * related methods.
889 */
890 public static Intent createChooser(Intent target, CharSequence title) {
Adam Powell0b3c1122014-10-09 12:50:14 -0700891 return createChooser(target, title, null);
892 }
893
894 /**
895 * Convenience function for creating a {@link #ACTION_CHOOSER} Intent.
896 *
897 * <p>Builds a new {@link #ACTION_CHOOSER} Intent that wraps the given
898 * target intent, also optionally supplying a title. If the target
899 * intent has specified {@link #FLAG_GRANT_READ_URI_PERMISSION} or
900 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, then these flags will also be
901 * set in the returned chooser intent, with its ClipData set appropriately:
902 * either a direct reflection of {@link #getClipData()} if that is non-null,
903 * or a new ClipData built from {@link #getData()}.</p>
904 *
905 * <p>The caller may optionally supply an {@link IntentSender} to receive a callback
906 * when the user makes a choice. This can be useful if the calling application wants
907 * to remember the last chosen target and surface it as a more prominent or one-touch
908 * affordance elsewhere in the UI for next time.</p>
909 *
910 * @param target The Intent that the user will be selecting an activity
911 * to perform.
912 * @param title Optional title that will be displayed in the chooser.
913 * @param sender Optional IntentSender to be called when a choice is made.
914 * @return Return a new Intent object that you can hand to
915 * {@link Context#startActivity(Intent) Context.startActivity()} and
916 * related methods.
917 */
918 public static Intent createChooser(Intent target, CharSequence title, IntentSender sender) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700919 Intent intent = new Intent(ACTION_CHOOSER);
920 intent.putExtra(EXTRA_INTENT, target);
921 if (title != null) {
922 intent.putExtra(EXTRA_TITLE, title);
923 }
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -0700924
Adam Powell0b3c1122014-10-09 12:50:14 -0700925 if (sender != null) {
926 intent.putExtra(EXTRA_CHOSEN_COMPONENT_INTENT_SENDER, sender);
927 }
928
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -0700929 // Migrate any clip data and flags from target.
Jeff Sharkey846318a2014-04-04 12:12:41 -0700930 int permFlags = target.getFlags() & (FLAG_GRANT_READ_URI_PERMISSION
931 | FLAG_GRANT_WRITE_URI_PERMISSION | FLAG_GRANT_PERSISTABLE_URI_PERMISSION
932 | FLAG_GRANT_PREFIX_URI_PERMISSION);
Dianne Hackborne302a162012-05-15 14:58:32 -0700933 if (permFlags != 0) {
934 ClipData targetClipData = target.getClipData();
935 if (targetClipData == null && target.getData() != null) {
936 ClipData.Item item = new ClipData.Item(target.getData());
937 String[] mimeTypes;
938 if (target.getType() != null) {
939 mimeTypes = new String[] { target.getType() };
940 } else {
941 mimeTypes = new String[] { };
942 }
943 targetClipData = new ClipData(null, mimeTypes, item);
944 }
945 if (targetClipData != null) {
946 intent.setClipData(targetClipData);
947 intent.addFlags(permFlags);
948 }
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -0700949 }
Dianne Hackborne302a162012-05-15 14:58:32 -0700950
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700951 return intent;
952 }
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -0700953
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700954 /**
955 * Activity Action: Allow the user to select a particular kind of data and
956 * return it. This is different than {@link #ACTION_PICK} in that here we
957 * just say what kind of data is desired, not a URI of existing data from
Dianne Hackbornfdb3f092013-01-28 15:10:48 -0800958 * which the user can pick. An ACTION_GET_CONTENT could allow the user to
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700959 * create the data as it runs (for example taking a picture or recording a
Ken Wakasaf76a50c2012-03-09 19:56:35 +0900960 * sound), let them browse over the web and download the desired data,
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700961 * etc.
962 * <p>
Ken Wakasaf76a50c2012-03-09 19:56:35 +0900963 * 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 -0700964 * of data, such as a person contact, you set the MIME type to the kind of
965 * data you want and launch it with {@link Context#startActivity(Intent)}.
966 * The system will then launch the best application to select that kind
967 * of data for you.
968 * <p>
969 * You may also be interested in any of a set of types of content the user
970 * can pick. For example, an e-mail application that wants to allow the
971 * user to add an attachment to an e-mail message can use this action to
972 * bring up a list of all of the types of content the user can attach.
973 * <p>
974 * In this case, you should wrap the GET_CONTENT intent with a chooser
975 * (through {@link #createChooser}), which will give the proper interface
976 * for the user to pick how to send your data and allow you to specify
977 * a prompt indicating what they are doing. You will usually specify a
978 * broad MIME type (such as image/* or {@literal *}/*), resulting in a
979 * broad range of content types the user can select from.
980 * <p>
Ken Wakasaf76a50c2012-03-09 19:56:35 +0900981 * When using such a broad GET_CONTENT action, it is often desirable to
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700982 * only pick from data that can be represented as a stream. This is
983 * accomplished by requiring the {@link #CATEGORY_OPENABLE} in the Intent.
984 * <p>
Dianne Hackbornc4d0e6f2011-01-25 14:55:06 -0800985 * Callers can optionally specify {@link #EXTRA_LOCAL_ONLY} to request that
Ken Wakasaf76a50c2012-03-09 19:56:35 +0900986 * the launched content chooser only returns results representing data that
Dianne Hackbornc4d0e6f2011-01-25 14:55:06 -0800987 * is locally available on the device. For example, if this extra is set
988 * to true then an image picker should not show any pictures that are available
989 * from a remote server but not already on the local device (thus requiring
990 * they be downloaded when opened).
991 * <p>
Dianne Hackbornfdb3f092013-01-28 15:10:48 -0800992 * If the caller can handle multiple returned items (the user performing
993 * multiple selection), then it can specify {@link #EXTRA_ALLOW_MULTIPLE}
994 * to indicate this.
995 * <p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700996 * Input: {@link #getType} is the desired MIME type to retrieve. Note
997 * that no URI is supplied in the intent, as there are no constraints on
998 * where the returned data originally comes from. You may also include the
999 * {@link #CATEGORY_OPENABLE} if you can only accept data that can be
Dianne Hackbornc4d0e6f2011-01-25 14:55:06 -08001000 * opened as a stream. You may use {@link #EXTRA_LOCAL_ONLY} to limit content
Dianne Hackbornfdb3f092013-01-28 15:10:48 -08001001 * selection to local data. You may use {@link #EXTRA_ALLOW_MULTIPLE} to
1002 * allow the user to select multiple items.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001003 * <p>
1004 * Output: The URI of the item that was picked. This must be a content:
1005 * URI so that any receiver can access it.
1006 */
1007 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1008 public static final String ACTION_GET_CONTENT = "android.intent.action.GET_CONTENT";
1009 /**
1010 * Activity Action: Dial a number as specified by the data. This shows a
1011 * UI with the number being dialed, allowing the user to explicitly
1012 * initiate the call.
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 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1019 public static final String ACTION_DIAL = "android.intent.action.DIAL";
1020 /**
1021 * Activity Action: Perform a call to someone specified by the data.
1022 * <p>Input: If nothing, an empty dialer is started; else {@link #getData}
1023 * is URI of a phone number to be dialed or a tel: URI of an explicit phone
1024 * number.
1025 * <p>Output: nothing.
1026 *
1027 * <p>Note: there will be restrictions on which applications can initiate a
1028 * call; most applications should use the {@link #ACTION_DIAL}.
1029 * <p>Note: this Intent <strong>cannot</strong> be used to call emergency
1030 * numbers. Applications can <strong>dial</strong> emergency numbers using
1031 * {@link #ACTION_DIAL}, however.
Svetoslav7008b512015-06-24 18:47:07 -07001032 *
Dianne Hackborn0e3de6c2015-07-29 15:20:21 -07001033 * <p>Note: if you app targets {@link android.os.Build.VERSION_CODES#M M}
Svetoslav7008b512015-06-24 18:47:07 -07001034 * and above and declares as using the {@link android.Manifest.permission#CALL_PHONE}
Svet Ganov7121e182015-07-13 22:38:12 -07001035 * permission which is not granted, then attempting to use this action will
Svetoslav7008b512015-06-24 18:47:07 -07001036 * result in a {@link java.lang.SecurityException}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001037 */
1038 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1039 public static final String ACTION_CALL = "android.intent.action.CALL";
1040 /**
1041 * Activity Action: Perform a call to an emergency number specified by the
1042 * 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_EMERGENCY = "android.intent.action.CALL_EMERGENCY";
1049 /**
1050 * Activity action: Perform a call to any number (emergency or not)
1051 * specified by the data.
1052 * <p>Input: {@link #getData} is URI of a phone number to be dialed or a
1053 * tel: URI of an explicit phone number.
1054 * <p>Output: nothing.
1055 * @hide
1056 */
1057 public static final String ACTION_CALL_PRIVILEGED = "android.intent.action.CALL_PRIVILEGED";
1058 /**
Santos Cordon15a13782015-03-31 18:32:31 -07001059 * Activity action: Activate the current SIM card. If SIM cards do not require activation,
1060 * sending this intent is a no-op.
1061 * <p>Input: No data should be specified. get*Extra may have an optional
1062 * {@link #EXTRA_SIM_ACTIVATION_RESPONSE} field containing a PendingIntent through which to
1063 * send the activation result.
1064 * <p>Output: nothing.
1065 * @hide
1066 */
1067 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1068 public static final String ACTION_SIM_ACTIVATION_REQUEST =
1069 "android.intent.action.SIM_ACTIVATION_REQUEST";
1070 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001071 * Activity Action: Send a message to someone specified by the data.
1072 * <p>Input: {@link #getData} is URI describing the target.
1073 * <p>Output: nothing.
1074 */
1075 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1076 public static final String ACTION_SENDTO = "android.intent.action.SENDTO";
1077 /**
1078 * Activity Action: Deliver some data to someone else. Who the data is
1079 * being delivered to is not specified; it is up to the receiver of this
1080 * action to ask the user where the data should be sent.
1081 * <p>
1082 * When launching a SEND intent, you should usually wrap it in a chooser
1083 * (through {@link #createChooser}), which will give the proper interface
1084 * for the user to pick how to send your data and allow you to specify
1085 * a prompt indicating what they are doing.
1086 * <p>
1087 * Input: {@link #getType} is the MIME type of the data being sent.
1088 * get*Extra can have either a {@link #EXTRA_TEXT}
1089 * or {@link #EXTRA_STREAM} field, containing the data to be sent. If
1090 * using EXTRA_TEXT, the MIME type should be "text/plain"; otherwise it
1091 * should be the MIME type of the data in EXTRA_STREAM. Use {@literal *}/*
1092 * if the MIME type is unknown (this will only allow senders that can
Dianne Hackbornacb69bb2012-04-13 15:36:06 -07001093 * handle generic data streams). If using {@link #EXTRA_TEXT}, you can
1094 * also optionally supply {@link #EXTRA_HTML_TEXT} for clients to retrieve
1095 * your text with HTML formatting.
1096 * <p>
1097 * As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN}, the data
1098 * being sent can be supplied through {@link #setClipData(ClipData)}. This
1099 * allows you to use {@link #FLAG_GRANT_READ_URI_PERMISSION} when sharing
1100 * content: URIs and other advanced features of {@link ClipData}. If
1101 * using this approach, you still must supply the same data through the
1102 * {@link #EXTRA_TEXT} or {@link #EXTRA_STREAM} fields described below
1103 * for compatibility with old applications. If you don't set a ClipData,
1104 * it will be copied there for you when calling {@link Context#startActivity(Intent)}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001105 * <p>
1106 * Optional standard extras, which may be interpreted by some recipients as
1107 * appropriate, are: {@link #EXTRA_EMAIL}, {@link #EXTRA_CC},
1108 * {@link #EXTRA_BCC}, {@link #EXTRA_SUBJECT}.
1109 * <p>
1110 * Output: nothing.
1111 */
1112 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1113 public static final String ACTION_SEND = "android.intent.action.SEND";
1114 /**
Wu-cheng Li649f99e2009-06-17 14:29:57 +08001115 * Activity Action: Deliver multiple data to someone else.
1116 * <p>
Dianne Hackbornacb69bb2012-04-13 15:36:06 -07001117 * Like {@link #ACTION_SEND}, except the data is multiple.
Wu-cheng Li649f99e2009-06-17 14:29:57 +08001118 * <p>
1119 * Input: {@link #getType} is the MIME type of the data being sent.
1120 * get*ArrayListExtra can have either a {@link #EXTRA_TEXT} or {@link
Dianne Hackbornacb69bb2012-04-13 15:36:06 -07001121 * #EXTRA_STREAM} field, containing the data to be sent. If using
1122 * {@link #EXTRA_TEXT}, you can also optionally supply {@link #EXTRA_HTML_TEXT}
1123 * for clients to retrieve your text with HTML formatting.
Wu-cheng Li649f99e2009-06-17 14:29:57 +08001124 * <p>
Chih-Chung Chang5962d272009-09-04 14:36:01 +08001125 * Multiple types are supported, and receivers should handle mixed types
1126 * whenever possible. The right way for the receiver to check them is to
1127 * use the content resolver on each URI. The intent sender should try to
1128 * put the most concrete mime type in the intent type, but it can fall
1129 * back to {@literal <type>/*} or {@literal *}/* as needed.
1130 * <p>
1131 * e.g. if you are sending image/jpg and image/jpg, the intent's type can
1132 * be image/jpg, but if you are sending image/jpg and image/png, then the
1133 * intent's type should be image/*.
1134 * <p>
Dianne Hackbornacb69bb2012-04-13 15:36:06 -07001135 * As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN}, the data
1136 * being sent can be supplied through {@link #setClipData(ClipData)}. This
1137 * allows you to use {@link #FLAG_GRANT_READ_URI_PERMISSION} when sharing
1138 * content: URIs and other advanced features of {@link ClipData}. If
1139 * using this approach, you still must supply the same data through the
1140 * {@link #EXTRA_TEXT} or {@link #EXTRA_STREAM} fields described below
1141 * for compatibility with old applications. If you don't set a ClipData,
1142 * it will be copied there for you when calling {@link Context#startActivity(Intent)}.
1143 * <p>
Wu-cheng Li649f99e2009-06-17 14:29:57 +08001144 * Optional standard extras, which may be interpreted by some recipients as
1145 * appropriate, are: {@link #EXTRA_EMAIL}, {@link #EXTRA_CC},
1146 * {@link #EXTRA_BCC}, {@link #EXTRA_SUBJECT}.
1147 * <p>
1148 * Output: nothing.
1149 */
1150 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1151 public static final String ACTION_SEND_MULTIPLE = "android.intent.action.SEND_MULTIPLE";
1152 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001153 * Activity Action: Handle an incoming phone call.
1154 * <p>Input: nothing.
1155 * <p>Output: nothing.
1156 */
1157 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1158 public static final String ACTION_ANSWER = "android.intent.action.ANSWER";
1159 /**
1160 * Activity Action: Insert an empty item into the given container.
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_INSERT = "android.intent.action.INSERT";
1167 /**
Dianne Hackborn23fdaf62010-08-06 12:16:55 -07001168 * Activity Action: Create a new item in the given container, initializing it
1169 * from the current contents of the clipboard.
1170 * <p>Input: {@link #getData} is URI of the directory (vnd.android.cursor.dir/*)
1171 * in which to place the data.
1172 * <p>Output: URI of the new data that was created.
1173 */
1174 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1175 public static final String ACTION_PASTE = "android.intent.action.PASTE";
1176 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001177 * Activity Action: Delete the given data from its container.
1178 * <p>Input: {@link #getData} is URI of data to be deleted.
1179 * <p>Output: nothing.
1180 */
1181 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1182 public static final String ACTION_DELETE = "android.intent.action.DELETE";
1183 /**
1184 * Activity Action: Run the data, whatever that means.
1185 * <p>Input: ? (Note: this is currently specific to the test harness.)
1186 * <p>Output: nothing.
1187 */
1188 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1189 public static final String ACTION_RUN = "android.intent.action.RUN";
1190 /**
1191 * Activity Action: Perform a data synchronization.
1192 * <p>Input: ?
1193 * <p>Output: ?
1194 */
1195 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1196 public static final String ACTION_SYNC = "android.intent.action.SYNC";
1197 /**
1198 * Activity Action: Pick an activity given an intent, returning the class
1199 * selected.
1200 * <p>Input: get*Extra field {@link #EXTRA_INTENT} is an Intent
1201 * used with {@link PackageManager#queryIntentActivities} to determine the
1202 * set of activities from which to pick.
1203 * <p>Output: Class name of the activity that was selected.
1204 */
1205 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1206 public static final String ACTION_PICK_ACTIVITY = "android.intent.action.PICK_ACTIVITY";
1207 /**
1208 * Activity Action: Perform a search.
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_SEARCH = "android.intent.action.SEARCH";
1216 /**
Jim Miller7e4ad352009-03-25 18:16:41 -07001217 * Activity Action: Start the platform-defined tutorial
1218 * <p>Input: {@link android.app.SearchManager#QUERY getStringExtra(SearchManager.QUERY)}
1219 * is the text to search for. If empty, simply
1220 * enter your search results Activity with the search UI activated.
1221 * <p>Output: nothing.
1222 */
1223 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1224 public static final String ACTION_SYSTEM_TUTORIAL = "android.intent.action.SYSTEM_TUTORIAL";
1225 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001226 * Activity Action: Perform a web search.
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08001227 * <p>
1228 * Input: {@link android.app.SearchManager#QUERY
1229 * getStringExtra(SearchManager.QUERY)} is the text to search for. If it is
1230 * a url starts with http or https, the site will be opened. If it is plain
1231 * text, Google search will be applied.
1232 * <p>
1233 * Output: nothing.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001234 */
1235 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1236 public static final String ACTION_WEB_SEARCH = "android.intent.action.WEB_SEARCH";
Dianne Hackbornf9c5e0f2013-01-23 14:39:13 -08001237
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001238 /**
Jim Miller07994402012-05-02 14:22:27 -07001239 * Activity Action: Perform assist action.
1240 * <p>
Adam Skory7140a252013-09-11 12:04:58 +01001241 * Input: {@link #EXTRA_ASSIST_PACKAGE}, {@link #EXTRA_ASSIST_CONTEXT}, can provide
1242 * additional optional contextual information about where the user was when they
Dianne Hackborna3acdb32015-06-08 17:07:40 -07001243 * requested the assist; {@link #EXTRA_REFERRER} may be set with additional referrer
1244 * information.
Jim Miller07994402012-05-02 14:22:27 -07001245 * Output: nothing.
1246 */
1247 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1248 public static final String ACTION_ASSIST = "android.intent.action.ASSIST";
Dianne Hackbornf9c5e0f2013-01-23 14:39:13 -08001249
1250 /**
Bjorn Bringertbc086862013-03-01 12:59:24 +00001251 * Activity Action: Perform voice assist action.
1252 * <p>
Adam Skory7140a252013-09-11 12:04:58 +01001253 * Input: {@link #EXTRA_ASSIST_PACKAGE}, {@link #EXTRA_ASSIST_CONTEXT}, can provide
1254 * additional optional contextual information about where the user was when they
Adam Skorydfc7fd72013-08-05 19:23:41 -07001255 * requested the voice assist.
Bjorn Bringertbc086862013-03-01 12:59:24 +00001256 * Output: nothing.
Adam Skory7140a252013-09-11 12:04:58 +01001257 * @hide
Bjorn Bringertbc086862013-03-01 12:59:24 +00001258 */
1259 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1260 public static final String ACTION_VOICE_ASSIST = "android.intent.action.VOICE_ASSIST";
1261
1262 /**
Adam Skory7140a252013-09-11 12:04:58 +01001263 * An optional field on {@link #ACTION_ASSIST} containing the name of the current foreground
1264 * application package at the time the assist was invoked.
Dianne Hackbornf9c5e0f2013-01-23 14:39:13 -08001265 */
1266 public static final String EXTRA_ASSIST_PACKAGE
1267 = "android.intent.extra.ASSIST_PACKAGE";
1268
1269 /**
Dianne Hackborna83ce1d2015-03-11 15:16:13 -07001270 * An optional field on {@link #ACTION_ASSIST} containing the uid of the current foreground
1271 * application package at the time the assist was invoked.
1272 */
1273 public static final String EXTRA_ASSIST_UID
1274 = "android.intent.extra.ASSIST_UID";
1275
1276 /**
Adam Skory7140a252013-09-11 12:04:58 +01001277 * An optional field on {@link #ACTION_ASSIST} and containing additional contextual
1278 * information supplied by the current foreground app at the time of the assist request.
1279 * This is a {@link Bundle} of additional data.
Dianne Hackbornf9c5e0f2013-01-23 14:39:13 -08001280 */
1281 public static final String EXTRA_ASSIST_CONTEXT
1282 = "android.intent.extra.ASSIST_CONTEXT";
1283
Jim Miller07994402012-05-02 14:22:27 -07001284 /**
Michael Wright8ab940a2014-09-01 11:01:27 -07001285 * An optional field on {@link #ACTION_ASSIST} suggesting that the user will likely use a
1286 * keyboard as the primary input device for assistance.
1287 */
1288 public static final String EXTRA_ASSIST_INPUT_HINT_KEYBOARD =
1289 "android.intent.extra.ASSIST_INPUT_HINT_KEYBOARD";
1290
1291 /**
Tim Kilbourn0e5f1102015-06-05 16:18:09 -07001292 * An optional field on {@link #ACTION_ASSIST} containing the InputDevice id
1293 * that was used to invoke the assist.
1294 */
1295 public static final String EXTRA_ASSIST_INPUT_DEVICE_ID =
1296 "android.intent.extra.ASSIST_INPUT_DEVICE_ID";
1297
1298 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001299 * Activity Action: List all available applications
1300 * <p>Input: Nothing.
1301 * <p>Output: nothing.
1302 */
1303 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1304 public static final String ACTION_ALL_APPS = "android.intent.action.ALL_APPS";
1305 /**
1306 * Activity Action: Show settings for choosing wallpaper
1307 * <p>Input: Nothing.
1308 * <p>Output: Nothing.
1309 */
1310 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1311 public static final String ACTION_SET_WALLPAPER = "android.intent.action.SET_WALLPAPER";
1312
1313 /**
1314 * Activity Action: Show activity for reporting a bug.
1315 * <p>Input: Nothing.
1316 * <p>Output: Nothing.
1317 */
1318 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1319 public static final String ACTION_BUG_REPORT = "android.intent.action.BUG_REPORT";
1320
1321 /**
1322 * Activity Action: Main entry point for factory tests. Only used when
1323 * the device is booting in factory test node. The implementing package
1324 * must be installed in the system image.
1325 * <p>Input: nothing
1326 * <p>Output: nothing
1327 */
1328 public static final String ACTION_FACTORY_TEST = "android.intent.action.FACTORY_TEST";
1329
1330 /**
1331 * Activity Action: The user pressed the "call" button to go to the dialer
1332 * or other appropriate UI for placing a call.
1333 * <p>Input: Nothing.
1334 * <p>Output: Nothing.
1335 */
1336 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1337 public static final String ACTION_CALL_BUTTON = "android.intent.action.CALL_BUTTON";
1338
1339 /**
1340 * Activity Action: Start Voice Command.
1341 * <p>Input: Nothing.
1342 * <p>Output: Nothing.
1343 */
1344 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1345 public static final String ACTION_VOICE_COMMAND = "android.intent.action.VOICE_COMMAND";
The Android Open Source Projectba87e3e2009-03-13 13:04:22 -07001346
1347 /**
1348 * Activity Action: Start action associated with long pressing on the
1349 * search key.
1350 * <p>Input: Nothing.
1351 * <p>Output: Nothing.
1352 */
1353 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1354 public static final String ACTION_SEARCH_LONG_PRESS = "android.intent.action.SEARCH_LONG_PRESS";
The Android Open Source Project10592532009-03-18 17:39:46 -07001355
Jacek Surazski86b6c532009-05-13 14:38:28 +02001356 /**
1357 * Activity Action: The user pressed the "Report" button in the crash/ANR dialog.
1358 * This intent is delivered to the package which installed the application, usually
Dirk Dougherty4d7bc6552012-01-27 17:56:49 -08001359 * Google Play.
Jacek Surazski86b6c532009-05-13 14:38:28 +02001360 * <p>Input: No data is specified. The bug report is passed in using
1361 * an {@link #EXTRA_BUG_REPORT} field.
1362 * <p>Output: Nothing.
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001363 *
1364 * @see #EXTRA_BUG_REPORT
Jacek Surazski86b6c532009-05-13 14:38:28 +02001365 */
1366 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1367 public static final String ACTION_APP_ERROR = "android.intent.action.APP_ERROR";
Dianne Hackborn3d74bb42009-06-19 10:35:21 -07001368
1369 /**
1370 * Activity Action: Show power usage information to the user.
1371 * <p>Input: Nothing.
1372 * <p>Output: Nothing.
1373 */
1374 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1375 public static final String ACTION_POWER_USAGE_SUMMARY = "android.intent.action.POWER_USAGE_SUMMARY";
Tom Taylord4a47292009-12-21 13:59:18 -08001376
Dianne Hackbornd7cd29d2009-07-01 11:22:45 -07001377 /**
1378 * Activity Action: Setup wizard to launch after a platform update. This
1379 * activity should have a string meta-data field associated with it,
1380 * {@link #METADATA_SETUP_VERSION}, which defines the current version of
1381 * the platform for setup. The activity will be launched only if
1382 * {@link android.provider.Settings.Secure#LAST_SETUP_SHOWN} is not the
1383 * same value.
1384 * <p>Input: Nothing.
1385 * <p>Output: Nothing.
1386 * @hide
1387 */
1388 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1389 public static final String ACTION_UPGRADE_SETUP = "android.intent.action.UPGRADE_SETUP";
Tom Taylord4a47292009-12-21 13:59:18 -08001390
Dianne Hackbornd7cd29d2009-07-01 11:22:45 -07001391 /**
Jeff Sharkey7f868272011-06-05 16:05:02 -07001392 * Activity Action: Show settings for managing network data usage of a
1393 * specific application. Applications should define an activity that offers
1394 * options to control data usage.
1395 */
1396 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1397 public static final String ACTION_MANAGE_NETWORK_USAGE =
1398 "android.intent.action.MANAGE_NETWORK_USAGE";
1399
1400 /**
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001401 * Activity Action: Launch application installer.
1402 * <p>
1403 * Input: The data must be a content: or file: URI at which the application
Dianne Hackborneba784ff2012-09-19 12:42:37 -07001404 * can be retrieved. As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN_MR1},
1405 * you can also use "package:<package-name>" to install an application for the
1406 * current user that is already installed for another user. You can optionally supply
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001407 * {@link #EXTRA_INSTALLER_PACKAGE_NAME}, {@link #EXTRA_NOT_UNKNOWN_SOURCE},
1408 * {@link #EXTRA_ALLOW_REPLACE}, and {@link #EXTRA_RETURN_RESULT}.
1409 * <p>
1410 * Output: If {@link #EXTRA_RETURN_RESULT}, returns whether the install
1411 * succeeded.
Svet Ganov86877e42015-05-28 08:19:48 -07001412 * <p>
1413 * <strong>Note:</strong>If your app is targeting API level higher than 22 you
1414 * need to hold {@link android.Manifest.permission#REQUEST_INSTALL_PACKAGES}
1415 * in order to launch the application installer.
1416 * </p>
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001417 *
1418 * @see #EXTRA_INSTALLER_PACKAGE_NAME
1419 * @see #EXTRA_NOT_UNKNOWN_SOURCE
1420 * @see #EXTRA_RETURN_RESULT
1421 */
1422 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1423 public static final String ACTION_INSTALL_PACKAGE = "android.intent.action.INSTALL_PACKAGE";
1424
1425 /**
1426 * Used as a string extra field with {@link #ACTION_INSTALL_PACKAGE} to install a
1427 * package. Specifies the installer package name; this package will receive the
1428 * {@link #ACTION_APP_ERROR} intent.
1429 */
1430 public static final String EXTRA_INSTALLER_PACKAGE_NAME
1431 = "android.intent.extra.INSTALLER_PACKAGE_NAME";
1432
1433 /**
1434 * Used as a boolean extra field with {@link #ACTION_INSTALL_PACKAGE} to install a
1435 * package. Specifies that the application being installed should not be
1436 * treated as coming from an unknown source, but as coming from the app
1437 * invoking the Intent. For this to work you must start the installer with
1438 * startActivityForResult().
1439 */
1440 public static final String EXTRA_NOT_UNKNOWN_SOURCE
1441 = "android.intent.extra.NOT_UNKNOWN_SOURCE";
1442
1443 /**
rich cannings706e8ba2012-08-20 13:20:14 -07001444 * Used as a URI extra field with {@link #ACTION_INSTALL_PACKAGE} and
1445 * {@link #ACTION_VIEW} to indicate the URI from which the local APK in the Intent
rich cannings368ed012012-06-07 15:37:57 -07001446 * data field originated from.
1447 */
rich cannings706e8ba2012-08-20 13:20:14 -07001448 public static final String EXTRA_ORIGINATING_URI
1449 = "android.intent.extra.ORIGINATING_URI";
rich cannings368ed012012-06-07 15:37:57 -07001450
1451 /**
Dianne Hackborn85d558c2014-11-04 10:31:54 -08001452 * This extra can be used with any Intent used to launch an activity, supplying information
1453 * about who is launching that activity. This field contains a {@link android.net.Uri}
1454 * object, typically an http: or https: URI of the web site that the referral came from;
1455 * it can also use the {@link #URI_ANDROID_APP_SCHEME android-app:} scheme to identify
1456 * a native application that it came from.
1457 *
1458 * <p>To retrieve this value in a client, use {@link android.app.Activity#getReferrer}
1459 * instead of directly retrieving the extra. It is also valid for applications to
1460 * instead supply {@link #EXTRA_REFERRER_NAME} for cases where they can only create
1461 * a string, not a Uri; the field here, if supplied, will always take precedence,
1462 * however.</p>
1463 *
1464 * @see #EXTRA_REFERRER_NAME
rich cannings368ed012012-06-07 15:37:57 -07001465 */
1466 public static final String EXTRA_REFERRER
1467 = "android.intent.extra.REFERRER";
1468
1469 /**
Dianne Hackborn85d558c2014-11-04 10:31:54 -08001470 * Alternate version of {@link #EXTRA_REFERRER} that supplies the URI as a String rather
1471 * than a {@link android.net.Uri} object. Only for use in cases where Uri objects can
1472 * not be created, in particular when Intent extras are supplied through the
1473 * {@link #URI_INTENT_SCHEME intent:} or {@link #URI_ANDROID_APP_SCHEME android-app:}
1474 * schemes.
1475 *
1476 * @see #EXTRA_REFERRER
1477 */
1478 public static final String EXTRA_REFERRER_NAME
1479 = "android.intent.extra.REFERRER_NAME";
1480
1481 /**
Ben Gruver37d83a32012-09-27 13:02:06 -07001482 * Used as an int extra field with {@link #ACTION_INSTALL_PACKAGE} and
1483 * {@link} #ACTION_VIEW} to indicate the uid of the package that initiated the install
1484 * @hide
1485 */
1486 public static final String EXTRA_ORIGINATING_UID
1487 = "android.intent.extra.ORIGINATING_UID";
1488
1489 /**
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001490 * Used as a boolean extra field with {@link #ACTION_INSTALL_PACKAGE} to install a
1491 * package. Tells the installer UI to skip the confirmation with the user
1492 * if the .apk is replacing an existing one.
Dianne Hackborn0e128bb2012-05-01 14:40:15 -07001493 * @deprecated As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN}, Android
1494 * will no longer show an interstitial message about updating existing
1495 * applications so this is no longer needed.
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001496 */
Dianne Hackborn0e128bb2012-05-01 14:40:15 -07001497 @Deprecated
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001498 public static final String EXTRA_ALLOW_REPLACE
1499 = "android.intent.extra.ALLOW_REPLACE";
1500
1501 /**
1502 * Used as a boolean extra field with {@link #ACTION_INSTALL_PACKAGE} or
1503 * {@link #ACTION_UNINSTALL_PACKAGE}. Specifies that the installer UI should
1504 * return to the application the result code of the install/uninstall. The returned result
1505 * code will be {@link android.app.Activity#RESULT_OK} on success or
1506 * {@link android.app.Activity#RESULT_FIRST_USER} on failure.
1507 */
1508 public static final String EXTRA_RETURN_RESULT
1509 = "android.intent.extra.RETURN_RESULT";
1510
1511 /**
1512 * Package manager install result code. @hide because result codes are not
1513 * yet ready to be exposed.
1514 */
1515 public static final String EXTRA_INSTALL_RESULT
1516 = "android.intent.extra.INSTALL_RESULT";
1517
1518 /**
1519 * Activity Action: Launch application uninstaller.
1520 * <p>
1521 * Input: The data must be a package: URI whose scheme specific part is
1522 * the package name of the current installed package to be uninstalled.
1523 * You can optionally supply {@link #EXTRA_RETURN_RESULT}.
1524 * <p>
1525 * Output: If {@link #EXTRA_RETURN_RESULT}, returns whether the install
1526 * succeeded.
1527 */
1528 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1529 public static final String ACTION_UNINSTALL_PACKAGE = "android.intent.action.UNINSTALL_PACKAGE";
1530
1531 /**
Dianne Hackborn6d235d82012-09-16 18:25:40 -07001532 * Specify whether the package should be uninstalled for all users.
1533 * @hide because these should not be part of normal application flow.
1534 */
1535 public static final String EXTRA_UNINSTALL_ALL_USERS
1536 = "android.intent.extra.UNINSTALL_ALL_USERS";
1537
1538 /**
Dianne Hackbornd7cd29d2009-07-01 11:22:45 -07001539 * A string associated with a {@link #ACTION_UPGRADE_SETUP} activity
1540 * describing the last run version of the platform that was setup.
1541 * @hide
1542 */
1543 public static final String METADATA_SETUP_VERSION = "android.SETUP_VERSION";
1544
Svet Ganov3695b8a2015-03-24 16:30:25 -07001545 /**
1546 * Activity action: Launch UI to manage the permissions of an app.
1547 * <p>
1548 * Input: {@link #EXTRA_PACKAGE_NAME} specifies the package whose permissions
1549 * will be managed by the launched UI.
1550 * </p>
1551 * <p>
1552 * Output: Nothing.
1553 * </p>
1554 *
1555 * @see #EXTRA_PACKAGE_NAME
1556 *
1557 * @hide
1558 */
Svet Ganov3695b8a2015-03-24 16:30:25 -07001559 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1560 public static final String ACTION_MANAGE_APP_PERMISSIONS =
1561 "android.intent.action.MANAGE_APP_PERMISSIONS";
1562
1563 /**
Svet Ganov321f0152015-05-16 22:51:50 -07001564 * Activity action: Launch UI to manage permissions.
1565 * <p>
1566 * Input: Nothing.
1567 * </p>
1568 * <p>
1569 * Output: Nothing.
1570 * </p>
1571 *
1572 * @hide
1573 */
Svet Ganov321f0152015-05-16 22:51:50 -07001574 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1575 public static final String ACTION_MANAGE_PERMISSIONS =
1576 "android.intent.action.MANAGE_PERMISSIONS";
1577
1578 /**
Svet Ganov3695b8a2015-03-24 16:30:25 -07001579 * Intent extra: An app package name.
1580 * <p>
1581 * Type: String
Svet Ganov0b316702015-05-23 13:25:11 -07001582 * </p>
Svet Ganov3695b8a2015-03-24 16:30:25 -07001583 *
1584 * @hide
1585 */
1586 @SystemApi
1587 public static final String EXTRA_PACKAGE_NAME = "android.intent.extra.PACKAGE_NAME";
1588
1589 /**
Jason Monk9cfa0cc2015-05-22 14:50:21 -04001590 * Broadcast action that requests current permission granted information. It will respond
1591 * to the request by sending a broadcast with action defined by
1592 * {@link #EXTRA_GET_PERMISSIONS_RESPONSE_INTENT}. The response will contain
Makoto Onukibbb912a2015-06-05 16:27:23 -07001593 * {@link #EXTRA_GET_PERMISSIONS_COUNT_RESULT}, as well as
1594 * {@link #EXTRA_GET_PERMISSIONS_GROUP_LIST_RESULT}, with contents described below or
1595 * a null upon failure.
Jason Monk9cfa0cc2015-05-22 14:50:21 -04001596 *
Makoto Onukibbb912a2015-06-05 16:27:23 -07001597 * <p>If {@link #EXTRA_PACKAGE_NAME} is included then the number of permissions granted, the
1598 * number of permissions requested and the number of granted additional permissions
1599 * by that package will be calculated and included as the first
Jason Monk9cfa0cc2015-05-22 14:50:21 -04001600 * and second elements respectively of an int[] in the response as
Makoto Onukibbb912a2015-06-05 16:27:23 -07001601 * {@link #EXTRA_GET_PERMISSIONS_COUNT_RESULT}. The response will also deliver the list
1602 * of localized permission group names that are granted in
1603 * {@link #EXTRA_GET_PERMISSIONS_GROUP_LIST_RESULT}.
Jason Monk9cfa0cc2015-05-22 14:50:21 -04001604 *
1605 * <p>If {@link #EXTRA_PACKAGE_NAME} is not included then the number of apps granted any runtime
1606 * permissions and the total number of apps requesting runtime permissions will be the first
1607 * and second elements respectively of an int[] in the response as
1608 * {@link #EXTRA_GET_PERMISSIONS_COUNT_RESULT}.
1609 *
1610 * @hide
1611 */
1612 public static final String ACTION_GET_PERMISSIONS_COUNT
1613 = "android.intent.action.GET_PERMISSIONS_COUNT";
1614
1615 /**
1616 * Extra included in response to {@link #ACTION_GET_PERMISSIONS_COUNT}.
1617 * @hide
1618 */
1619 public static final String EXTRA_GET_PERMISSIONS_COUNT_RESULT
1620 = "android.intent.extra.GET_PERMISSIONS_COUNT_RESULT";
1621
1622 /**
Makoto Onukibbb912a2015-06-05 16:27:23 -07001623 * List of CharSequence of localized permission group labels.
1624 * @hide
1625 */
1626 public static final String EXTRA_GET_PERMISSIONS_GROUP_LIST_RESULT
1627 = "android.intent.extra.GET_PERMISSIONS_GROUP_LIST_RESULT";
1628
1629 /**
1630 * Required extra to be sent with {@link #ACTION_GET_PERMISSIONS_COUNT} broadcasts.
Jason Monk9cfa0cc2015-05-22 14:50:21 -04001631 * @hide
1632 */
1633 public static final String EXTRA_GET_PERMISSIONS_RESPONSE_INTENT
1634 = "android.intent.extra.GET_PERMISSIONS_RESONSE_INTENT";
1635
1636 /**
Svet Ganov3695b8a2015-03-24 16:30:25 -07001637 * Activity action: Launch UI to manage which apps have a given permission.
1638 * <p>
1639 * Input: {@link #EXTRA_PERMISSION_NAME} specifies the permission access
1640 * to which will be managed by the launched UI.
1641 * </p>
1642 * <p>
1643 * Output: Nothing.
1644 * </p>
1645 *
1646 * @see #EXTRA_PERMISSION_NAME
1647 *
1648 * @hide
1649 */
Svet Ganov3695b8a2015-03-24 16:30:25 -07001650 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1651 public static final String ACTION_MANAGE_PERMISSION_APPS =
1652 "android.intent.action.MANAGE_PERMISSION_APPS";
1653
1654 /**
1655 * Intent extra: The name of a permission.
1656 * <p>
1657 * Type: String
1658 * </p>
1659 *
1660 * @hide
1661 */
1662 @SystemApi
1663 public static final String EXTRA_PERMISSION_NAME = "android.intent.extra.PERMISSION_NAME";
1664
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001665 // ---------------------------------------------------------------------
1666 // ---------------------------------------------------------------------
1667 // Standard intent broadcast actions (see action variable).
1668
1669 /**
Jeff Brown037c33e2014-04-09 00:31:55 -07001670 * Broadcast Action: Sent when the device goes to sleep and becomes non-interactive.
1671 * <p>
1672 * For historical reasons, the name of this broadcast action refers to the power
1673 * state of the screen but it is actually sent in response to changes in the
1674 * overall interactive state of the device.
1675 * </p><p>
1676 * This broadcast is sent when the device becomes non-interactive which may have
1677 * nothing to do with the screen turning off. To determine the
1678 * actual state of the screen, use {@link android.view.Display#getState}.
1679 * </p><p>
1680 * See {@link android.os.PowerManager#isInteractive} for details.
1681 * </p>
Casey Hodbf6785c2015-03-17 15:59:39 -07001682 * You <em>cannot</em> receive this through components declared in
1683 * manifests, only by explicitly registering for it with
1684 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
1685 * Context.registerReceiver()}.
Tom Taylord4a47292009-12-21 13:59:18 -08001686 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001687 * <p class="note">This is a protected intent that can only be sent
1688 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001689 */
1690 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1691 public static final String ACTION_SCREEN_OFF = "android.intent.action.SCREEN_OFF";
Jeff Brown037c33e2014-04-09 00:31:55 -07001692
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001693 /**
Jeff Brown037c33e2014-04-09 00:31:55 -07001694 * Broadcast Action: Sent when the device wakes up and becomes interactive.
1695 * <p>
1696 * For historical reasons, the name of this broadcast action refers to the power
1697 * state of the screen but it is actually sent in response to changes in the
1698 * overall interactive state of the device.
1699 * </p><p>
1700 * This broadcast is sent when the device becomes interactive which may have
1701 * nothing to do with the screen turning on. To determine the
1702 * actual state of the screen, use {@link android.view.Display#getState}.
1703 * </p><p>
1704 * See {@link android.os.PowerManager#isInteractive} for details.
1705 * </p>
Casey Hodbf6785c2015-03-17 15:59:39 -07001706 * You <em>cannot</em> receive this through components declared in
1707 * manifests, only by explicitly registering for it with
1708 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
1709 * Context.registerReceiver()}.
Tom Taylord4a47292009-12-21 13:59:18 -08001710 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001711 * <p class="note">This is a protected intent that can only be sent
1712 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001713 */
1714 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1715 public static final String ACTION_SCREEN_ON = "android.intent.action.SCREEN_ON";
The Android Open Source Projectb2a3dd82009-03-09 11:52:12 -07001716
1717 /**
Dianne Hackbornbe87e2f2012-09-28 16:31:34 -07001718 * Broadcast Action: Sent after the system stops 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_STOPPED = "android.intent.action.DREAMING_STOPPED";
1725
1726 /**
1727 * Broadcast Action: Sent after the system starts dreaming.
1728 *
1729 * <p class="note">This is a protected intent that can only be sent by the system.
1730 * It is only sent to registered receivers.</p>
1731 */
1732 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1733 public static final String ACTION_DREAMING_STARTED = "android.intent.action.DREAMING_STARTED";
1734
1735 /**
The Android Open Source Project10592532009-03-18 17:39:46 -07001736 * 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 -07001737 * keyguard is gone).
Tom Taylord4a47292009-12-21 13:59:18 -08001738 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001739 * <p class="note">This is a protected intent that can only be sent
1740 * by the system.
The Android Open Source Projectb2a3dd82009-03-09 11:52:12 -07001741 */
1742 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Dianne Hackborn1c633fc2009-12-08 19:45:14 -08001743 public static final String ACTION_USER_PRESENT = "android.intent.action.USER_PRESENT";
The Android Open Source Projectb2a3dd82009-03-09 11:52:12 -07001744
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001745 /**
1746 * Broadcast Action: The current time has changed. Sent every
Casey Hodbf6785c2015-03-17 15:59:39 -07001747 * minute. You <em>cannot</em> receive this through components declared
John Spurlock6098c5d2013-06-17 10:32:46 -04001748 * in manifests, only by explicitly registering for it with
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001749 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
1750 * Context.registerReceiver()}.
Tom Taylord4a47292009-12-21 13:59:18 -08001751 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001752 * <p class="note">This is a protected intent that can only be sent
1753 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001754 */
1755 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1756 public static final String ACTION_TIME_TICK = "android.intent.action.TIME_TICK";
1757 /**
1758 * Broadcast Action: The time was set.
1759 */
1760 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1761 public static final String ACTION_TIME_CHANGED = "android.intent.action.TIME_SET";
1762 /**
1763 * Broadcast Action: The date has changed.
1764 */
1765 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1766 public static final String ACTION_DATE_CHANGED = "android.intent.action.DATE_CHANGED";
1767 /**
1768 * Broadcast Action: The timezone has changed. The intent will have the following extra values:</p>
1769 * <ul>
1770 * <li><em>time-zone</em> - The java.util.TimeZone.getID() value identifying the new time zone.</li>
1771 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08001772 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001773 * <p class="note">This is a protected intent that can only be sent
1774 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001775 */
1776 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1777 public static final String ACTION_TIMEZONE_CHANGED = "android.intent.action.TIMEZONE_CHANGED";
1778 /**
Robert Greenwalt03595d02010-11-02 14:08:23 -07001779 * Clear DNS Cache Action: This is broadcast when networks have changed and old
1780 * DNS entries should be tossed.
1781 * @hide
1782 */
1783 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1784 public static final String ACTION_CLEAR_DNS_CACHE = "android.intent.action.CLEAR_DNS_CACHE";
1785 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001786 * Alarm Changed Action: This is broadcast when the AlarmClock
1787 * application's alarm is set or unset. It is used by the
1788 * AlarmClock application and the StatusBar service.
1789 * @hide
1790 */
1791 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1792 public static final String ACTION_ALARM_CHANGED = "android.intent.action.ALARM_CHANGED";
1793 /**
1794 * Sync State Changed Action: This is broadcast when the sync starts or stops or when one has
1795 * been failing for a long time. It is used by the SyncManager and the StatusBar service.
1796 * @hide
1797 */
1798 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1799 public static final String ACTION_SYNC_STATE_CHANGED
1800 = "android.intent.action.SYNC_STATE_CHANGED";
1801 /**
1802 * Broadcast Action: This is broadcast once, after the system has finished
1803 * booting. It can be used to perform application-specific initialization,
1804 * such as installing alarms. You must hold the
1805 * {@link android.Manifest.permission#RECEIVE_BOOT_COMPLETED} permission
1806 * in order to receive this broadcast.
Tom Taylord4a47292009-12-21 13:59:18 -08001807 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001808 * <p class="note">This is a protected intent that can only be sent
1809 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001810 */
1811 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1812 public static final String ACTION_BOOT_COMPLETED = "android.intent.action.BOOT_COMPLETED";
1813 /**
1814 * Broadcast Action: This is broadcast when a user action should request a
1815 * temporary system dialog to dismiss. Some examples of temporary system
1816 * dialogs are the notification window-shade and the recent tasks dialog.
1817 */
1818 public static final String ACTION_CLOSE_SYSTEM_DIALOGS = "android.intent.action.CLOSE_SYSTEM_DIALOGS";
1819 /**
1820 * Broadcast Action: Trigger the download and eventual installation
1821 * of a package.
1822 * <p>Input: {@link #getData} is the URI of the package file to download.
Tom Taylord4a47292009-12-21 13:59:18 -08001823 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001824 * <p class="note">This is a protected intent that can only be sent
1825 * by the system.
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001826 *
1827 * @deprecated This constant has never been used.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001828 */
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001829 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001830 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1831 public static final String ACTION_PACKAGE_INSTALL = "android.intent.action.PACKAGE_INSTALL";
1832 /**
1833 * Broadcast Action: A new application package has been installed on the
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07001834 * device. The data contains the name of the package. Note that the
1835 * newly installed package does <em>not</em> receive this broadcast.
Jeff Sharkeyd0c6ccb2012-09-14 16:26:37 -07001836 * <p>May include the following extras:
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001837 * <ul>
1838 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the new package.
1839 * <li> {@link #EXTRA_REPLACING} is set to true if this is following
1840 * an {@link #ACTION_PACKAGE_REMOVED} broadcast for the same package.
1841 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08001842 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001843 * <p class="note">This is a protected intent that can only be sent
1844 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001845 */
1846 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1847 public static final String ACTION_PACKAGE_ADDED = "android.intent.action.PACKAGE_ADDED";
1848 /**
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07001849 * Broadcast Action: A new version of an application package has been
1850 * installed, replacing an existing version that was previously installed.
1851 * The data contains the name of the package.
Jeff Sharkeyd0c6ccb2012-09-14 16:26:37 -07001852 * <p>May include the following extras:
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07001853 * <ul>
1854 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the new package.
1855 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08001856 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001857 * <p class="note">This is a protected intent that can only be sent
1858 * by the system.
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07001859 */
1860 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1861 public static final String ACTION_PACKAGE_REPLACED = "android.intent.action.PACKAGE_REPLACED";
1862 /**
Dianne Hackborne7f97212011-02-24 14:40:20 -08001863 * Broadcast Action: A new version of your application has been installed
1864 * over an existing one. This is only sent to the application that was
1865 * replaced. It does not contain any additional data; to receive it, just
1866 * use an intent filter for this action.
1867 *
1868 * <p class="note">This is a protected intent that can only be sent
1869 * by the system.
1870 */
1871 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1872 public static final String ACTION_MY_PACKAGE_REPLACED = "android.intent.action.MY_PACKAGE_REPLACED";
1873 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001874 * Broadcast Action: An existing application package has been removed from
1875 * the device. The data contains the name of the package. The package
1876 * that is being installed does <em>not</em> receive this Intent.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001877 * <ul>
1878 * <li> {@link #EXTRA_UID} containing the integer uid previously assigned
1879 * to the package.
1880 * <li> {@link #EXTRA_DATA_REMOVED} is set to true if the entire
1881 * application -- data and code -- is being removed.
1882 * <li> {@link #EXTRA_REPLACING} is set to true if this will be followed
1883 * by an {@link #ACTION_PACKAGE_ADDED} broadcast for the same package.
1884 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08001885 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001886 * <p class="note">This is a protected intent that can only be sent
1887 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001888 */
1889 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1890 public static final String ACTION_PACKAGE_REMOVED = "android.intent.action.PACKAGE_REMOVED";
1891 /**
Dianne Hackbornf9abb402011-08-10 15:00:59 -07001892 * Broadcast Action: An existing application package has been completely
1893 * removed from the device. The data contains the name of the package.
1894 * This is like {@link #ACTION_PACKAGE_REMOVED}, but only set when
1895 * {@link #EXTRA_DATA_REMOVED} is true and
1896 * {@link #EXTRA_REPLACING} is false of that broadcast.
1897 *
1898 * <ul>
1899 * <li> {@link #EXTRA_UID} containing the integer uid previously assigned
1900 * to the package.
1901 * </ul>
1902 *
1903 * <p class="note">This is a protected intent that can only be sent
1904 * by the system.
1905 */
1906 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1907 public static final String ACTION_PACKAGE_FULLY_REMOVED
1908 = "android.intent.action.PACKAGE_FULLY_REMOVED";
1909 /**
Dianne Hackborn86a72da2009-11-11 20:12:41 -08001910 * Broadcast Action: An existing application package has been changed (e.g.
1911 * a component has been enabled or disabled). The data contains the name of
1912 * the package.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001913 * <ul>
1914 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
Dianne Hackborn86a72da2009-11-11 20:12:41 -08001915 * <li> {@link #EXTRA_CHANGED_COMPONENT_NAME_LIST} containing the class name
Dianne Hackbornfd7aded2013-01-22 17:10:23 -08001916 * of the changed components (or the package name itself).
Dianne Hackborn86a72da2009-11-11 20:12:41 -08001917 * <li> {@link #EXTRA_DONT_KILL_APP} containing boolean field to override the
1918 * default action of restarting the application.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001919 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08001920 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001921 * <p class="note">This is a protected intent that can only be sent
1922 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001923 */
1924 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1925 public static final String ACTION_PACKAGE_CHANGED = "android.intent.action.PACKAGE_CHANGED";
1926 /**
Dianne Hackborn21f1bd12010-02-19 17:02:21 -08001927 * @hide
1928 * Broadcast Action: Ask system services if there is any reason to
1929 * restart the given package. The data contains the name of the
1930 * package.
1931 * <ul>
1932 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
1933 * <li> {@link #EXTRA_PACKAGES} String array of all packages to check.
1934 * </ul>
1935 *
1936 * <p class="note">This is a protected intent that can only be sent
1937 * by the system.
1938 */
Soonil Nagarkar0e8fd092015-02-10 10:37:36 -08001939 @SystemApi
Dianne Hackborn21f1bd12010-02-19 17:02:21 -08001940 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1941 public static final String ACTION_QUERY_PACKAGE_RESTART = "android.intent.action.QUERY_PACKAGE_RESTART";
1942 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001943 * Broadcast Action: The user has restarted a package, and all of its
1944 * processes have been killed. All runtime state
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001945 * associated with it (processes, alarms, notifications, etc) should
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07001946 * be removed. Note that the restarted package does <em>not</em>
1947 * receive this broadcast.
1948 * The data contains the name of the package.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001949 * <ul>
1950 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
1951 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08001952 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001953 * <p class="note">This is a protected intent that can only be sent
1954 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001955 */
1956 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1957 public static final String ACTION_PACKAGE_RESTARTED = "android.intent.action.PACKAGE_RESTARTED";
1958 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001959 * Broadcast Action: The user has cleared the data of a package. This should
1960 * be preceded by {@link #ACTION_PACKAGE_RESTARTED}, after which all of
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07001961 * its persistent data is erased and this broadcast sent.
1962 * Note that the cleared package does <em>not</em>
1963 * receive this broadcast. The data contains the name of the package.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001964 * <ul>
1965 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
1966 * </ul>
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 Project9066cfe2009-03-03 19:31:44 -08001970 */
1971 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1972 public static final String ACTION_PACKAGE_DATA_CLEARED = "android.intent.action.PACKAGE_DATA_CLEARED";
1973 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001974 * Broadcast Action: A user ID has been removed from the system. The user
1975 * ID number is stored in the extra data under {@link #EXTRA_UID}.
Tom Taylord4a47292009-12-21 13:59:18 -08001976 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001977 * <p class="note">This is a protected intent that can only be sent
1978 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001979 */
1980 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1981 public static final String ACTION_UID_REMOVED = "android.intent.action.UID_REMOVED";
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08001982
1983 /**
Dianne Hackborne7f97212011-02-24 14:40:20 -08001984 * Broadcast Action: Sent to the installer package of an application
1985 * when that application is first launched (that is the first time it
1986 * is moved out of the stopped state). The data contains the name of the package.
1987 *
1988 * <p class="note">This is a protected intent that can only be sent
1989 * by the system.
1990 */
1991 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1992 public static final String ACTION_PACKAGE_FIRST_LAUNCH = "android.intent.action.PACKAGE_FIRST_LAUNCH";
1993
1994 /**
Kenny Root5ab21572011-07-27 11:11:19 -07001995 * Broadcast Action: Sent to the system package verifier when a package
1996 * needs to be verified. The data contains the package URI.
1997 * <p class="note">
1998 * This is a protected intent that can only be sent by the system.
1999 * </p>
Kenny Root5ab21572011-07-27 11:11:19 -07002000 */
2001 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2002 public static final String ACTION_PACKAGE_NEEDS_VERIFICATION = "android.intent.action.PACKAGE_NEEDS_VERIFICATION";
2003
2004 /**
rich canningsd1b5cfc2012-08-29 14:49:51 -07002005 * Broadcast Action: Sent to the system package verifier when a package is
2006 * verified. The data contains the package URI.
2007 * <p class="note">
2008 * This is a protected intent that can only be sent by the system.
2009 */
2010 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2011 public static final String ACTION_PACKAGE_VERIFIED = "android.intent.action.PACKAGE_VERIFIED";
2012
2013 /**
Fabrice Di Meglio1c1b4712014-11-19 17:12:32 -08002014 * Broadcast Action: Sent to the system intent filter verifier when an intent filter
2015 * needs to be verified. The data contains the filter data hosts to be verified against.
2016 * <p class="note">
2017 * This is a protected intent that can only be sent by the system.
2018 * </p>
2019 *
2020 * @hide
2021 */
2022 @SystemApi
2023 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2024 public static final String ACTION_INTENT_FILTER_NEEDS_VERIFICATION = "android.intent.action.INTENT_FILTER_NEEDS_VERIFICATION";
2025
2026 /**
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002027 * Broadcast Action: Resources for a set of packages (which were
2028 * previously unavailable) are currently
2029 * available since the media on which they exist is available.
2030 * The extra data {@link #EXTRA_CHANGED_PACKAGE_LIST} contains a
2031 * list of packages whose availability changed.
2032 * The extra data {@link #EXTRA_CHANGED_UID_LIST} contains a
2033 * list of uids of packages whose availability changed.
2034 * Note that the
2035 * packages in this list do <em>not</em> receive this broadcast.
2036 * The specified set of packages are now available on the system.
2037 * <p>Includes the following extras:
2038 * <ul>
2039 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages
2040 * whose resources(were previously unavailable) are currently available.
2041 * {@link #EXTRA_CHANGED_UID_LIST} is the set of uids of the
2042 * packages whose resources(were previously unavailable)
2043 * are currently available.
2044 * </ul>
2045 *
2046 * <p class="note">This is a protected intent that can only be sent
2047 * by the system.
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002048 */
2049 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08002050 public static final String ACTION_EXTERNAL_APPLICATIONS_AVAILABLE =
2051 "android.intent.action.EXTERNAL_APPLICATIONS_AVAILABLE";
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002052
2053 /**
2054 * Broadcast Action: Resources for a set of packages are currently
2055 * unavailable since the media on which they exist is unavailable.
2056 * The extra data {@link #EXTRA_CHANGED_PACKAGE_LIST} contains a
2057 * list of packages whose availability changed.
2058 * The extra data {@link #EXTRA_CHANGED_UID_LIST} contains a
2059 * list of uids of packages whose availability changed.
2060 * The specified set of packages can no longer be
2061 * launched and are practically unavailable on the system.
2062 * <p>Inclues the following extras:
2063 * <ul>
2064 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages
2065 * whose resources are no longer available.
2066 * {@link #EXTRA_CHANGED_UID_LIST} is the set of packages
2067 * whose resources are no longer available.
2068 * </ul>
2069 *
2070 * <p class="note">This is a protected intent that can only be sent
2071 * by the system.
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002072 */
2073 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08002074 public static final String ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE =
Joe Onorato8a051a42010-03-04 15:54:50 -05002075 "android.intent.action.EXTERNAL_APPLICATIONS_UNAVAILABLE";
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002076
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002077 /**
2078 * Broadcast Action: The current system wallpaper has changed. See
Scott Main8b2e0002009-09-29 18:17:31 -07002079 * {@link android.app.WallpaperManager} for retrieving the new wallpaper.
Dianne Hackbornc5bf7582012-04-25 19:12:07 -07002080 * This should <em>only</em> be used to determine when the wallpaper
2081 * has changed to show the new wallpaper to the user. You should certainly
2082 * never, in response to this, change the wallpaper or other attributes of
2083 * it such as the suggested size. That would be crazy, right? You'd cause
2084 * all kinds of loops, especially if other apps are doing similar things,
2085 * right? Of course. So please don't do this.
2086 *
2087 * @deprecated Modern applications should use
2088 * {@link android.view.WindowManager.LayoutParams#FLAG_SHOW_WALLPAPER
2089 * WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER} to have the wallpaper
2090 * shown behind their UI, rather than watching for this broadcast and
2091 * rendering the wallpaper on their own.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002092 */
Dianne Hackbornc5bf7582012-04-25 19:12:07 -07002093 @Deprecated @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002094 public static final String ACTION_WALLPAPER_CHANGED = "android.intent.action.WALLPAPER_CHANGED";
2095 /**
2096 * Broadcast Action: The current device {@link android.content.res.Configuration}
2097 * (orientation, locale, etc) has changed. When such a change happens, the
2098 * UIs (view hierarchy) will need to be rebuilt based on this new
2099 * information; for the most part, applications don't need to worry about
2100 * this, because the system will take care of stopping and restarting the
2101 * application to make sure it sees the new changes. Some system code that
2102 * can not be restarted will need to watch for this action and handle it
2103 * appropriately.
Tom Taylord4a47292009-12-21 13:59:18 -08002104 *
Dianne Hackborn362d5b92009-11-11 18:04:39 -08002105 * <p class="note">
Casey Hodbf6785c2015-03-17 15:59:39 -07002106 * You <em>cannot</em> receive this through components declared
Dianne Hackborn362d5b92009-11-11 18:04:39 -08002107 * in manifests, only by explicitly registering for it with
2108 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
2109 * Context.registerReceiver()}.
Tom Taylord4a47292009-12-21 13:59:18 -08002110 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002111 * <p class="note">This is a protected intent that can only be sent
2112 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002113 *
2114 * @see android.content.res.Configuration
2115 */
2116 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2117 public static final String ACTION_CONFIGURATION_CHANGED = "android.intent.action.CONFIGURATION_CHANGED";
2118 /**
Dianne Hackborn362d5b92009-11-11 18:04:39 -08002119 * Broadcast Action: The current device's locale has changed.
Tom Taylord4a47292009-12-21 13:59:18 -08002120 *
Dianne Hackborn362d5b92009-11-11 18:04:39 -08002121 * <p class="note">This is a protected intent that can only be sent
2122 * by the system.
2123 */
2124 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2125 public static final String ACTION_LOCALE_CHANGED = "android.intent.action.LOCALE_CHANGED";
2126 /**
Dianne Hackbornedd93162009-09-19 14:03:05 -07002127 * Broadcast Action: This is a <em>sticky broadcast</em> containing the
2128 * charging state, level, and other information about the battery.
2129 * See {@link android.os.BatteryManager} for documentation on the
2130 * contents of the Intent.
The Android Open Source Project10592532009-03-18 17:39:46 -07002131 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002132 * <p class="note">
Casey Hodbf6785c2015-03-17 15:59:39 -07002133 * You <em>cannot</em> receive this through components declared
Dianne Hackborn854060af2009-07-09 18:14:31 -07002134 * in manifests, only by explicitly registering for it with
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002135 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
Dianne Hackbornedd93162009-09-19 14:03:05 -07002136 * Context.registerReceiver()}. See {@link #ACTION_BATTERY_LOW},
2137 * {@link #ACTION_BATTERY_OKAY}, {@link #ACTION_POWER_CONNECTED},
2138 * and {@link #ACTION_POWER_DISCONNECTED} for distinct battery-related
2139 * broadcasts that are sent and can be received through manifest
2140 * receivers.
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_CHANGED = "android.intent.action.BATTERY_CHANGED";
2147 /**
2148 * Broadcast Action: Indicates low battery condition on the device.
2149 * This broadcast corresponds to the "Low battery warning" system dialog.
Tom Taylord4a47292009-12-21 13:59:18 -08002150 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002151 * <p class="note">This is a protected intent that can only be sent
2152 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002153 */
2154 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2155 public static final String ACTION_BATTERY_LOW = "android.intent.action.BATTERY_LOW";
2156 /**
Dianne Hackborn1dac2772009-06-26 18:16:48 -07002157 * Broadcast Action: Indicates the battery is now okay after being low.
2158 * This will be sent after {@link #ACTION_BATTERY_LOW} once the battery has
2159 * gone back up to an okay state.
Tom Taylord4a47292009-12-21 13:59:18 -08002160 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002161 * <p class="note">This is a protected intent that can only be sent
2162 * by the system.
Dianne Hackborn1dac2772009-06-26 18:16:48 -07002163 */
2164 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2165 public static final String ACTION_BATTERY_OKAY = "android.intent.action.BATTERY_OKAY";
2166 /**
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002167 * Broadcast Action: External power has been connected to the device.
2168 * This is intended for applications that wish to register specifically to this notification.
2169 * Unlike ACTION_BATTERY_CHANGED, applications will be woken for this and so do not have to
2170 * stay active to receive this notification. This action can be used to implement actions
2171 * that wait until power is available to trigger.
Tom Taylord4a47292009-12-21 13:59:18 -08002172 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002173 * <p class="note">This is a protected intent that can only be sent
2174 * by the system.
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002175 */
2176 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Dianne Hackbornfe240ec2009-08-27 12:51:11 -07002177 public static final String ACTION_POWER_CONNECTED = "android.intent.action.ACTION_POWER_CONNECTED";
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002178 /**
2179 * Broadcast Action: External power has been removed from the device.
2180 * This is intended for applications that wish to register specifically to this notification.
2181 * Unlike ACTION_BATTERY_CHANGED, applications will be woken for this and so do not have to
2182 * stay active to receive this notification. This action can be used to implement actions
Romain Guy4969af72009-06-17 10:53:19 -07002183 * that wait until power is available to trigger.
Tom Taylord4a47292009-12-21 13:59:18 -08002184 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002185 * <p class="note">This is a protected intent that can only be sent
2186 * by the system.
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002187 */
2188 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jean-Baptiste Queru1ef45642008-10-24 11:49:25 -07002189 public static final String ACTION_POWER_DISCONNECTED =
Dianne Hackbornfe240ec2009-08-27 12:51:11 -07002190 "android.intent.action.ACTION_POWER_DISCONNECTED";
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002191 /**
Dianne Hackborn55280a92009-05-07 15:53:46 -07002192 * Broadcast Action: Device is shutting down.
2193 * This is broadcast when the device is being shut down (completely turned
2194 * off, not sleeping). Once the broadcast is complete, the final shutdown
2195 * will proceed and all unsaved data lost. Apps will not normally need
Dianne Hackbornfe240ec2009-08-27 12:51:11 -07002196 * to handle this, since the foreground activity will be paused as well.
Tom Taylord4a47292009-12-21 13:59:18 -08002197 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002198 * <p class="note">This is a protected intent that can only be sent
2199 * by the system.
Dianne Hackborn57a7f592013-07-22 18:21:32 -07002200 * <p>May include the following extras:
2201 * <ul>
2202 * <li> {@link #EXTRA_SHUTDOWN_USERSPACE_ONLY} a boolean that is set to true if this
2203 * shutdown is only for userspace processes. If not set, assumed to be false.
2204 * </ul>
Dianne Hackborn55280a92009-05-07 15:53:46 -07002205 */
2206 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Romain Guy4969af72009-06-17 10:53:19 -07002207 public static final String ACTION_SHUTDOWN = "android.intent.action.ACTION_SHUTDOWN";
Dianne Hackborn55280a92009-05-07 15:53:46 -07002208 /**
Mike Lockwoodbad80e02009-07-30 01:21:08 -07002209 * Activity Action: Start this activity to request system shutdown.
2210 * The optional boolean extra field {@link #EXTRA_KEY_CONFIRM} can be set to true
Yusuke Sato705ffd12015-07-21 15:52:11 -07002211 * to request confirmation from the user before shutting down. The optional boolean
2212 * extra field {@link #EXTRA_USER_REQUESTED_SHUTDOWN} can be set to true to
2213 * indicate that the shutdown is requested by the user.
Mike Lockwoodbad80e02009-07-30 01:21:08 -07002214 *
2215 * <p class="note">This is a protected intent that can only be sent
2216 * by the system.
2217 *
2218 * {@hide}
2219 */
2220 public static final String ACTION_REQUEST_SHUTDOWN = "android.intent.action.ACTION_REQUEST_SHUTDOWN";
2221 /**
Dianne Hackbornedd93162009-09-19 14:03:05 -07002222 * Broadcast Action: A sticky broadcast that indicates low memory
2223 * condition on the device
Tom Taylord4a47292009-12-21 13:59:18 -08002224 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002225 * <p class="note">This is a protected intent that can only be sent
2226 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002227 */
2228 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2229 public static final String ACTION_DEVICE_STORAGE_LOW = "android.intent.action.DEVICE_STORAGE_LOW";
2230 /**
2231 * Broadcast Action: Indicates low memory condition on the device no longer exists
Tom Taylord4a47292009-12-21 13:59:18 -08002232 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002233 * <p class="note">This is a protected intent that can only be sent
2234 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002235 */
2236 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2237 public static final String ACTION_DEVICE_STORAGE_OK = "android.intent.action.DEVICE_STORAGE_OK";
2238 /**
Jake Hambybb371632010-08-23 18:16:48 -07002239 * Broadcast Action: A sticky broadcast that indicates a memory full
2240 * condition on the device. This is intended for activities that want
2241 * to be able to fill the data partition completely, leaving only
2242 * enough free space to prevent system-wide SQLite failures.
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_FULL = "android.intent.action.DEVICE_STORAGE_FULL";
2251 /**
2252 * Broadcast Action: Indicates memory full condition on the device
2253 * no longer exists.
2254 *
2255 * <p class="note">This is a protected intent that can only be sent
2256 * by the system.
2257 *
2258 * {@hide}
2259 */
2260 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2261 public static final String ACTION_DEVICE_STORAGE_NOT_FULL = "android.intent.action.DEVICE_STORAGE_NOT_FULL";
2262 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002263 * Broadcast Action: Indicates low memory condition notification acknowledged by user
2264 * and package management should be started.
2265 * This is triggered by the user from the ACTION_DEVICE_STORAGE_LOW
2266 * notification.
2267 */
2268 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2269 public static final String ACTION_MANAGE_PACKAGE_STORAGE = "android.intent.action.MANAGE_PACKAGE_STORAGE";
2270 /**
2271 * Broadcast Action: The device has entered USB Mass Storage mode.
2272 * This is used mainly for the USB Settings panel.
2273 * Apps should listen for ACTION_MEDIA_MOUNTED and ACTION_MEDIA_UNMOUNTED broadcasts to be notified
2274 * when the SD card file system is mounted or unmounted
Mike Lockwood7e4db372011-06-07 11:23:44 -07002275 * @deprecated replaced by android.os.storage.StorageEventListener
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002276 */
Mike Lockwoodda85e522011-06-07 09:08:34 -07002277 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002278 public static final String ACTION_UMS_CONNECTED = "android.intent.action.UMS_CONNECTED";
2279
2280 /**
2281 * Broadcast Action: The device has exited USB Mass Storage mode.
2282 * This is used mainly for the USB Settings panel.
2283 * Apps should listen for ACTION_MEDIA_MOUNTED and ACTION_MEDIA_UNMOUNTED broadcasts to be notified
2284 * when the SD card file system is mounted or unmounted
Mike Lockwood7e4db372011-06-07 11:23:44 -07002285 * @deprecated replaced by android.os.storage.StorageEventListener
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002286 */
Mike Lockwoodda85e522011-06-07 09:08:34 -07002287 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002288 public static final String ACTION_UMS_DISCONNECTED = "android.intent.action.UMS_DISCONNECTED";
2289
2290 /**
2291 * Broadcast Action: External media has been removed.
2292 * The path to the mount point for the removed media is contained in the Intent.mData field.
2293 */
2294 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2295 public static final String ACTION_MEDIA_REMOVED = "android.intent.action.MEDIA_REMOVED";
2296
2297 /**
2298 * Broadcast Action: External media is present, but not mounted at its mount point.
suyi Yuanbe7af832013-01-04 21:21:59 +08002299 * 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 -07002300 */
2301 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2302 public static final String ACTION_MEDIA_UNMOUNTED = "android.intent.action.MEDIA_UNMOUNTED";
2303
2304 /**
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08002305 * Broadcast Action: External media is present, and being disk-checked
2306 * 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 -08002307 */
2308 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2309 public static final String ACTION_MEDIA_CHECKING = "android.intent.action.MEDIA_CHECKING";
2310
2311 /**
2312 * Broadcast Action: External media is present, but is using an incompatible fs (or is blank)
2313 * 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 -08002314 */
2315 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2316 public static final String ACTION_MEDIA_NOFS = "android.intent.action.MEDIA_NOFS";
2317
2318 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002319 * Broadcast Action: External media is present and mounted at its mount point.
suyi Yuanbe7af832013-01-04 21:21:59 +08002320 * 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 -07002321 * The Intent contains an extra with name "read-only" and Boolean value to indicate if the
2322 * media was mounted read only.
2323 */
2324 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2325 public static final String ACTION_MEDIA_MOUNTED = "android.intent.action.MEDIA_MOUNTED";
2326
2327 /**
2328 * Broadcast Action: External media is unmounted because it is being shared via USB mass storage.
Mike Lockwoodbf2dd442010-03-03 06:16:52 -05002329 * 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 -07002330 */
2331 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2332 public static final String ACTION_MEDIA_SHARED = "android.intent.action.MEDIA_SHARED";
2333
2334 /**
Mike Lockwoodbf2dd442010-03-03 06:16:52 -05002335 * Broadcast Action: External media is no longer being shared via USB mass storage.
2336 * The path to the mount point for the previously shared media is contained in the Intent.mData field.
2337 *
2338 * @hide
2339 */
2340 public static final String ACTION_MEDIA_UNSHARED = "android.intent.action.MEDIA_UNSHARED";
2341
2342 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002343 * Broadcast Action: External media was removed from SD card slot, but mount point was not unmounted.
2344 * The path to the mount point for the removed media is contained in the Intent.mData field.
2345 */
2346 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2347 public static final String ACTION_MEDIA_BAD_REMOVAL = "android.intent.action.MEDIA_BAD_REMOVAL";
2348
2349 /**
2350 * Broadcast Action: External media is present but cannot be mounted.
suyi Yuanbe7af832013-01-04 21:21:59 +08002351 * 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 -07002352 */
2353 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2354 public static final String ACTION_MEDIA_UNMOUNTABLE = "android.intent.action.MEDIA_UNMOUNTABLE";
2355
2356 /**
2357 * Broadcast Action: User has expressed the desire to remove the external storage media.
2358 * Applications should close all files they have open within the mount point when they receive this intent.
2359 * The path to the mount point for the media to be ejected is contained in the Intent.mData field.
2360 */
2361 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2362 public static final String ACTION_MEDIA_EJECT = "android.intent.action.MEDIA_EJECT";
2363
2364 /**
2365 * Broadcast Action: The media scanner has started scanning a directory.
2366 * The path to the directory being scanned is contained in the Intent.mData field.
2367 */
2368 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2369 public static final String ACTION_MEDIA_SCANNER_STARTED = "android.intent.action.MEDIA_SCANNER_STARTED";
2370
2371 /**
2372 * Broadcast Action: The media scanner has finished scanning a directory.
2373 * The path to the scanned directory is contained in the Intent.mData field.
2374 */
2375 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2376 public static final String ACTION_MEDIA_SCANNER_FINISHED = "android.intent.action.MEDIA_SCANNER_FINISHED";
2377
2378 /**
2379 * Broadcast Action: Request the media scanner to scan a file and add it to the media database.
2380 * The path to the file is contained in the Intent.mData field.
2381 */
2382 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2383 public static final String ACTION_MEDIA_SCANNER_SCAN_FILE = "android.intent.action.MEDIA_SCANNER_SCAN_FILE";
2384
2385 /**
2386 * Broadcast Action: The "Media Button" was pressed. Includes a single
2387 * extra field, {@link #EXTRA_KEY_EVENT}, containing the key event that
2388 * caused the broadcast.
2389 */
2390 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2391 public static final String ACTION_MEDIA_BUTTON = "android.intent.action.MEDIA_BUTTON";
2392
2393 /**
2394 * Broadcast Action: The "Camera Button" was pressed. Includes a single
2395 * extra field, {@link #EXTRA_KEY_EVENT}, containing the key event that
2396 * caused the broadcast.
2397 */
2398 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2399 public static final String ACTION_CAMERA_BUTTON = "android.intent.action.CAMERA_BUTTON";
2400
2401 // *** NOTE: @todo(*) The following really should go into a more domain-specific
2402 // location; they are not general-purpose actions.
2403
2404 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09002405 * Broadcast Action: A GTalk connection has been established.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002406 */
2407 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2408 public static final String ACTION_GTALK_SERVICE_CONNECTED =
2409 "android.intent.action.GTALK_CONNECTED";
2410
2411 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09002412 * Broadcast Action: A GTalk connection has been disconnected.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002413 */
2414 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2415 public static final String ACTION_GTALK_SERVICE_DISCONNECTED =
2416 "android.intent.action.GTALK_DISCONNECTED";
The Android Open Source Project10592532009-03-18 17:39:46 -07002417
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08002418 /**
2419 * Broadcast Action: An input method has been changed.
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08002420 */
2421 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2422 public static final String ACTION_INPUT_METHOD_CHANGED =
2423 "android.intent.action.INPUT_METHOD_CHANGED";
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002424
2425 /**
2426 * <p>Broadcast Action: The user has switched the phone into or out of Airplane Mode. One or
2427 * more radios have been turned off or on. The intent will have the following extra value:</p>
2428 * <ul>
2429 * <li><em>state</em> - A boolean value indicating whether Airplane Mode is on. If true,
2430 * then cell radio and possibly other radios such as bluetooth or WiFi may have also been
2431 * turned off</li>
2432 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002433 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002434 * <p class="note">This is a protected intent that can only be sent
2435 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002436 */
2437 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2438 public static final String ACTION_AIRPLANE_MODE_CHANGED = "android.intent.action.AIRPLANE_MODE";
2439
2440 /**
2441 * Broadcast Action: Some content providers have parts of their namespace
2442 * where they publish new events or items that the user may be especially
2443 * interested in. For these things, they may broadcast this action when the
2444 * set of interesting items change.
2445 *
2446 * For example, GmailProvider sends this notification when the set of unread
2447 * mail in the inbox changes.
2448 *
2449 * <p>The data of the intent identifies which part of which provider
2450 * changed. When queried through the content resolver, the data URI will
2451 * return the data set in question.
2452 *
2453 * <p>The intent will have the following extra values:
2454 * <ul>
2455 * <li><em>count</em> - The number of items in the data set. This is the
2456 * same as the number of items in the cursor returned by querying the
2457 * data URI. </li>
2458 * </ul>
2459 *
2460 * This intent will be sent at boot (if the count is non-zero) and when the
2461 * data set changes. It is possible for the data set to change without the
2462 * count changing (for example, if a new unread message arrives in the same
2463 * sync operation in which a message is archived). The phone should still
2464 * ring/vibrate/etc as normal in this case.
2465 */
2466 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2467 public static final String ACTION_PROVIDER_CHANGED =
2468 "android.intent.action.PROVIDER_CHANGED";
2469
2470 /**
2471 * Broadcast Action: Wired Headset plugged in or unplugged.
2472 *
Jean-Michel Trivic5258432014-08-27 15:46:54 -07002473 * Same as {@link android.media.AudioManager#ACTION_HEADSET_PLUG}, to be consulted for value
2474 * and documentation.
2475 * <p>If the minimum SDK version of your application is
Dianne Hackborn955d8d62014-10-07 20:17:19 -07002476 * {@link android.os.Build.VERSION_CODES#LOLLIPOP}, it is recommended to refer
Jean-Michel Trivic5258432014-08-27 15:46:54 -07002477 * to the <code>AudioManager</code> constant in your receiver registration code instead.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002478 */
2479 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jean-Michel Trivic5258432014-08-27 15:46:54 -07002480 public static final String ACTION_HEADSET_PLUG = android.media.AudioManager.ACTION_HEADSET_PLUG;
Eric Laurent59f48272012-04-05 19:42:21 -07002481
2482 /**
Joe Onorato9cdffa12011-04-06 18:27:27 -07002483 * <p>Broadcast Action: The user has switched on advanced settings in the settings app:</p>
2484 * <ul>
2485 * <li><em>state</em> - A boolean value indicating whether the settings is on or off.</li>
2486 * </ul>
2487 *
2488 * <p class="note">This is a protected intent that can only be sent
2489 * by the system.
2490 *
2491 * @hide
2492 */
2493 //@SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2494 public static final String ACTION_ADVANCED_SETTINGS_CHANGED
2495 = "android.intent.action.ADVANCED_SETTINGS";
2496
2497 /**
Robin Lee66e5d962014-04-09 16:44:21 +01002498 * Broadcast Action: Sent after application restrictions are changed.
2499 *
2500 * <p class="note">This is a protected intent that can only be sent
2501 * by the system.</p>
2502 */
2503 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2504 public static final String ACTION_APPLICATION_RESTRICTIONS_CHANGED =
2505 "android.intent.action.APPLICATION_RESTRICTIONS_CHANGED";
2506
2507 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002508 * Broadcast Action: An outgoing call is about to be placed.
2509 *
Dirk Dougherty367ce902013-05-28 17:37:12 -07002510 * <p>The Intent will have the following extra value:</p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002511 * <ul>
The Android Open Source Project10592532009-03-18 17:39:46 -07002512 * <li><em>{@link android.content.Intent#EXTRA_PHONE_NUMBER}</em> -
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002513 * the phone number originally intended to be dialed.</li>
2514 * </ul>
2515 * <p>Once the broadcast is finished, the resultData is used as the actual
2516 * number to call. If <code>null</code>, no call will be placed.</p>
The Android Open Source Project10592532009-03-18 17:39:46 -07002517 * <p>It is perfectly acceptable for multiple receivers to process the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002518 * outgoing call in turn: for example, a parental control application
2519 * might verify that the user is authorized to place the call at that
2520 * time, then a number-rewriting application might add an area code if
2521 * one was not specified.</p>
2522 * <p>For consistency, any receiver whose purpose is to prohibit phone
2523 * calls should have a priority of 0, to ensure it will see the final
2524 * phone number to be dialed.
The Android Open Source Project10592532009-03-18 17:39:46 -07002525 * Any receiver whose purpose is to rewrite phone numbers to be called
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002526 * should have a positive priority.
2527 * Negative priorities are reserved for the system for this broadcast;
2528 * using them may cause problems.</p>
Dirk Dougherty932fbcc2013-05-29 15:19:14 -07002529 * <p>Any BroadcastReceiver receiving this Intent <em>must not</em>
2530 * abort the broadcast.</p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002531 * <p>Emergency calls cannot be intercepted using this mechanism, and
2532 * other calls cannot be modified to call emergency numbers using this
2533 * mechanism.
Santos Cordonba701362013-05-17 14:48:54 -07002534 * <p>Some apps (such as VoIP apps) may want to redirect the outgoing
2535 * call to use their own service instead. Those apps should first prevent
2536 * the call from being placed by setting resultData to <code>null</code>
2537 * and then start their own app to make the call.
The Android Open Source Project10592532009-03-18 17:39:46 -07002538 * <p>You must hold the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002539 * {@link android.Manifest.permission#PROCESS_OUTGOING_CALLS}
2540 * permission to receive this Intent.</p>
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_NEW_OUTGOING_CALL =
2547 "android.intent.action.NEW_OUTGOING_CALL";
2548
2549 /**
2550 * Broadcast Action: Have the device reboot. This is only for use by
2551 * system code.
Tom Taylord4a47292009-12-21 13:59:18 -08002552 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002553 * <p class="note">This is a protected intent that can only be sent
2554 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002555 */
2556 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2557 public static final String ACTION_REBOOT =
2558 "android.intent.action.REBOOT";
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002559
Wei Huang97ecc9c2009-05-11 17:44:20 -07002560 /**
Dianne Hackborn7299c412010-03-04 18:41:49 -08002561 * Broadcast Action: A sticky broadcast for changes in the physical
2562 * docking state of the device.
Tobias Haamel154f7a12010-02-17 11:56:39 -08002563 *
2564 * <p>The intent will have the following extra values:
2565 * <ul>
2566 * <li><em>{@link #EXTRA_DOCK_STATE}</em> - the current dock
Dianne Hackborn7299c412010-03-04 18:41:49 -08002567 * state, indicating which dock the device is physically in.</li>
Tobias Haamel154f7a12010-02-17 11:56:39 -08002568 * </ul>
Dianne Hackborn7299c412010-03-04 18:41:49 -08002569 * <p>This is intended for monitoring the current physical dock state.
2570 * See {@link android.app.UiModeManager} for the normal API dealing with
2571 * dock mode changes.
Dianne Hackbornedd93162009-09-19 14:03:05 -07002572 */
2573 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2574 public static final String ACTION_DOCK_EVENT =
2575 "android.intent.action.DOCK_EVENT";
2576
2577 /**
Svetoslavb3038ec2013-02-13 14:39:30 -08002578 * Broadcast Action: A broadcast when idle maintenance can be started.
2579 * This means that the user is not interacting with the device and is
2580 * not expected to do so soon. Typical use of the idle maintenance is
2581 * to perform somehow expensive tasks that can be postponed at a moment
2582 * when they will not degrade user experience.
2583 * <p>
2584 * <p class="note">In order to keep the device responsive in case of an
2585 * unexpected user interaction, implementations of a maintenance task
2586 * should be interruptible. In such a scenario a broadcast with action
2587 * {@link #ACTION_IDLE_MAINTENANCE_END} will be sent. In other words, you
2588 * should not do the maintenance work in
2589 * {@link BroadcastReceiver#onReceive(Context, Intent)}, rather start a
2590 * maintenance service by {@link Context#startService(Intent)}. Also
2591 * you should hold a wake lock while your maintenance service is running
2592 * to prevent the device going to sleep.
2593 * </p>
2594 * <p>
2595 * <p class="note">This is a protected intent that can only be sent by
2596 * the system.
2597 * </p>
2598 *
2599 * @see #ACTION_IDLE_MAINTENANCE_END
Svetoslav6a08a122013-05-03 11:24:26 -07002600 *
2601 * @hide
Svetoslavb3038ec2013-02-13 14:39:30 -08002602 */
2603 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2604 public static final String ACTION_IDLE_MAINTENANCE_START =
2605 "android.intent.action.ACTION_IDLE_MAINTENANCE_START";
2606
2607 /**
2608 * Broadcast Action: A broadcast when idle maintenance should be stopped.
2609 * This means that the user was not interacting with the device as a result
2610 * of which a broadcast with action {@link #ACTION_IDLE_MAINTENANCE_START}
2611 * was sent and now the user started interacting with the device. Typical
2612 * use of the idle maintenance is to perform somehow expensive tasks that
2613 * can be postponed at a moment when they will not degrade user experience.
2614 * <p>
2615 * <p class="note">In order to keep the device responsive in case of an
2616 * unexpected user interaction, implementations of a maintenance task
2617 * should be interruptible. Hence, on receiving a broadcast with this
2618 * action, the maintenance task should be interrupted as soon as possible.
2619 * In other words, you should not do the maintenance work in
2620 * {@link BroadcastReceiver#onReceive(Context, Intent)}, rather stop the
2621 * maintenance service that was started on receiving of
2622 * {@link #ACTION_IDLE_MAINTENANCE_START}.Also you should release the wake
2623 * lock you acquired when your maintenance service started.
2624 * </p>
2625 * <p class="note">This is a protected intent that can only be sent
2626 * by the system.
2627 *
2628 * @see #ACTION_IDLE_MAINTENANCE_START
Svetoslav6a08a122013-05-03 11:24:26 -07002629 *
2630 * @hide
Svetoslavb3038ec2013-02-13 14:39:30 -08002631 */
2632 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2633 public static final String ACTION_IDLE_MAINTENANCE_END =
2634 "android.intent.action.ACTION_IDLE_MAINTENANCE_END";
2635
2636 /**
Wei Huang97ecc9c2009-05-11 17:44:20 -07002637 * Broadcast Action: a remote intent is to be broadcasted.
2638 *
2639 * A remote intent is used for remote RPC between devices. The remote intent
2640 * is serialized and sent from one device to another device. The receiving
2641 * device parses the remote intent and broadcasts it. Note that anyone can
2642 * broadcast a remote intent. However, if the intent receiver of the remote intent
2643 * does not trust intent broadcasts from arbitrary intent senders, it should require
2644 * the sender to hold certain permissions so only trusted sender's broadcast will be
2645 * let through.
Dianne Hackbornedd93162009-09-19 14:03:05 -07002646 * @hide
Wei Huang97ecc9c2009-05-11 17:44:20 -07002647 */
2648 public static final String ACTION_REMOTE_INTENT =
Costin Manolache8d83f9e2010-05-12 16:04:10 -07002649 "com.google.android.c2dm.intent.RECEIVE";
Wei Huang97ecc9c2009-05-11 17:44:20 -07002650
Dianne Hackborn9acc0302009-08-25 00:27:12 -07002651 /**
2652 * Broadcast Action: hook for permforming cleanup after a system update.
2653 *
2654 * The broadcast is sent when the system is booting, before the
2655 * BOOT_COMPLETED broadcast. It is only sent to receivers in the system
2656 * image. A receiver for this should do its work and then disable itself
2657 * so that it does not get run again at the next boot.
2658 * @hide
2659 */
2660 public static final String ACTION_PRE_BOOT_COMPLETED =
2661 "android.intent.action.PRE_BOOT_COMPLETED";
2662
Amith Yamasani13593602012-03-22 16:16:17 -07002663 /**
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08002664 * Broadcast to a specific application to query any supported restrictions to impose
Amith Yamasani7e99bc02013-04-16 18:24:51 -07002665 * on restricted users. The broadcast intent contains an extra
2666 * {@link #EXTRA_RESTRICTIONS_BUNDLE} with the currently persisted
2667 * restrictions as a Bundle of key/value pairs. The value types can be Boolean, String or
2668 * String[] depending on the restriction type.<p/>
2669 * The response should contain an extra {@link #EXTRA_RESTRICTIONS_LIST},
Amith Yamasani86118ba2013-03-28 14:33:16 -07002670 * which is of type <code>ArrayList&lt;RestrictionEntry&gt;</code>. It can also
2671 * contain an extra {@link #EXTRA_RESTRICTIONS_INTENT}, which is of type <code>Intent</code>.
2672 * The activity specified by that intent will be launched for a result which must contain
Amith Yamasani3b458ad2013-04-18 18:40:07 -07002673 * one of the extras {@link #EXTRA_RESTRICTIONS_LIST} or {@link #EXTRA_RESTRICTIONS_BUNDLE}.
2674 * The keys and values of the returned restrictions will be persisted.
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08002675 * @see RestrictionEntry
2676 */
2677 public static final String ACTION_GET_RESTRICTION_ENTRIES =
2678 "android.intent.action.GET_RESTRICTION_ENTRIES";
2679
2680 /**
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002681 * Sent the first time a user is starting, to allow system apps to
2682 * perform one time initialization. (This will not be seen by third
2683 * party applications because a newly initialized user does not have any
2684 * third party applications installed for it.) This is sent early in
2685 * starting the user, around the time the home app is started, before
Dianne Hackborn36d337a2012-10-08 14:33:47 -07002686 * {@link #ACTION_BOOT_COMPLETED} is sent. This is sent as a foreground
2687 * broadcast, since it is part of a visible user interaction; be as quick
2688 * as possible when handling it.
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002689 */
2690 public static final String ACTION_USER_INITIALIZE =
2691 "android.intent.action.USER_INITIALIZE";
2692
2693 /**
2694 * Sent when a user switch is happening, causing the process's user to be
2695 * brought to the foreground. This is only sent to receivers registered
2696 * through {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
2697 * Context.registerReceiver}. It is sent to the user that is going to the
Dianne Hackborn36d337a2012-10-08 14:33:47 -07002698 * foreground. This is sent as a foreground
2699 * broadcast, since it is part of a visible user interaction; be as quick
2700 * as possible when handling it.
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002701 */
2702 public static final String ACTION_USER_FOREGROUND =
2703 "android.intent.action.USER_FOREGROUND";
2704
2705 /**
2706 * Sent when a user switch is happening, causing the process's user to be
2707 * sent to the background. This is only sent to receivers registered
2708 * through {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
2709 * Context.registerReceiver}. It is sent to the user that is going to the
Dianne Hackborn36d337a2012-10-08 14:33:47 -07002710 * background. This is sent as a foreground
2711 * broadcast, since it is part of a visible user interaction; be as quick
2712 * as possible when handling it.
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002713 */
2714 public static final String ACTION_USER_BACKGROUND =
2715 "android.intent.action.USER_BACKGROUND";
2716
2717 /**
Dianne Hackborn36d337a2012-10-08 14:33:47 -07002718 * Broadcast sent to the system when a user is added. Carries an extra
2719 * EXTRA_USER_HANDLE that has the userHandle of the new user. It is sent to
2720 * all running users. You must hold
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002721 * {@link android.Manifest.permission#MANAGE_USERS} to receive this broadcast.
Amith Yamasani13593602012-03-22 16:16:17 -07002722 * @hide
2723 */
2724 public static final String ACTION_USER_ADDED =
2725 "android.intent.action.USER_ADDED";
2726
2727 /**
Dianne Hackborn36d337a2012-10-08 14:33:47 -07002728 * Broadcast sent by the system when a user is started. Carries an extra
2729 * EXTRA_USER_HANDLE that has the userHandle of the user. This is only sent to
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002730 * registered receivers, not manifest receivers. It is sent to the user
Dianne Hackborn36d337a2012-10-08 14:33:47 -07002731 * that has been started. This is sent as a foreground
2732 * broadcast, since it is part of a visible user interaction; be as quick
2733 * as possible when handling it.
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002734 * @hide
2735 */
2736 public static final String ACTION_USER_STARTED =
2737 "android.intent.action.USER_STARTED";
2738
2739 /**
Dianne Hackborn36d337a2012-10-08 14:33:47 -07002740 * Broadcast sent when a user is in the process of starting. Carries an extra
2741 * EXTRA_USER_HANDLE that has the userHandle of the user. This is only
2742 * sent to registered receivers, not manifest receivers. It is sent to all
2743 * users (including the one that is being started). You must hold
2744 * {@link android.Manifest.permission#INTERACT_ACROSS_USERS} to receive
2745 * this broadcast. This is sent as a background broadcast, since
2746 * its result is not part of the primary UX flow; to safely keep track of
2747 * started/stopped state of a user you can use this in conjunction with
2748 * {@link #ACTION_USER_STOPPING}. It is <b>not</b> generally safe to use with
2749 * other user state broadcasts since those are foreground broadcasts so can
2750 * execute in a different order.
2751 * @hide
2752 */
2753 public static final String ACTION_USER_STARTING =
2754 "android.intent.action.USER_STARTING";
2755
2756 /**
2757 * Broadcast sent when a user is going to be stopped. Carries an extra
2758 * EXTRA_USER_HANDLE that has the userHandle of the user. This is only
2759 * sent to registered receivers, not manifest receivers. It is sent to all
2760 * users (including the one that is being stopped). You must hold
2761 * {@link android.Manifest.permission#INTERACT_ACROSS_USERS} to receive
2762 * this broadcast. The user will not stop until all receivers have
2763 * handled the broadcast. This is sent as a background broadcast, since
2764 * its result is not part of the primary UX flow; to safely keep track of
2765 * started/stopped state of a user you can use this in conjunction with
2766 * {@link #ACTION_USER_STARTING}. It is <b>not</b> generally safe to use with
2767 * other user state broadcasts since those are foreground broadcasts so can
2768 * execute in a different order.
2769 * @hide
2770 */
2771 public static final String ACTION_USER_STOPPING =
2772 "android.intent.action.USER_STOPPING";
2773
2774 /**
2775 * Broadcast sent to the system when a user is stopped. Carries an extra
2776 * EXTRA_USER_HANDLE that has the userHandle of the user. This is similar to
2777 * {@link #ACTION_PACKAGE_RESTARTED}, but for an entire user instead of a
2778 * specific package. This is only sent to registered receivers, not manifest
2779 * receivers. It is sent to all running users <em>except</em> the one that
2780 * has just been stopped (which is no longer running).
Dianne Hackborn80a4af22012-08-27 19:18:31 -07002781 * @hide
2782 */
2783 public static final String ACTION_USER_STOPPED =
2784 "android.intent.action.USER_STOPPED";
2785
2786 /**
Amith Yamasani2a003292012-08-14 18:25:45 -07002787 * 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 -07002788 * the userHandle of the user. It is sent to all running users except the
Amith Yamasanidb6a14c2012-10-17 21:16:52 -07002789 * one that has been removed. The user will not be completely removed until all receivers have
2790 * handled the broadcast. You must hold
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002791 * {@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_REMOVED =
2795 "android.intent.action.USER_REMOVED";
2796
2797 /**
Amith Yamasani2a003292012-08-14 18:25:45 -07002798 * Broadcast sent to the system when the user switches. Carries an extra EXTRA_USER_HANDLE that has
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002799 * the userHandle of the user to become the current one. This is only sent to
2800 * registered receivers, not manifest receivers. It is sent to all running users.
2801 * You must hold
2802 * {@link android.Manifest.permission#MANAGE_USERS} to receive this broadcast.
Amith Yamasani13593602012-03-22 16:16:17 -07002803 * @hide
2804 */
2805 public static final String ACTION_USER_SWITCHED =
2806 "android.intent.action.USER_SWITCHED";
2807
Amith Yamasanie928d7d2012-09-17 21:46:51 -07002808 /**
2809 * Broadcast sent to the system when a user's information changes. Carries an extra
2810 * {@link #EXTRA_USER_HANDLE} to indicate which user's information changed.
Amith Yamasani6fc1d4e2013-05-08 16:43:58 -07002811 * This is only sent to registered receivers, not manifest receivers. It is sent to all users.
Amith Yamasanie928d7d2012-09-17 21:46:51 -07002812 * @hide
2813 */
2814 public static final String ACTION_USER_INFO_CHANGED =
2815 "android.intent.action.USER_INFO_CHANGED";
2816
Daniel Sandler2e7d25b2012-10-01 16:43:26 -04002817 /**
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01002818 * Broadcast sent to the primary user when an associated managed profile is added (the profile
2819 * was created and is ready to be used). Carries an extra {@link #EXTRA_USER} that specifies
Adam Connorsd4b584e2014-06-09 13:55:47 +01002820 * the UserHandle of the profile that was added. Only applications (for example Launchers)
2821 * that need to display merged content across both primary and managed profiles need to
2822 * worry about this broadcast. This is only sent to registered receivers,
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01002823 * not manifest receivers.
2824 */
2825 public static final String ACTION_MANAGED_PROFILE_ADDED =
2826 "android.intent.action.MANAGED_PROFILE_ADDED";
2827
2828 /**
2829 * Broadcast sent to the primary user when an associated managed profile is removed. Carries an
Adam Connorsd4b584e2014-06-09 13:55:47 +01002830 * extra {@link #EXTRA_USER} that specifies the UserHandle of the profile that was removed.
2831 * Only applications (for example Launchers) that need to display merged content across both
2832 * primary and managed profiles need to worry about this broadcast. This is only sent to
2833 * registered receivers, not manifest receivers.
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01002834 */
2835 public static final String ACTION_MANAGED_PROFILE_REMOVED =
2836 "android.intent.action.MANAGED_PROFILE_REMOVED";
2837
2838 /**
Daniel Sandler2e7d25b2012-10-01 16:43:26 -04002839 * Sent when the user taps on the clock widget in the system's "quick settings" area.
2840 */
2841 public static final String ACTION_QUICK_CLOCK =
2842 "android.intent.action.QUICK_CLOCK";
2843
Michael Wright0087a142013-02-05 16:29:39 -08002844 /**
Alan Viverette5a399492014-07-14 16:19:38 -07002845 * Activity Action: Shows the brightness setting dialog.
Michael Wright0087a142013-02-05 16:29:39 -08002846 * @hide
2847 */
2848 public static final String ACTION_SHOW_BRIGHTNESS_DIALOG =
2849 "android.intent.action.SHOW_BRIGHTNESS_DIALOG";
2850
Justin Kohd378ad72013-04-01 12:18:26 -07002851 /**
2852 * Broadcast Action: A global button was pressed. Includes a single
2853 * extra field, {@link #EXTRA_KEY_EVENT}, containing the key event that
2854 * caused the broadcast.
2855 * @hide
2856 */
2857 public static final String ACTION_GLOBAL_BUTTON = "android.intent.action.GLOBAL_BUTTON";
2858
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07002859 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07002860 * Activity Action: Allow the user to select and return one or more existing
2861 * documents. When invoked, the system will display the various
2862 * {@link DocumentsProvider} instances installed on the device, letting the
2863 * user interactively navigate through them. These documents include local
2864 * media, such as photos and video, and documents provided by installed
2865 * cloud storage providers.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07002866 * <p>
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07002867 * Each document is represented as a {@code content://} URI backed by a
2868 * {@link DocumentsProvider}, which can be opened as a stream with
2869 * {@link ContentResolver#openFileDescriptor(Uri, String)}, or queried for
2870 * {@link android.provider.DocumentsContract.Document} metadata.
2871 * <p>
2872 * All selected documents are returned to the calling application with
2873 * persistable read and write permission grants. If you want to maintain
2874 * access to the documents across device reboots, you need to explicitly
2875 * take the persistable permissions using
2876 * {@link ContentResolver#takePersistableUriPermission(Uri, int)}.
2877 * <p>
Jeff Sharkey21de56a2014-04-05 19:05:24 -07002878 * Callers must indicate the acceptable document MIME types through
2879 * {@link #setType(String)}. For example, to select photos, use
2880 * {@code image/*}. If multiple disjoint MIME types are acceptable, define
2881 * them in {@link #EXTRA_MIME_TYPES} and {@link #setType(String)} to
2882 * {@literal *}/*.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07002883 * <p>
2884 * If the caller can handle multiple returned items (the user performing
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07002885 * multiple selection), then you can specify {@link #EXTRA_ALLOW_MULTIPLE}
2886 * to indicate this.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07002887 * <p>
Jeff Sharkeybd3b9022013-08-20 15:20:04 -07002888 * Callers must include {@link #CATEGORY_OPENABLE} in the Intent so that
2889 * returned URIs can be opened with
2890 * {@link ContentResolver#openFileDescriptor(Uri, String)}.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07002891 * <p>
Jeff Sharkey21de56a2014-04-05 19:05:24 -07002892 * Output: The URI of the item that was picked, returned in
2893 * {@link #getData()}. This must be a {@code content://} URI so that any
2894 * receiver can access it. If multiple documents were selected, they are
2895 * returned in {@link #getClipData()}.
Jeff Sharkeybd3b9022013-08-20 15:20:04 -07002896 *
2897 * @see DocumentsContract
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07002898 * @see #ACTION_OPEN_DOCUMENT_TREE
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07002899 * @see #ACTION_CREATE_DOCUMENT
2900 * @see #FLAG_GRANT_PERSISTABLE_URI_PERMISSION
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07002901 */
2902 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
2903 public static final String ACTION_OPEN_DOCUMENT = "android.intent.action.OPEN_DOCUMENT";
2904
2905 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07002906 * Activity Action: Allow the user to create a new document. When invoked,
2907 * the system will display the various {@link DocumentsProvider} instances
2908 * installed on the device, letting the user navigate through them. The
2909 * returned document may be a newly created document with no content, or it
2910 * may be an existing document with the requested MIME type.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07002911 * <p>
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07002912 * Each document is represented as a {@code content://} URI backed by a
2913 * {@link DocumentsProvider}, which can be opened as a stream with
2914 * {@link ContentResolver#openFileDescriptor(Uri, String)}, or queried for
2915 * {@link android.provider.DocumentsContract.Document} metadata.
2916 * <p>
2917 * Callers must indicate the concrete MIME type of the document being
2918 * created by setting {@link #setType(String)}. This MIME type cannot be
2919 * changed after the document is created.
2920 * <p>
2921 * Callers can provide an initial display name through {@link #EXTRA_TITLE},
2922 * but the user may change this value before creating the file.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07002923 * <p>
Jeff Sharkeybd3b9022013-08-20 15:20:04 -07002924 * Callers must include {@link #CATEGORY_OPENABLE} in the Intent so that
2925 * returned URIs can be opened with
2926 * {@link ContentResolver#openFileDescriptor(Uri, String)}.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07002927 * <p>
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07002928 * Output: The URI of the item that was created. This must be a
2929 * {@code content://} URI so that any receiver can access it.
Jeff Sharkeybd3b9022013-08-20 15:20:04 -07002930 *
2931 * @see DocumentsContract
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07002932 * @see #ACTION_OPEN_DOCUMENT
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07002933 * @see #ACTION_OPEN_DOCUMENT_TREE
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07002934 * @see #FLAG_GRANT_PERSISTABLE_URI_PERMISSION
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07002935 */
2936 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
2937 public static final String ACTION_CREATE_DOCUMENT = "android.intent.action.CREATE_DOCUMENT";
2938
Jeff Sharkey21de56a2014-04-05 19:05:24 -07002939 /**
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07002940 * Activity Action: Allow the user to pick a directory subtree. When
2941 * invoked, the system will display the various {@link DocumentsProvider}
2942 * instances installed on the device, letting the user navigate through
2943 * them. Apps can fully manage documents within the returned directory.
Jeff Sharkey21de56a2014-04-05 19:05:24 -07002944 * <p>
2945 * To gain access to descendant (child, grandchild, etc) documents, use
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07002946 * {@link DocumentsContract#buildDocumentUriUsingTree(Uri, String)} and
2947 * {@link DocumentsContract#buildChildDocumentsUriUsingTree(Uri, String)}
2948 * with the returned URI.
Jeff Sharkey21de56a2014-04-05 19:05:24 -07002949 * <p>
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07002950 * Output: The URI representing the selected directory tree.
Jeff Sharkey21de56a2014-04-05 19:05:24 -07002951 *
2952 * @see DocumentsContract
2953 */
2954 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07002955 public static final String
2956 ACTION_OPEN_DOCUMENT_TREE = "android.intent.action.OPEN_DOCUMENT_TREE";
Jeff Sharkey21de56a2014-04-05 19:05:24 -07002957
Jeff Sharkey004a4b22014-09-24 11:45:24 -07002958 /** {@hide} */
2959 public static final String ACTION_MASTER_CLEAR = "android.intent.action.MASTER_CLEAR";
2960
Christopher Tate6597e342015-02-17 12:15:25 -08002961 /**
2962 * Broadcast action: report that a settings element is being restored from backup. The intent
2963 * contains three extras: EXTRA_SETTING_NAME is a string naming the restored setting,
2964 * EXTRA_SETTING_NEW_VALUE is the value being restored, and EXTRA_SETTING_PREVIOUS_VALUE
2965 * is the value of that settings entry prior to the restore operation. All of these values are
2966 * represented as strings.
2967 *
2968 * <p>This broadcast is sent only for settings provider entries known to require special handling
2969 * around restore time. These entries are found in the BROADCAST_ON_RESTORE table within
2970 * the provider's backup agent implementation.
2971 *
2972 * @see #EXTRA_SETTING_NAME
2973 * @see #EXTRA_SETTING_PREVIOUS_VALUE
2974 * @see #EXTRA_SETTING_NEW_VALUE
2975 * {@hide}
2976 */
2977 public static final String ACTION_SETTING_RESTORED = "android.os.action.SETTING_RESTORED";
2978
2979 /** {@hide} */
2980 public static final String EXTRA_SETTING_NAME = "setting_name";
2981 /** {@hide} */
2982 public static final String EXTRA_SETTING_PREVIOUS_VALUE = "previous_value";
2983 /** {@hide} */
2984 public static final String EXTRA_SETTING_NEW_VALUE = "new_value";
2985
Clara Bayarri0a26157a2015-03-26 18:38:55 +00002986 /**
2987 * Activity Action: Process a piece of text.
2988 * <p>Input: {@link #EXTRA_PROCESS_TEXT} contains the text to be processed.
2989 * {@link #EXTRA_PROCESS_TEXT_READONLY} states if the resulting text will be read-only.</p>
2990 * <p>Output: {@link #EXTRA_PROCESS_TEXT} contains the processed text.</p>
2991 */
2992 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
2993 public static final String ACTION_PROCESS_TEXT = "android.intent.action.PROCESS_TEXT";
2994 /**
Clara Bayarri92c8e6f2015-05-21 17:50:08 +01002995 * The name of the extra used to define the text to be processed, as a
2996 * CharSequence. Note that this may be a styled CharSequence, so you must use
2997 * {@link Bundle#getCharSequence(String) Bundle.getCharSequence()} to retrieve it.
Clara Bayarri0a26157a2015-03-26 18:38:55 +00002998 */
2999 public static final String EXTRA_PROCESS_TEXT = "android.intent.extra.PROCESS_TEXT";
3000 /**
Clara Bayarri92c8e6f2015-05-21 17:50:08 +01003001 * 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 +00003002 */
3003 public static final String EXTRA_PROCESS_TEXT_READONLY =
3004 "android.intent.extra.PROCESS_TEXT_READONLY";
3005
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003006 // ---------------------------------------------------------------------
3007 // ---------------------------------------------------------------------
3008 // Standard intent categories (see addCategory()).
3009
3010 /**
3011 * Set if the activity should be an option for the default action
3012 * (center press) to perform on a piece of data. Setting this will
3013 * hide from the user any activities without it set when performing an
John Spurlock6098c5d2013-06-17 10:32:46 -04003014 * action on some data. Note that this is normally -not- set in the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003015 * Intent when initiating an action -- it is for use in intent filters
3016 * specified in packages.
3017 */
3018 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3019 public static final String CATEGORY_DEFAULT = "android.intent.category.DEFAULT";
3020 /**
3021 * Activities that can be safely invoked from a browser must support this
3022 * category. For example, if the user is viewing a web page or an e-mail
3023 * and clicks on a link in the text, the Intent generated execute that
3024 * link will require the BROWSABLE category, so that only activities
3025 * supporting this category will be considered as possible actions. By
3026 * supporting this category, you are promising that there is nothing
3027 * damaging (without user intervention) that can happen by invoking any
3028 * matching Intent.
3029 */
3030 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3031 public static final String CATEGORY_BROWSABLE = "android.intent.category.BROWSABLE";
3032 /**
Dianne Hackborn91097de2014-04-04 18:02:06 -07003033 * Categories for activities that can participate in voice interaction.
3034 * An activity that supports this category must be prepared to run with
3035 * no UI shown at all (though in some case it may have a UI shown), and
3036 * rely on {@link android.app.VoiceInteractor} to interact with the user.
3037 */
3038 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3039 public static final String CATEGORY_VOICE = "android.intent.category.VOICE";
3040 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003041 * Set if the activity should be considered as an alternative action to
3042 * the data the user is currently viewing. See also
3043 * {@link #CATEGORY_SELECTED_ALTERNATIVE} for an alternative action that
3044 * applies to the selection in a list of items.
3045 *
3046 * <p>Supporting this category means that you would like your activity to be
3047 * displayed in the set of alternative things the user can do, usually as
3048 * part of the current activity's options menu. You will usually want to
3049 * include a specific label in the &lt;intent-filter&gt; of this action
3050 * describing to the user what it does.
3051 *
3052 * <p>The action of IntentFilter with this category is important in that it
3053 * describes the specific action the target will perform. This generally
3054 * should not be a generic action (such as {@link #ACTION_VIEW}, but rather
3055 * a specific name such as "com.android.camera.action.CROP. Only one
3056 * alternative of any particular action will be shown to the user, so using
3057 * a specific action like this makes sure that your alternative will be
3058 * displayed while also allowing other applications to provide their own
3059 * overrides of that particular action.
3060 */
3061 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3062 public static final String CATEGORY_ALTERNATIVE = "android.intent.category.ALTERNATIVE";
3063 /**
3064 * Set if the activity should be considered as an alternative selection
3065 * action to the data the user has currently selected. This is like
3066 * {@link #CATEGORY_ALTERNATIVE}, but is used in activities showing a list
3067 * of items from which the user can select, giving them alternatives to the
3068 * default action that will be performed on it.
3069 */
3070 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3071 public static final String CATEGORY_SELECTED_ALTERNATIVE = "android.intent.category.SELECTED_ALTERNATIVE";
3072 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09003073 * Intended to be used as a tab inside of a containing TabActivity.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003074 */
3075 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3076 public static final String CATEGORY_TAB = "android.intent.category.TAB";
3077 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003078 * Should be displayed in the top-level launcher.
3079 */
3080 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3081 public static final String CATEGORY_LAUNCHER = "android.intent.category.LAUNCHER";
3082 /**
Jose Lima38b75b62014-03-11 10:41:39 -07003083 * Indicates an activity optimized for Leanback mode, and that should
3084 * be displayed in the Leanback launcher.
3085 */
3086 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3087 public static final String CATEGORY_LEANBACK_LAUNCHER = "android.intent.category.LEANBACK_LAUNCHER";
3088 /**
Jose Lima73915cf2014-07-29 17:16:31 -07003089 * Indicates a Leanback settings activity to be displayed in the Leanback launcher.
3090 * @hide
3091 */
3092 @SystemApi
3093 public static final String CATEGORY_LEANBACK_SETTINGS = "android.intent.category.LEANBACK_SETTINGS";
3094 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003095 * Provides information about the package it is in; typically used if
3096 * a package does not contain a {@link #CATEGORY_LAUNCHER} to provide
3097 * a front-door to the user without having to be shown in the all apps list.
3098 */
3099 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3100 public static final String CATEGORY_INFO = "android.intent.category.INFO";
3101 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003102 * This is the home activity, that is the first activity that is displayed
3103 * when the device boots.
3104 */
3105 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3106 public static final String CATEGORY_HOME = "android.intent.category.HOME";
3107 /**
Svet Ganov50a8bf42015-07-15 11:04:18 -07003108 * This is the setup wizard activity, that is the first activity that is displayed
3109 * when the user sets up the device for the first time.
3110 * @hide
3111 */
3112 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3113 public static final String CATEGORY_SETUP_WIZARD = "android.intent.category.SETUP_WIZARD";
3114 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003115 * This activity is a preference panel.
3116 */
3117 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3118 public static final String CATEGORY_PREFERENCE = "android.intent.category.PREFERENCE";
3119 /**
3120 * This activity is a development preference panel.
3121 */
3122 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3123 public static final String CATEGORY_DEVELOPMENT_PREFERENCE = "android.intent.category.DEVELOPMENT_PREFERENCE";
3124 /**
3125 * Capable of running inside a parent activity container.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003126 */
3127 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3128 public static final String CATEGORY_EMBED = "android.intent.category.EMBED";
3129 /**
Patrick Dubroy6dabe242010-08-30 10:43:47 -07003130 * This activity allows the user to browse and download new applications.
3131 */
3132 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3133 public static final String CATEGORY_APP_MARKET = "android.intent.category.APP_MARKET";
3134 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003135 * This activity may be exercised by the monkey or other automated test tools.
3136 */
3137 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3138 public static final String CATEGORY_MONKEY = "android.intent.category.MONKEY";
3139 /**
3140 * To be used as a test (not part of the normal user experience).
3141 */
3142 public static final String CATEGORY_TEST = "android.intent.category.TEST";
3143 /**
3144 * To be used as a unit test (run through the Test Harness).
3145 */
3146 public static final String CATEGORY_UNIT_TEST = "android.intent.category.UNIT_TEST";
3147 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09003148 * To be used as a sample code example (not part of the normal user
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003149 * experience).
3150 */
3151 public static final String CATEGORY_SAMPLE_CODE = "android.intent.category.SAMPLE_CODE";
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003152
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003153 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003154 * Used to indicate that an intent only wants URIs that can be opened with
3155 * {@link ContentResolver#openFileDescriptor(Uri, String)}. Openable URIs
3156 * must support at least the columns defined in {@link OpenableColumns} when
3157 * queried.
3158 *
3159 * @see #ACTION_GET_CONTENT
3160 * @see #ACTION_OPEN_DOCUMENT
3161 * @see #ACTION_CREATE_DOCUMENT
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003162 */
3163 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3164 public static final String CATEGORY_OPENABLE = "android.intent.category.OPENABLE";
3165
3166 /**
3167 * To be used as code under test for framework instrumentation tests.
3168 */
3169 public static final String CATEGORY_FRAMEWORK_INSTRUMENTATION_TEST =
3170 "android.intent.category.FRAMEWORK_INSTRUMENTATION_TEST";
Mike Lockwood9092ab42009-09-16 13:01:32 -04003171 /**
3172 * An activity to run when device is inserted into a car dock.
Dianne Hackborn7299c412010-03-04 18:41:49 -08003173 * Used with {@link #ACTION_MAIN} to launch an activity. For more
3174 * information, see {@link android.app.UiModeManager}.
Mike Lockwood9092ab42009-09-16 13:01:32 -04003175 */
3176 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3177 public static final String CATEGORY_CAR_DOCK = "android.intent.category.CAR_DOCK";
3178 /**
3179 * An activity to run when device is inserted into a car dock.
Dianne Hackborn7299c412010-03-04 18:41:49 -08003180 * Used with {@link #ACTION_MAIN} to launch an activity. For more
3181 * information, see {@link android.app.UiModeManager}.
Mike Lockwood9092ab42009-09-16 13:01:32 -04003182 */
3183 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3184 public static final String CATEGORY_DESK_DOCK = "android.intent.category.DESK_DOCK";
Praveen Bharathi21e941b2010-10-06 15:23:14 -05003185 /**
3186 * An activity to run when device is inserted into a analog (low end) dock.
3187 * Used with {@link #ACTION_MAIN} to launch an activity. For more
3188 * information, see {@link android.app.UiModeManager}.
3189 */
3190 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3191 public static final String CATEGORY_LE_DESK_DOCK = "android.intent.category.LE_DESK_DOCK";
3192
3193 /**
3194 * An activity to run when device is inserted into a digital (high end) dock.
3195 * Used with {@link #ACTION_MAIN} to launch an activity. For more
3196 * information, see {@link android.app.UiModeManager}.
3197 */
3198 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3199 public static final String CATEGORY_HE_DESK_DOCK = "android.intent.category.HE_DESK_DOCK";
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05003200
Bernd Holzheyaea4b672010-03-31 09:46:13 +02003201 /**
3202 * Used to indicate that the activity can be used in a car environment.
3203 */
3204 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3205 public static final String CATEGORY_CAR_MODE = "android.intent.category.CAR_MODE";
3206
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003207 // ---------------------------------------------------------------------
3208 // ---------------------------------------------------------------------
Jeff Brown6651a632011-11-28 12:59:11 -08003209 // Application launch intent categories (see addCategory()).
3210
3211 /**
3212 * Used with {@link #ACTION_MAIN} to launch the browser application.
3213 * The activity should be able to browse the Internet.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003214 * <p>NOTE: This should not be used as the primary key of an Intent,
3215 * since it will not result in the app launching with the correct
3216 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003217 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003218 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003219 */
3220 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3221 public static final String CATEGORY_APP_BROWSER = "android.intent.category.APP_BROWSER";
3222
3223 /**
3224 * Used with {@link #ACTION_MAIN} to launch the calculator application.
3225 * The activity should be able to perform standard arithmetic operations.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003226 * <p>NOTE: This should not be used as the primary key of an Intent,
3227 * since it will not result in the app launching with the correct
3228 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003229 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003230 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003231 */
3232 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3233 public static final String CATEGORY_APP_CALCULATOR = "android.intent.category.APP_CALCULATOR";
3234
3235 /**
3236 * Used with {@link #ACTION_MAIN} to launch the calendar application.
3237 * The activity should be able to view and manipulate calendar entries.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003238 * <p>NOTE: This should not be used as the primary key of an Intent,
3239 * since it will not result in the app launching with the correct
3240 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003241 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003242 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003243 */
3244 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3245 public static final String CATEGORY_APP_CALENDAR = "android.intent.category.APP_CALENDAR";
3246
3247 /**
3248 * Used with {@link #ACTION_MAIN} to launch the contacts application.
3249 * The activity should be able to view and manipulate address book entries.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003250 * <p>NOTE: This should not be used as the primary key of an Intent,
3251 * since it will not result in the app launching with the correct
3252 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003253 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003254 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003255 */
3256 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3257 public static final String CATEGORY_APP_CONTACTS = "android.intent.category.APP_CONTACTS";
3258
3259 /**
3260 * Used with {@link #ACTION_MAIN} to launch the email application.
3261 * The activity should be able to send and receive email.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003262 * <p>NOTE: This should not be used as the primary key of an Intent,
3263 * since it will not result in the app launching with the correct
3264 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003265 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003266 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003267 */
3268 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3269 public static final String CATEGORY_APP_EMAIL = "android.intent.category.APP_EMAIL";
3270
3271 /**
3272 * Used with {@link #ACTION_MAIN} to launch the gallery application.
3273 * The activity should be able to view and manipulate image and video files
3274 * stored on the device.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003275 * <p>NOTE: This should not be used as the primary key of an Intent,
3276 * since it will not result in the app launching with the correct
3277 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003278 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003279 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003280 */
3281 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3282 public static final String CATEGORY_APP_GALLERY = "android.intent.category.APP_GALLERY";
3283
3284 /**
3285 * Used with {@link #ACTION_MAIN} to launch the maps application.
3286 * The activity should be able to show the user's current location and surroundings.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003287 * <p>NOTE: This should not be used as the primary key of an Intent,
3288 * since it will not result in the app launching with the correct
3289 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003290 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003291 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003292 */
3293 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3294 public static final String CATEGORY_APP_MAPS = "android.intent.category.APP_MAPS";
3295
3296 /**
3297 * Used with {@link #ACTION_MAIN} to launch the messaging application.
3298 * The activity should be able to send and receive text messages.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003299 * <p>NOTE: This should not be used as the primary key of an Intent,
3300 * since it will not result in the app launching with the correct
3301 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003302 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003303 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003304 */
3305 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3306 public static final String CATEGORY_APP_MESSAGING = "android.intent.category.APP_MESSAGING";
3307
3308 /**
3309 * Used with {@link #ACTION_MAIN} to launch the music application.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003310 * The activity should be able to play, browse, or manipulate music files
3311 * stored on the device.
3312 * <p>NOTE: This should not be used as the primary key of an Intent,
3313 * since it will not result in the app launching with the correct
3314 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003315 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003316 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003317 */
3318 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3319 public static final String CATEGORY_APP_MUSIC = "android.intent.category.APP_MUSIC";
3320
3321 // ---------------------------------------------------------------------
3322 // ---------------------------------------------------------------------
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003323 // Standard extra data keys.
3324
3325 /**
3326 * The initial data to place in a newly created record. Use with
3327 * {@link #ACTION_INSERT}. The data here is a Map containing the same
3328 * fields as would be given to the underlying ContentProvider.insert()
3329 * call.
3330 */
3331 public static final String EXTRA_TEMPLATE = "android.intent.extra.TEMPLATE";
3332
3333 /**
3334 * A constant CharSequence that is associated with the Intent, used with
3335 * {@link #ACTION_SEND} to supply the literal data to be sent. Note that
3336 * this may be a styled CharSequence, so you must use
3337 * {@link Bundle#getCharSequence(String) Bundle.getCharSequence()} to
3338 * retrieve it.
3339 */
3340 public static final String EXTRA_TEXT = "android.intent.extra.TEXT";
3341
3342 /**
Dianne Hackbornacb69bb2012-04-13 15:36:06 -07003343 * A constant String that is associated with the Intent, used with
3344 * {@link #ACTION_SEND} to supply an alternative to {@link #EXTRA_TEXT}
3345 * as HTML formatted text. Note that you <em>must</em> also supply
3346 * {@link #EXTRA_TEXT}.
3347 */
3348 public static final String EXTRA_HTML_TEXT = "android.intent.extra.HTML_TEXT";
3349
3350 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003351 * A content: URI holding a stream of data associated with the Intent,
3352 * used with {@link #ACTION_SEND} to supply the data being sent.
3353 */
3354 public static final String EXTRA_STREAM = "android.intent.extra.STREAM";
3355
3356 /**
3357 * A String[] holding e-mail addresses that should be delivered to.
3358 */
3359 public static final String EXTRA_EMAIL = "android.intent.extra.EMAIL";
3360
3361 /**
3362 * A String[] holding e-mail addresses that should be carbon copied.
3363 */
3364 public static final String EXTRA_CC = "android.intent.extra.CC";
3365
3366 /**
3367 * A String[] holding e-mail addresses that should be blind carbon copied.
3368 */
3369 public static final String EXTRA_BCC = "android.intent.extra.BCC";
3370
3371 /**
3372 * A constant string holding the desired subject line of a message.
3373 */
3374 public static final String EXTRA_SUBJECT = "android.intent.extra.SUBJECT";
3375
3376 /**
3377 * An Intent describing the choices you would like shown with
Adam Powell2ed547e2015-04-29 18:45:04 -07003378 * {@link #ACTION_PICK_ACTIVITY} or {@link #ACTION_CHOOSER}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003379 */
3380 public static final String EXTRA_INTENT = "android.intent.extra.INTENT";
3381
3382 /**
Adam Powell2ed547e2015-04-29 18:45:04 -07003383 * An Intent[] describing additional, alternate choices you would like shown with
3384 * {@link #ACTION_CHOOSER}.
3385 *
3386 * <p>An app may be capable of providing several different payload types to complete a
3387 * user's intended action. For example, an app invoking {@link #ACTION_SEND} to share photos
3388 * with another app may use EXTRA_ALTERNATE_INTENTS to have the chooser transparently offer
3389 * several different supported sending mechanisms for sharing, such as the actual "image/*"
3390 * photo data or a hosted link where the photos can be viewed.</p>
3391 *
3392 * <p>The intent present in {@link #EXTRA_INTENT} will be treated as the
3393 * first/primary/preferred intent in the set. Additional intents specified in
3394 * this extra are ordered; by default intents that appear earlier in the array will be
3395 * preferred over intents that appear later in the array as matches for the same
3396 * target component. To alter this preference, a calling app may also supply
3397 * {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER}.</p>
3398 */
3399 public static final String EXTRA_ALTERNATE_INTENTS = "android.intent.extra.ALTERNATE_INTENTS";
3400
3401 /**
3402 * An {@link IntentSender} for an Activity that will be invoked when the user makes a selection
3403 * from the chooser activity presented by {@link #ACTION_CHOOSER}.
3404 *
3405 * <p>An app preparing an action for another app to complete may wish to allow the user to
3406 * disambiguate between several options for completing the action based on the chosen target
3407 * or otherwise refine the action before it is invoked.
3408 * </p>
3409 *
3410 * <p>When sent, this IntentSender may be filled in with the following extras:</p>
3411 * <ul>
3412 * <li>{@link #EXTRA_INTENT} The first intent that matched the user's chosen target</li>
3413 * <li>{@link #EXTRA_ALTERNATE_INTENTS} Any additional intents that also matched the user's
3414 * chosen target beyond the first</li>
3415 * <li>{@link #EXTRA_RESULT_RECEIVER} A {@link ResultReceiver} that the refinement activity
3416 * should fill in and send once the disambiguation is complete</li>
3417 * </ul>
3418 */
3419 public static final String EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER
3420 = "android.intent.extra.CHOOSER_REFINEMENT_INTENT_SENDER";
3421
3422 /**
3423 * A {@link ResultReceiver} used to return data back to the sender.
3424 *
3425 * <p>Used to complete an app-specific
3426 * {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER refinement} for {@link #ACTION_CHOOSER}.</p>
3427 *
3428 * <p>If {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER} is present in the intent
3429 * used to start a {@link #ACTION_CHOOSER} activity this extra will be
3430 * {@link #fillIn(Intent, int) filled in} to that {@link IntentSender} and sent
3431 * when the user selects a target component from the chooser. It is up to the recipient
3432 * to send a result to this ResultReceiver to signal that disambiguation is complete
3433 * and that the chooser should invoke the user's choice.</p>
3434 *
3435 * <p>The disambiguator should provide a Bundle to the ResultReceiver with an intent
3436 * assigned to the key {@link #EXTRA_INTENT}. This supplied intent will be used by the chooser
3437 * to match and fill in the final Intent or ChooserTarget before starting it.
3438 * The supplied intent must {@link #filterEquals(Intent) match} one of the intents from
3439 * {@link #EXTRA_INTENT} or {@link #EXTRA_ALTERNATE_INTENTS} passed to
3440 * {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER} to be accepted.</p>
3441 *
3442 * <p>The result code passed to the ResultReceiver should be
3443 * {@link android.app.Activity#RESULT_OK} if the refinement succeeded and the supplied intent's
3444 * target in the chooser should be started, or {@link android.app.Activity#RESULT_CANCELED} if
3445 * the chooser should finish without starting a target.</p>
3446 */
3447 public static final String EXTRA_RESULT_RECEIVER
3448 = "android.intent.extra.RESULT_RECEIVER";
3449
3450 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003451 * A CharSequence dialog title to provide to the user when used with a
Jim Miller4d64746d2014-08-13 21:08:41 +00003452 * {@link #ACTION_CHOOSER}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003453 */
3454 public static final String EXTRA_TITLE = "android.intent.extra.TITLE";
3455
3456 /**
Dianne Hackborneb034652009-09-07 00:49:58 -07003457 * A Parcelable[] of {@link Intent} or
3458 * {@link android.content.pm.LabeledIntent} objects as set with
3459 * {@link #putExtra(String, Parcelable[])} of additional activities to place
3460 * a the front of the list of choices, when shown to the user with a
3461 * {@link #ACTION_CHOOSER}.
3462 */
3463 public static final String EXTRA_INITIAL_INTENTS = "android.intent.extra.INITIAL_INTENTS";
3464
3465 /**
Adam Powelle49d9392014-07-17 18:45:19 -07003466 * A Bundle forming a mapping of potential target package names to different extras Bundles
3467 * to add to the default intent extras in {@link #EXTRA_INTENT} when used with
3468 * {@link #ACTION_CHOOSER}. Each key should be a package name. The package need not
3469 * be currently installed on the device.
3470 *
3471 * <p>An application may choose to provide alternate extras for the case where a user
3472 * selects an activity from a predetermined set of target packages. If the activity
3473 * the user selects from the chooser belongs to a package with its package name as
3474 * a key in this bundle, the corresponding extras for that package will be merged with
3475 * the extras already present in the intent at {@link #EXTRA_INTENT}. If a replacement
3476 * extra has the same key as an extra already present in the intent it will overwrite
3477 * the extra from the intent.</p>
3478 *
3479 * <p><em>Examples:</em>
3480 * <ul>
3481 * <li>An application may offer different {@link #EXTRA_TEXT} to an application
3482 * when sharing with it via {@link #ACTION_SEND}, augmenting a link with additional query
3483 * parameters for that target.</li>
3484 * <li>An application may offer additional metadata for known targets of a given intent
3485 * to pass along information only relevant to that target such as account or content
3486 * identifiers already known to that application.</li>
3487 * </ul></p>
3488 */
3489 public static final String EXTRA_REPLACEMENT_EXTRAS =
3490 "android.intent.extra.REPLACEMENT_EXTRAS";
3491
3492 /**
Adam Powell0b3c1122014-10-09 12:50:14 -07003493 * An {@link IntentSender} that will be notified if a user successfully chooses a target
3494 * component to handle an action in an {@link #ACTION_CHOOSER} activity. The IntentSender
3495 * will have the extra {@link #EXTRA_CHOSEN_COMPONENT} appended to it containing the
3496 * {@link ComponentName} of the chosen component.
3497 *
3498 * <p>In some situations this callback may never come, for example if the user abandons
3499 * the chooser, switches to another task or any number of other reasons. Apps should not
3500 * be written assuming that this callback will always occur.</p>
3501 */
3502 public static final String EXTRA_CHOSEN_COMPONENT_INTENT_SENDER =
3503 "android.intent.extra.CHOSEN_COMPONENT_INTENT_SENDER";
3504
3505 /**
3506 * The {@link ComponentName} chosen by the user to complete an action.
3507 *
3508 * @see #EXTRA_CHOSEN_COMPONENT_INTENT_SENDER
3509 */
3510 public static final String EXTRA_CHOSEN_COMPONENT = "android.intent.extra.CHOSEN_COMPONENT";
3511
3512 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003513 * A {@link android.view.KeyEvent} object containing the event that
3514 * triggered the creation of the Intent it is in.
3515 */
3516 public static final String EXTRA_KEY_EVENT = "android.intent.extra.KEY_EVENT";
3517
3518 /**
Mike Lockwoodbad80e02009-07-30 01:21:08 -07003519 * Set to true in {@link #ACTION_REQUEST_SHUTDOWN} to request confirmation from the user
3520 * before shutting down.
3521 *
3522 * {@hide}
3523 */
3524 public static final String EXTRA_KEY_CONFIRM = "android.intent.extra.KEY_CONFIRM";
3525
3526 /**
Yusuke Sato705ffd12015-07-21 15:52:11 -07003527 * Set to true in {@link #ACTION_REQUEST_SHUTDOWN} to indicate that the shutdown is
3528 * requested by the user.
3529 *
3530 * {@hide}
3531 */
3532 public static final String EXTRA_USER_REQUESTED_SHUTDOWN =
3533 "android.intent.extra.USER_REQUESTED_SHUTDOWN";
3534
3535 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09003536 * 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 -07003537 * {@link android.content.Intent#ACTION_PACKAGE_CHANGED} intents to override the default action
3538 * of restarting the application.
3539 */
3540 public static final String EXTRA_DONT_KILL_APP = "android.intent.extra.DONT_KILL_APP";
3541
3542 /**
3543 * A String holding the phone number originally entered in
3544 * {@link android.content.Intent#ACTION_NEW_OUTGOING_CALL}, or the actual
3545 * number to call in a {@link android.content.Intent#ACTION_CALL}.
3546 */
3547 public static final String EXTRA_PHONE_NUMBER = "android.intent.extra.PHONE_NUMBER";
Bernd Holzheyaea4b672010-03-31 09:46:13 +02003548
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003549 /**
3550 * Used as an int extra field in {@link android.content.Intent#ACTION_UID_REMOVED}
3551 * intents to supply the uid the package had been assigned. Also an optional
3552 * extra in {@link android.content.Intent#ACTION_PACKAGE_REMOVED} or
3553 * {@link android.content.Intent#ACTION_PACKAGE_CHANGED} for the same
3554 * purpose.
3555 */
3556 public static final String EXTRA_UID = "android.intent.extra.UID";
3557
3558 /**
Dianne Hackborn21f1bd12010-02-19 17:02:21 -08003559 * @hide String array of package names.
3560 */
Soonil Nagarkar0e8fd092015-02-10 10:37:36 -08003561 @SystemApi
Dianne Hackborn21f1bd12010-02-19 17:02:21 -08003562 public static final String EXTRA_PACKAGES = "android.intent.extra.PACKAGES";
3563
3564 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003565 * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED}
3566 * intents to indicate whether this represents a full uninstall (removing
3567 * both the code and its data) or a partial uninstall (leaving its data,
3568 * implying that this is an update).
3569 */
3570 public static final String EXTRA_DATA_REMOVED = "android.intent.extra.DATA_REMOVED";
The Android Open Source Project10592532009-03-18 17:39:46 -07003571
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003572 /**
Dianne Hackbornc72fc672012-09-20 13:12:03 -07003573 * @hide
3574 * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED}
3575 * intents to indicate that at this point the package has been removed for
3576 * all users on the device.
3577 */
3578 public static final String EXTRA_REMOVED_FOR_ALL_USERS
3579 = "android.intent.extra.REMOVED_FOR_ALL_USERS";
3580
3581 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003582 * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED}
3583 * intents to indicate that this is a replacement of the package, so this
3584 * broadcast will immediately be followed by an add broadcast for a
3585 * different version of the same package.
3586 */
3587 public static final String EXTRA_REPLACING = "android.intent.extra.REPLACING";
The Android Open Source Project10592532009-03-18 17:39:46 -07003588
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003589 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003590 * Used as an int extra field in {@link android.app.AlarmManager} intents
3591 * to tell the application being invoked how many pending alarms are being
3592 * delievered with the intent. For one-shot alarms this will always be 1.
3593 * For recurring alarms, this might be greater than 1 if the device was
3594 * asleep or powered off at the time an earlier alarm would have been
3595 * delivered.
3596 */
3597 public static final String EXTRA_ALARM_COUNT = "android.intent.extra.ALARM_COUNT";
Romain Guy4969af72009-06-17 10:53:19 -07003598
Jacek Surazski86b6c532009-05-13 14:38:28 +02003599 /**
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05003600 * Used as an int extra field in {@link android.content.Intent#ACTION_DOCK_EVENT}
3601 * intents to request the dock state. Possible values are
Mike Lockwood725fcbf2009-08-24 13:09:20 -07003602 * {@link android.content.Intent#EXTRA_DOCK_STATE_UNDOCKED},
3603 * {@link android.content.Intent#EXTRA_DOCK_STATE_DESK}, or
Praveen Bharathi21e941b2010-10-06 15:23:14 -05003604 * {@link android.content.Intent#EXTRA_DOCK_STATE_CAR}, or
3605 * {@link android.content.Intent#EXTRA_DOCK_STATE_LE_DESK}, or
3606 * {@link android.content.Intent#EXTRA_DOCK_STATE_HE_DESK}.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05003607 */
3608 public static final String EXTRA_DOCK_STATE = "android.intent.extra.DOCK_STATE";
3609
3610 /**
3611 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
3612 * to represent that the phone is not in any dock.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05003613 */
3614 public static final int EXTRA_DOCK_STATE_UNDOCKED = 0;
3615
3616 /**
3617 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
3618 * to represent that the phone is in a desk dock.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05003619 */
3620 public static final int EXTRA_DOCK_STATE_DESK = 1;
3621
3622 /**
3623 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
3624 * to represent that the phone is in a car dock.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05003625 */
3626 public static final int EXTRA_DOCK_STATE_CAR = 2;
3627
3628 /**
Praveen Bharathi21e941b2010-10-06 15:23:14 -05003629 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
3630 * to represent that the phone is in a analog (low end) dock.
3631 */
3632 public static final int EXTRA_DOCK_STATE_LE_DESK = 3;
3633
3634 /**
3635 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
3636 * to represent that the phone is in a digital (high end) dock.
3637 */
3638 public static final int EXTRA_DOCK_STATE_HE_DESK = 4;
3639
3640 /**
Dianne Hackborn9bfb7072009-09-22 11:37:40 -07003641 * Boolean that can be supplied as meta-data with a dock activity, to
3642 * indicate that the dock should take over the home key when it is active.
3643 */
3644 public static final String METADATA_DOCK_HOME = "android.dock_home";
Tom Taylord4a47292009-12-21 13:59:18 -08003645
Dianne Hackborn9bfb7072009-09-22 11:37:40 -07003646 /**
Jacek Surazski86b6c532009-05-13 14:38:28 +02003647 * Used as a parcelable extra field in {@link #ACTION_APP_ERROR}, containing
3648 * the bug report.
Jacek Surazski86b6c532009-05-13 14:38:28 +02003649 */
3650 public static final String EXTRA_BUG_REPORT = "android.intent.extra.BUG_REPORT";
3651
3652 /**
Wei Huang97ecc9c2009-05-11 17:44:20 -07003653 * Used in the extra field in the remote intent. It's astring token passed with the
3654 * remote intent.
3655 */
3656 public static final String EXTRA_REMOTE_INTENT_TOKEN =
3657 "android.intent.extra.remote_intent_token";
3658
Suchi Amalapurapu0214e942009-09-02 11:03:18 -07003659 /**
Dianne Hackborn1d62ea92009-11-17 12:49:50 -08003660 * @deprecated See {@link #EXTRA_CHANGED_COMPONENT_NAME_LIST}; this field
Dianne Hackborn86a72da2009-11-11 20:12:41 -08003661 * will contain only the first name in the list.
Suchi Amalapurapu0214e942009-09-02 11:03:18 -07003662 */
Dianne Hackborn1d62ea92009-11-17 12:49:50 -08003663 @Deprecated public static final String EXTRA_CHANGED_COMPONENT_NAME =
Suchi Amalapurapu0214e942009-09-02 11:03:18 -07003664 "android.intent.extra.changed_component_name";
3665
Dianne Hackborndd9b82c2009-09-03 00:18:47 -07003666 /**
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08003667 * This field is part of {@link android.content.Intent#ACTION_PACKAGE_CHANGED},
Dianne Hackbornfd7aded2013-01-22 17:10:23 -08003668 * and contains a string array of all of the components that have changed. If
3669 * the state of the overall package has changed, then it will contain an entry
3670 * with the package name itself.
Dianne Hackborn86a72da2009-11-11 20:12:41 -08003671 */
3672 public static final String EXTRA_CHANGED_COMPONENT_NAME_LIST =
3673 "android.intent.extra.changed_component_name_list";
3674
3675 /**
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08003676 * This field is part of
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08003677 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_AVAILABLE},
3678 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE}
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08003679 * and contains a string array of all of the components that have changed.
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08003680 */
3681 public static final String EXTRA_CHANGED_PACKAGE_LIST =
3682 "android.intent.extra.changed_package_list";
3683
3684 /**
3685 * This field is part of
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08003686 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_AVAILABLE},
3687 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE}
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08003688 * and contains an integer array of uids of all of the components
3689 * that have changed.
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08003690 */
3691 public static final String EXTRA_CHANGED_UID_LIST =
3692 "android.intent.extra.changed_uid_list";
3693
3694 /**
Dianne Hackborndd9b82c2009-09-03 00:18:47 -07003695 * @hide
3696 * Magic extra system code can use when binding, to give a label for
3697 * who it is that has bound to a service. This is an integer giving
3698 * a framework string resource that can be displayed to the user.
3699 */
3700 public static final String EXTRA_CLIENT_LABEL =
3701 "android.intent.extra.client_label";
3702
3703 /**
3704 * @hide
3705 * Magic extra system code can use when binding, to give a PendingIntent object
3706 * that can be launched for the user to disable the system's use of this
3707 * service.
3708 */
3709 public static final String EXTRA_CLIENT_INTENT =
3710 "android.intent.extra.client_intent";
3711
Dianne Hackbornc4d0e6f2011-01-25 14:55:06 -08003712 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003713 * Extra used to indicate that an intent should only return data that is on
3714 * the local device. This is a boolean extra; the default is false. If true,
3715 * an implementation should only allow the user to select data that is
3716 * already on the device, not requiring it be downloaded from a remote
3717 * service when opened.
3718 *
3719 * @see #ACTION_GET_CONTENT
3720 * @see #ACTION_OPEN_DOCUMENT
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003721 * @see #ACTION_OPEN_DOCUMENT_TREE
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003722 * @see #ACTION_CREATE_DOCUMENT
Dianne Hackbornc4d0e6f2011-01-25 14:55:06 -08003723 */
3724 public static final String EXTRA_LOCAL_ONLY =
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003725 "android.intent.extra.LOCAL_ONLY";
Daniel Lehmanna5b58df2011-10-12 16:24:22 -07003726
Amith Yamasani13593602012-03-22 16:16:17 -07003727 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003728 * Extra used to indicate that an intent can allow the user to select and
3729 * return multiple items. This is a boolean extra; the default is false. If
3730 * true, an implementation is allowed to present the user with a UI where
3731 * they can pick multiple items that are all returned to the caller. When
3732 * this happens, they should be returned as the {@link #getClipData()} part
3733 * of the result Intent.
3734 *
3735 * @see #ACTION_GET_CONTENT
3736 * @see #ACTION_OPEN_DOCUMENT
Dianne Hackbornfdb3f092013-01-28 15:10:48 -08003737 */
3738 public static final String EXTRA_ALLOW_MULTIPLE =
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003739 "android.intent.extra.ALLOW_MULTIPLE";
Dianne Hackbornfdb3f092013-01-28 15:10:48 -08003740
3741 /**
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01003742 * The integer userHandle carried with broadcast intents related to addition, removal and
3743 * switching of users and managed profiles - {@link #ACTION_USER_ADDED},
3744 * {@link #ACTION_USER_REMOVED} and {@link #ACTION_USER_SWITCHED}.
3745 *
Amith Yamasani13593602012-03-22 16:16:17 -07003746 * @hide
3747 */
Amith Yamasani2a003292012-08-14 18:25:45 -07003748 public static final String EXTRA_USER_HANDLE =
3749 "android.intent.extra.user_handle";
Jean-Michel Trivi3114ce32012-06-11 15:03:52 -07003750
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08003751 /**
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01003752 * The UserHandle carried with broadcasts intents related to addition and removal of managed
3753 * profiles - {@link #ACTION_MANAGED_PROFILE_ADDED} and {@link #ACTION_MANAGED_PROFILE_REMOVED}.
3754 */
3755 public static final String EXTRA_USER =
Alexandra Gherghina3315f6b2014-09-05 15:48:06 +01003756 "android.intent.extra.USER";
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01003757
3758 /**
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08003759 * Extra used in the response from a BroadcastReceiver that handles
Amith Yamasani7e99bc02013-04-16 18:24:51 -07003760 * {@link #ACTION_GET_RESTRICTION_ENTRIES}. The type of the extra is
3761 * <code>ArrayList&lt;RestrictionEntry&gt;</code>.
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08003762 */
Amith Yamasani7e99bc02013-04-16 18:24:51 -07003763 public static final String EXTRA_RESTRICTIONS_LIST = "android.intent.extra.restrictions_list";
3764
3765 /**
3766 * Extra sent in the intent to the BroadcastReceiver that handles
3767 * {@link #ACTION_GET_RESTRICTION_ENTRIES}. The type of the extra is a Bundle containing
3768 * the restrictions as key/value pairs.
3769 */
3770 public static final String EXTRA_RESTRICTIONS_BUNDLE =
3771 "android.intent.extra.restrictions_bundle";
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08003772
Amith Yamasani86118ba2013-03-28 14:33:16 -07003773 /**
3774 * Extra used in the response from a BroadcastReceiver that handles
3775 * {@link #ACTION_GET_RESTRICTION_ENTRIES}.
3776 */
3777 public static final String EXTRA_RESTRICTIONS_INTENT =
3778 "android.intent.extra.restrictions_intent";
3779
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003780 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003781 * Extra used to communicate a set of acceptable MIME types. The type of the
3782 * extra is {@code String[]}. Values may be a combination of concrete MIME
3783 * types (such as "image/png") and/or partial MIME types (such as
3784 * "audio/*").
3785 *
3786 * @see #ACTION_GET_CONTENT
3787 * @see #ACTION_OPEN_DOCUMENT
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003788 */
3789 public static final String EXTRA_MIME_TYPES = "android.intent.extra.MIME_TYPES";
3790
Dianne Hackborn57a7f592013-07-22 18:21:32 -07003791 /**
3792 * Optional extra for {@link #ACTION_SHUTDOWN} that allows the sender to qualify that
3793 * this shutdown is only for the user space of the system, not a complete shutdown.
Dianne Hackbornd318e0b2013-09-03 14:34:12 -07003794 * When this is true, hardware devices can use this information to determine that
3795 * they shouldn't do a complete shutdown of their device since this is not a
3796 * complete shutdown down to the kernel, but only user space restarting.
3797 * The default if not supplied is false.
Dianne Hackborn57a7f592013-07-22 18:21:32 -07003798 */
3799 public static final String EXTRA_SHUTDOWN_USERSPACE_ONLY
3800 = "android.intent.extra.SHUTDOWN_USERSPACE_ONLY";
3801
Narayan Kamathccb2a0862013-12-19 14:49:36 +00003802 /**
3803 * Optional boolean extra for {@link #ACTION_TIME_CHANGED} that indicates the
3804 * user has set their time format preferences to the 24 hour format.
3805 *
3806 * @hide for internal use only.
3807 */
3808 public static final String EXTRA_TIME_PREF_24_HOUR_FORMAT =
3809 "android.intent.extra.TIME_PREF_24_HOUR_FORMAT";
3810
Jeff Sharkey004a4b22014-09-24 11:45:24 -07003811 /** {@hide} */
3812 public static final String EXTRA_REASON = "android.intent.extra.REASON";
3813
Rubin Xue8490f12015-06-25 12:17:48 +01003814 /** {@hide} */
3815 public static final String EXTRA_WIPE_EXTERNAL_STORAGE = "android.intent.extra.WIPE_EXTERNAL_STORAGE";
3816
Santos Cordon15a13782015-03-31 18:32:31 -07003817 /**
3818 * Optional {@link android.app.PendingIntent} extra used to deliver the result of the SIM
3819 * activation request.
3820 * TODO: Add information about the structure and response data used with the pending intent.
3821 * @hide
3822 */
3823 public static final String EXTRA_SIM_ACTIVATION_RESPONSE =
3824 "android.intent.extra.SIM_ACTIVATION_RESPONSE";
3825
Steve McKay6eaf38632015-08-04 10:11:01 -07003826 /** {@hide} */
3827 public static final String EXTRA_INDEX = "android.intent.extra.INDEX";
3828
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003829 // ---------------------------------------------------------------------
3830 // ---------------------------------------------------------------------
3831 // Intent flags (see mFlags variable).
3832
Tor Norbyed9273d62013-05-30 15:59:53 -07003833 /** @hide */
Jeff Sharkey846318a2014-04-04 12:12:41 -07003834 @IntDef(flag = true, value = {
3835 FLAG_GRANT_READ_URI_PERMISSION, FLAG_GRANT_WRITE_URI_PERMISSION,
3836 FLAG_GRANT_PERSISTABLE_URI_PERMISSION, FLAG_GRANT_PREFIX_URI_PERMISSION })
Tor Norbyed9273d62013-05-30 15:59:53 -07003837 @Retention(RetentionPolicy.SOURCE)
3838 public @interface GrantUriMode {}
3839
Jeff Sharkey846318a2014-04-04 12:12:41 -07003840 /** @hide */
3841 @IntDef(flag = true, value = {
3842 FLAG_GRANT_READ_URI_PERMISSION, FLAG_GRANT_WRITE_URI_PERMISSION })
3843 @Retention(RetentionPolicy.SOURCE)
3844 public @interface AccessUriMode {}
3845
3846 /**
3847 * Test if given mode flags specify an access mode, which must be at least
3848 * read and/or write.
3849 *
3850 * @hide
3851 */
3852 public static boolean isAccessUriMode(int modeFlags) {
3853 return (modeFlags & (Intent.FLAG_GRANT_READ_URI_PERMISSION
3854 | Intent.FLAG_GRANT_WRITE_URI_PERMISSION)) != 0;
3855 }
3856
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003857 /**
3858 * If set, the recipient of this Intent will be granted permission to
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003859 * perform read operations on the URI in the Intent's data and any URIs
Dianne Hackborn21c241e2012-03-08 13:57:23 -08003860 * specified in its ClipData. When applying to an Intent's ClipData,
3861 * all URIs as well as recursive traversals through data or other ClipData
3862 * in Intent items will be granted; only the grant flags of the top-level
3863 * Intent are used.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003864 */
3865 public static final int FLAG_GRANT_READ_URI_PERMISSION = 0x00000001;
3866 /**
3867 * If set, the recipient of this Intent will be granted permission to
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003868 * perform write operations on the URI in the Intent's data and any URIs
Dianne Hackborn21c241e2012-03-08 13:57:23 -08003869 * specified in its ClipData. When applying to an Intent's ClipData,
3870 * all URIs as well as recursive traversals through data or other ClipData
3871 * in Intent items will be granted; only the grant flags of the top-level
3872 * Intent are used.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003873 */
3874 public static final int FLAG_GRANT_WRITE_URI_PERMISSION = 0x00000002;
3875 /**
3876 * Can be set by the caller to indicate that this Intent is coming from
3877 * a background operation, not from direct user interaction.
3878 */
3879 public static final int FLAG_FROM_BACKGROUND = 0x00000004;
3880 /**
3881 * A flag you can enable for debugging: when set, log messages will be
3882 * printed during the resolution of this intent to show you what has
3883 * been found to create the final resolved list.
3884 */
3885 public static final int FLAG_DEBUG_LOG_RESOLUTION = 0x00000008;
Dianne Hackborne7f97212011-02-24 14:40:20 -08003886 /**
3887 * If set, this intent will not match any components in packages that
3888 * are currently stopped. If this is not set, then the default behavior
3889 * is to include such applications in the result.
3890 */
3891 public static final int FLAG_EXCLUDE_STOPPED_PACKAGES = 0x00000010;
3892 /**
3893 * If set, this intent will always match any components in packages that
3894 * are currently stopped. This is the default behavior when
3895 * {@link #FLAG_EXCLUDE_STOPPED_PACKAGES} is not set. If both of these
3896 * flags are set, this one wins (it allows overriding of exclude for
3897 * places where the framework may automatically set the exclude flag).
3898 */
3899 public static final int FLAG_INCLUDE_STOPPED_PACKAGES = 0x00000020;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003900
3901 /**
Jeff Sharkey328ebf22013-03-21 18:09:39 -07003902 * When combined with {@link #FLAG_GRANT_READ_URI_PERMISSION} and/or
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003903 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, the URI permission grant can be
Jeff Sharkeye66c1772013-09-20 14:30:59 -07003904 * persisted across device reboots until explicitly revoked with
3905 * {@link Context#revokeUriPermission(Uri, int)}. This flag only offers the
3906 * grant for possible persisting; the receiving application must call
3907 * {@link ContentResolver#takePersistableUriPermission(Uri, int)} to
3908 * actually persist.
3909 *
3910 * @see ContentResolver#takePersistableUriPermission(Uri, int)
3911 * @see ContentResolver#releasePersistableUriPermission(Uri, int)
3912 * @see ContentResolver#getPersistedUriPermissions()
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003913 * @see ContentResolver#getOutgoingPersistedUriPermissions()
Jeff Sharkey328ebf22013-03-21 18:09:39 -07003914 */
Jeff Sharkeye66c1772013-09-20 14:30:59 -07003915 public static final int FLAG_GRANT_PERSISTABLE_URI_PERMISSION = 0x00000040;
Jeff Sharkey328ebf22013-03-21 18:09:39 -07003916
3917 /**
Jeff Sharkey846318a2014-04-04 12:12:41 -07003918 * When combined with {@link #FLAG_GRANT_READ_URI_PERMISSION} and/or
3919 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, the URI permission grant
3920 * applies to any URI that is a prefix match against the original granted
3921 * URI. (Without this flag, the URI must match exactly for access to be
3922 * granted.) Another URI is considered a prefix match only when scheme,
3923 * authority, and all path segments defined by the prefix are an exact
3924 * match.
3925 */
3926 public static final int FLAG_GRANT_PREFIX_URI_PERMISSION = 0x00000080;
3927
3928 /**
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08003929 * If set, the new activity is not kept in the history stack. As soon as
3930 * the user navigates away from it, the activity is finished. This may also
3931 * be set with the {@link android.R.styleable#AndroidManifestActivity_noHistory
3932 * noHistory} attribute.
Ricardo Cervera92f6a742014-04-04 11:17:06 -07003933 *
3934 * <p>If set, {@link android.app.Activity#onActivityResult onActivityResult()}
3935 * is never invoked when the current activity starts a new activity which
3936 * sets a result and finishes.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003937 */
3938 public static final int FLAG_ACTIVITY_NO_HISTORY = 0x40000000;
3939 /**
3940 * If set, the activity will not be launched if it is already running
3941 * at the top of the history stack.
3942 */
3943 public static final int FLAG_ACTIVITY_SINGLE_TOP = 0x20000000;
3944 /**
3945 * If set, this activity will become the start of a new task on this
3946 * history stack. A task (from the activity that started it to the
3947 * next task activity) defines an atomic group of activities that the
3948 * user can move to. Tasks can be moved to the foreground and background;
3949 * all of the activities inside of a particular task always remain in
The Android Open Source Project10592532009-03-18 17:39:46 -07003950 * the same order. See
Scott Main7aee61f2011-02-08 11:25:01 -08003951 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
3952 * Stack</a> for more information about tasks.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003953 *
3954 * <p>This flag is generally used by activities that want
3955 * to present a "launcher" style behavior: they give the user a list of
3956 * separate things that can be done, which otherwise run completely
3957 * independently of the activity launching them.
3958 *
3959 * <p>When using this flag, if a task is already running for the activity
3960 * you are now starting, then a new activity will not be started; instead,
3961 * the current task will simply be brought to the front of the screen with
3962 * the state it was last in. See {@link #FLAG_ACTIVITY_MULTIPLE_TASK} for a flag
3963 * to disable this behavior.
3964 *
3965 * <p>This flag can not be used when the caller is requesting a result from
3966 * the activity being launched.
3967 */
3968 public static final int FLAG_ACTIVITY_NEW_TASK = 0x10000000;
3969 /**
Craig Mautnerd00f4742014-03-12 14:17:26 -07003970 * This flag is used to create a new task and launch an activity into it.
3971 * This flag is always paired with either {@link #FLAG_ACTIVITY_NEW_DOCUMENT}
3972 * or {@link #FLAG_ACTIVITY_NEW_TASK}. In both cases these flags alone would
3973 * search through existing tasks for ones matching this Intent. Only if no such
3974 * task is found would a new task be created. When paired with
3975 * FLAG_ACTIVITY_MULTIPLE_TASK both of these behaviors are modified to skip
3976 * the search for a matching task and unconditionally start a new task.
3977 *
3978 * <strong>When used with {@link #FLAG_ACTIVITY_NEW_TASK} do not use this
3979 * flag unless you are implementing your own
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003980 * top-level application launcher.</strong> Used in conjunction with
3981 * {@link #FLAG_ACTIVITY_NEW_TASK} to disable the
3982 * behavior of bringing an existing task to the foreground. When set,
3983 * a new task is <em>always</em> started to host the Activity for the
3984 * Intent, regardless of whether there is already an existing task running
3985 * the same thing.
3986 *
3987 * <p><strong>Because the default system does not include graphical task management,
3988 * you should not use this flag unless you provide some way for a user to
3989 * return back to the tasks you have launched.</strong>
The Android Open Source Project10592532009-03-18 17:39:46 -07003990 *
Craig Mautnerd00f4742014-03-12 14:17:26 -07003991 * See {@link #FLAG_ACTIVITY_NEW_DOCUMENT} for details of this flag's use for
3992 * creating new document tasks.
3993 *
3994 * <p>This flag is ignored if one of {@link #FLAG_ACTIVITY_NEW_TASK} or
Paul Soulos628cb742014-09-19 11:00:52 -07003995 * {@link #FLAG_ACTIVITY_NEW_DOCUMENT} is not also set.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003996 *
Scott Main7aee61f2011-02-08 11:25:01 -08003997 * <p>See
3998 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
3999 * Stack</a> for more information about tasks.
Craig Mautnerd00f4742014-03-12 14:17:26 -07004000 *
4001 * @see #FLAG_ACTIVITY_NEW_DOCUMENT
4002 * @see #FLAG_ACTIVITY_NEW_TASK
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004003 */
4004 public static final int FLAG_ACTIVITY_MULTIPLE_TASK = 0x08000000;
4005 /**
4006 * If set, and the activity being launched is already running in the
4007 * current task, then instead of launching a new instance of that activity,
4008 * all of the other activities on top of it will be closed and this Intent
4009 * will be delivered to the (now on top) old activity as a new Intent.
4010 *
4011 * <p>For example, consider a task consisting of the activities: A, B, C, D.
4012 * If D calls startActivity() with an Intent that resolves to the component
4013 * of activity B, then C and D will be finished and B receive the given
4014 * Intent, resulting in the stack now being: A, B.
4015 *
Dianne Hackbornaa52f9a2009-08-25 16:01:15 -07004016 * <p>The currently running instance of activity B in the above example will
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004017 * either receive the new intent you are starting here in its
4018 * onNewIntent() method, or be itself finished and restarted with the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004019 * new intent. If it has declared its launch mode to be "multiple" (the
Dianne Hackbornaa52f9a2009-08-25 16:01:15 -07004020 * default) and you have not set {@link #FLAG_ACTIVITY_SINGLE_TOP} in
4021 * the same intent, then it will be finished and re-created; for all other
4022 * launch modes or if {@link #FLAG_ACTIVITY_SINGLE_TOP} is set then this
4023 * Intent will be delivered to the current instance's onNewIntent().
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004024 *
4025 * <p>This launch mode can also be used to good effect in conjunction with
4026 * {@link #FLAG_ACTIVITY_NEW_TASK}: if used to start the root activity
4027 * of a task, it will bring any currently running instance of that task
4028 * to the foreground, and then clear it to its root state. This is
4029 * especially useful, for example, when launching an activity from the
4030 * notification manager.
4031 *
Scott Main7aee61f2011-02-08 11:25:01 -08004032 * <p>See
4033 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
4034 * Stack</a> for more information about tasks.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004035 */
4036 public static final int FLAG_ACTIVITY_CLEAR_TOP = 0x04000000;
4037 /**
4038 * If set and this intent is being used to launch a new activity from an
4039 * existing one, then the reply target of the existing activity will be
4040 * transfered to the new activity. This way the new activity can call
4041 * {@link android.app.Activity#setResult} and have that result sent back to
4042 * the reply target of the original activity.
4043 */
4044 public static final int FLAG_ACTIVITY_FORWARD_RESULT = 0x02000000;
4045 /**
4046 * If set and this intent is being used to launch a new activity from an
4047 * existing one, the current activity will not be counted as the top
4048 * activity for deciding whether the new intent should be delivered to
4049 * the top instead of starting a new one. The previous activity will
4050 * be used as the top, with the assumption being that the current activity
4051 * will finish itself immediately.
4052 */
4053 public static final int FLAG_ACTIVITY_PREVIOUS_IS_TOP = 0x01000000;
4054 /**
4055 * If set, the new activity is not kept in the list of recently launched
4056 * activities.
4057 */
4058 public static final int FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS = 0x00800000;
4059 /**
4060 * This flag is not normally set by application code, but set for you by
4061 * the system as described in the
4062 * {@link android.R.styleable#AndroidManifestActivity_launchMode
4063 * launchMode} documentation for the singleTask mode.
4064 */
4065 public static final int FLAG_ACTIVITY_BROUGHT_TO_FRONT = 0x00400000;
4066 /**
4067 * If set, and this activity is either being started in a new task or
4068 * bringing to the top an existing task, then it will be launched as
4069 * the front door of the task. This will result in the application of
4070 * any affinities needed to have that task in the proper state (either
4071 * moving activities to or from it), or simply resetting that task to
4072 * its initial state if needed.
4073 */
4074 public static final int FLAG_ACTIVITY_RESET_TASK_IF_NEEDED = 0x00200000;
4075 /**
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08004076 * This flag is not normally set by application code, but set for you by
4077 * the system if this activity is being launched from history
4078 * (longpress home key).
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004079 */
4080 public static final int FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY = 0x00100000;
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08004081 /**
Craig Mautnerf357c0c2014-06-09 09:23:27 -07004082 * @deprecated As of API 21 this performs identically to
4083 * {@link #FLAG_ACTIVITY_NEW_DOCUMENT} which should be used instead of this.
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08004084 */
4085 public static final int FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET = 0x00080000;
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08004086 /**
Craig Mautner026596b2014-05-21 15:35:44 -07004087 * This flag is used to open a document into a new task rooted at the activity launched
4088 * by this Intent. Through the use of this flag, or its equivalent attribute,
4089 * {@link android.R.attr#documentLaunchMode} multiple instances of the same activity
Chet Haase0d1c27a2014-11-03 18:35:16 +00004090 * containing different documents will appear in the recent tasks list.
Craig Mautnerd00f4742014-03-12 14:17:26 -07004091 *
Craig Mautner026596b2014-05-21 15:35:44 -07004092 * <p>The use of the activity attribute form of this,
4093 * {@link android.R.attr#documentLaunchMode}, is
4094 * preferred over the Intent flag described here. The attribute form allows the
4095 * Activity to specify multiple document behavior for all launchers of the Activity
4096 * whereas using this flag requires each Intent that launches the Activity to specify it.
Craig Mautnerd00f4742014-03-12 14:17:26 -07004097 *
Dianne Hackborn13420f22014-07-18 15:43:56 -07004098 * <p>Note that the default semantics of this flag w.r.t. whether the recents entry for
4099 * it is kept after the activity is finished is different than the use of
4100 * {@link #FLAG_ACTIVITY_NEW_TASK} and {@link android.R.attr#documentLaunchMode} -- if
4101 * this flag is being used to create a new recents entry, then by default that entry
4102 * will be removed once the activity is finished. You can modify this behavior with
4103 * {@link #FLAG_ACTIVITY_RETAIN_IN_RECENTS}.
4104 *
Craig Mautner026596b2014-05-21 15:35:44 -07004105 * <p>FLAG_ACTIVITY_NEW_DOCUMENT may be used in conjunction with {@link
4106 * #FLAG_ACTIVITY_MULTIPLE_TASK}. When used alone it is the
4107 * equivalent of the Activity manifest specifying {@link
4108 * android.R.attr#documentLaunchMode}="intoExisting". When used with
4109 * FLAG_ACTIVITY_MULTIPLE_TASK it is the equivalent of the Activity manifest specifying
4110 * {@link android.R.attr#documentLaunchMode}="always".
Craig Mautnerd00f4742014-03-12 14:17:26 -07004111 *
Craig Mautner026596b2014-05-21 15:35:44 -07004112 * Refer to {@link android.R.attr#documentLaunchMode} for more information.
Craig Mautnerd00f4742014-03-12 14:17:26 -07004113 *
Craig Mautner026596b2014-05-21 15:35:44 -07004114 * @see android.R.attr#documentLaunchMode
Craig Mautnerd00f4742014-03-12 14:17:26 -07004115 * @see #FLAG_ACTIVITY_MULTIPLE_TASK
4116 */
Craig Mautnerf357c0c2014-06-09 09:23:27 -07004117 public static final int FLAG_ACTIVITY_NEW_DOCUMENT = FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET;
Craig Mautnerd00f4742014-03-12 14:17:26 -07004118 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004119 * If set, this flag will prevent the normal {@link android.app.Activity#onUserLeaveHint}
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08004120 * callback from occurring on the current frontmost activity before it is
4121 * paused as the newly-started activity is brought to the front.
The Android Open Source Project10592532009-03-18 17:39:46 -07004122 *
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08004123 * <p>Typically, an activity can rely on that callback to indicate that an
4124 * explicit user action has caused their activity to be moved out of the
4125 * foreground. The callback marks an appropriate point in the activity's
4126 * lifecycle for it to dismiss any notifications that it intends to display
4127 * "until the user has seen them," such as a blinking LED.
The Android Open Source Project10592532009-03-18 17:39:46 -07004128 *
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08004129 * <p>If an activity is ever started via any non-user-driven events such as
4130 * phone-call receipt or an alarm handler, this flag should be passed to {@link
4131 * Context#startActivity Context.startActivity}, ensuring that the pausing
The Android Open Source Project10592532009-03-18 17:39:46 -07004132 * activity does not think the user has acknowledged its notification.
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08004133 */
4134 public static final int FLAG_ACTIVITY_NO_USER_ACTION = 0x00040000;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004135 /**
4136 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
4137 * this flag will cause the launched activity to be brought to the front of its
4138 * task's history stack if it is already running.
The Android Open Source Project10592532009-03-18 17:39:46 -07004139 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004140 * <p>For example, consider a task consisting of four activities: A, B, C, D.
4141 * If D calls startActivity() with an Intent that resolves to the component
4142 * of activity B, then B will be brought to the front of the history stack,
4143 * with this resulting order: A, C, D, B.
The Android Open Source Project10592532009-03-18 17:39:46 -07004144 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004145 * This flag will be ignored if {@link #FLAG_ACTIVITY_CLEAR_TOP} is also
The Android Open Source Project10592532009-03-18 17:39:46 -07004146 * specified.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004147 */
4148 public static final int FLAG_ACTIVITY_REORDER_TO_FRONT = 0X00020000;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004149 /**
Dianne Hackbornbfe319e2009-09-21 00:34:05 -07004150 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
4151 * this flag will prevent the system from applying an activity transition
4152 * animation to go to the next activity state. This doesn't mean an
4153 * animation will never run -- if another activity change happens that doesn't
4154 * specify this flag before the activity started here is displayed, then
Dianne Hackborn621e17d2010-11-22 15:59:56 -08004155 * that transition will be used. This flag can be put to good use
Dianne Hackbornbfe319e2009-09-21 00:34:05 -07004156 * when you are going to do a series of activity operations but the
4157 * animation seen by the user shouldn't be driven by the first activity
4158 * change but rather a later one.
4159 */
4160 public static final int FLAG_ACTIVITY_NO_ANIMATION = 0X00010000;
4161 /**
Dianne Hackborn621e17d2010-11-22 15:59:56 -08004162 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
4163 * this flag will cause any existing task that would be associated with the
4164 * activity to be cleared before the activity is started. That is, the activity
4165 * becomes the new root of an otherwise empty task, and any old activities
4166 * are finished. This can only be used in conjunction with {@link #FLAG_ACTIVITY_NEW_TASK}.
4167 */
4168 public static final int FLAG_ACTIVITY_CLEAR_TASK = 0X00008000;
4169 /**
4170 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
4171 * this flag will cause a newly launching task to be placed on top of the current
4172 * home activity task (if there is one). That is, pressing back from the task
4173 * will always return the user to home even if that was not the last activity they
4174 * saw. This can only be used in conjunction with {@link #FLAG_ACTIVITY_NEW_TASK}.
4175 */
4176 public static final int FLAG_ACTIVITY_TASK_ON_HOME = 0X00004000;
4177 /**
Dianne Hackborn13420f22014-07-18 15:43:56 -07004178 * By default a document created by {@link #FLAG_ACTIVITY_NEW_DOCUMENT} will
4179 * have its entry in recent tasks removed when the user closes it (with back
Jeff Sharkey9f991a22014-08-13 11:37:41 -07004180 * or however else it may finish()). If you would like to instead allow the
Dianne Hackborn13420f22014-07-18 15:43:56 -07004181 * document to be kept in recents so that it can be re-launched, you can use
Jeff Sharkey9f991a22014-08-13 11:37:41 -07004182 * this flag. When set and the task's activity is finished, the recents
4183 * entry will remain in the interface for the user to re-launch it, like a
4184 * recents entry for a top-level application.
4185 * <p>
4186 * The receiving activity can override this request with
4187 * {@link android.R.attr#autoRemoveFromRecents} or by explcitly calling
4188 * {@link android.app.Activity#finishAndRemoveTask()
Dianne Hackborn13420f22014-07-18 15:43:56 -07004189 * Activity.finishAndRemoveTask()}.
Craig Mautner2dac0562014-05-06 09:06:44 -07004190 */
Dianne Hackborn13420f22014-07-18 15:43:56 -07004191 public static final int FLAG_ACTIVITY_RETAIN_IN_RECENTS = 0x00002000;
Craig Mautnera228ae92014-07-09 05:44:55 -07004192
4193 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004194 * If set, when sending a broadcast only registered receivers will be
4195 * called -- no BroadcastReceiver components will be launched.
4196 */
4197 public static final int FLAG_RECEIVER_REGISTERED_ONLY = 0x40000000;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004198 /**
Dianne Hackborn1c633fc2009-12-08 19:45:14 -08004199 * If set, when sending a broadcast the new broadcast will replace
4200 * any existing pending broadcast that matches it. Matching is defined
4201 * by {@link Intent#filterEquals(Intent) Intent.filterEquals} returning
4202 * true for the intents of the two broadcasts. When a match is found,
4203 * the new broadcast (and receivers associated with it) will replace the
4204 * existing one in the pending broadcast list, remaining at the same
4205 * position in the list.
Tom Taylord4a47292009-12-21 13:59:18 -08004206 *
Dianne Hackborn1c633fc2009-12-08 19:45:14 -08004207 * <p>This flag is most typically used with sticky broadcasts, which
4208 * only care about delivering the most recent values of the broadcast
4209 * to their receivers.
4210 */
4211 public static final int FLAG_RECEIVER_REPLACE_PENDING = 0x20000000;
4212 /**
Christopher Tatef46723b2012-01-26 14:19:24 -08004213 * If set, when sending a broadcast the recipient is allowed to run at
4214 * foreground priority, with a shorter timeout interval. During normal
4215 * broadcasts the receivers are not automatically hoisted out of the
4216 * background priority class.
4217 */
4218 public static final int FLAG_RECEIVER_FOREGROUND = 0x10000000;
4219 /**
Dianne Hackborn6285a322013-09-18 12:09:47 -07004220 * If this is an ordered broadcast, don't allow receivers to abort the broadcast.
4221 * They can still propagate results through to later receivers, but they can not prevent
4222 * later receivers from seeing the broadcast.
4223 */
4224 public static final int FLAG_RECEIVER_NO_ABORT = 0x08000000;
4225 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004226 * If set, when sending a broadcast <i>before boot has completed</i> only
4227 * registered receivers will be called -- no BroadcastReceiver components
4228 * will be launched. Sticky intent state will be recorded properly even
4229 * if no receivers wind up being called. If {@link #FLAG_RECEIVER_REGISTERED_ONLY}
4230 * is specified in the broadcast intent, this flag is unnecessary.
The Android Open Source Project10592532009-03-18 17:39:46 -07004231 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004232 * <p>This flag is only for use by system sevices as a convenience to
4233 * avoid having to implement a more complex mechanism around detection
4234 * of boot completion.
The Android Open Source Project10592532009-03-18 17:39:46 -07004235 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004236 * @hide
4237 */
Dianne Hackborn6285a322013-09-18 12:09:47 -07004238 public static final int FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT = 0x04000000;
Dianne Hackborn9acc0302009-08-25 00:27:12 -07004239 /**
4240 * Set when this broadcast is for a boot upgrade, a special mode that
4241 * allows the broadcast to be sent before the system is ready and launches
4242 * the app process with no providers running in it.
4243 * @hide
4244 */
Dianne Hackborn6285a322013-09-18 12:09:47 -07004245 public static final int FLAG_RECEIVER_BOOT_UPGRADE = 0x02000000;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004246
Dianne Hackbornfa82f222009-09-17 15:14:12 -07004247 /**
4248 * @hide Flags that can't be changed with PendingIntent.
4249 */
Jeff Sharkey846318a2014-04-04 12:12:41 -07004250 public static final int IMMUTABLE_FLAGS = FLAG_GRANT_READ_URI_PERMISSION
4251 | FLAG_GRANT_WRITE_URI_PERMISSION | FLAG_GRANT_PERSISTABLE_URI_PERMISSION
4252 | FLAG_GRANT_PREFIX_URI_PERMISSION;
Tom Taylord4a47292009-12-21 13:59:18 -08004253
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004254 // ---------------------------------------------------------------------
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004255 // ---------------------------------------------------------------------
4256 // toUri() and parseUri() options.
4257
4258 /**
4259 * Flag for use with {@link #toUri} and {@link #parseUri}: the URI string
4260 * always has the "intent:" scheme. This syntax can be used when you want
4261 * to later disambiguate between URIs that are intended to describe an
4262 * Intent vs. all others that should be treated as raw URIs. When used
4263 * with {@link #parseUri}, any other scheme will result in a generic
4264 * VIEW action for that raw URI.
4265 */
4266 public static final int URI_INTENT_SCHEME = 1<<0;
Tom Taylord4a47292009-12-21 13:59:18 -08004267
Dianne Hackborn85d558c2014-11-04 10:31:54 -08004268 /**
4269 * Flag for use with {@link #toUri} and {@link #parseUri}: the URI string
4270 * always has the "android-app:" scheme. This is a variation of
4271 * {@link #URI_INTENT_SCHEME} whose format is simpler for the case of an
4272 * http/https URI being delivered to a specific package name. The format
4273 * is:
4274 *
4275 * <pre class="prettyprint">
Dianne Hackborn0ee10f62015-01-14 16:16:13 -08004276 * android-app://{package_id}[/{scheme}[/{host}[/{path}]]][#Intent;{...}]</pre>
Dianne Hackborn85d558c2014-11-04 10:31:54 -08004277 *
Dianne Hackborn0ee10f62015-01-14 16:16:13 -08004278 * <p>In this scheme, only the <code>package_id</code> is required. If you include a host,
4279 * you must also include a scheme; including a path also requires both a host and a scheme.
4280 * The final #Intent; fragment can be used without a scheme, host, or path.
4281 * Note that this can not be
Dianne Hackborn85d558c2014-11-04 10:31:54 -08004282 * used with intents that have a {@link #setSelector}, since the base intent
4283 * will always have an explicit package name.</p>
4284 *
4285 * <p>Some examples of how this scheme maps to Intent objects:</p>
4286 * <table border="2" width="85%" align="center" frame="hsides" rules="rows">
4287 * <colgroup align="left" />
4288 * <colgroup align="left" />
4289 * <thead>
4290 * <tr><th>URI</th> <th>Intent</th></tr>
4291 * </thead>
4292 *
4293 * <tbody>
4294 * <tr><td><code>android-app://com.example.app</code></td>
4295 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
4296 * <tr><td>Action: </td><td>{@link #ACTION_MAIN}</td></tr>
4297 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
4298 * </table></td>
4299 * </tr>
4300 * <tr><td><code>android-app://com.example.app/http/example.com</code></td>
4301 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
4302 * <tr><td>Action: </td><td>{@link #ACTION_VIEW}</td></tr>
4303 * <tr><td>Data: </td><td><code>http://example.com/</code></td></tr>
4304 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
4305 * </table></td>
4306 * </tr>
4307 * <tr><td><code>android-app://com.example.app/http/example.com/foo?1234</code></td>
4308 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
4309 * <tr><td>Action: </td><td>{@link #ACTION_VIEW}</td></tr>
4310 * <tr><td>Data: </td><td><code>http://example.com/foo?1234</code></td></tr>
4311 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
4312 * </table></td>
4313 * </tr>
4314 * <tr><td><code>android-app://com.example.app/<br />#Intent;action=com.example.MY_ACTION;end</code></td>
4315 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
4316 * <tr><td>Action: </td><td><code>com.example.MY_ACTION</code></td></tr>
4317 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
4318 * </table></td>
4319 * </tr>
4320 * <tr><td><code>android-app://com.example.app/http/example.com/foo?1234<br />#Intent;action=com.example.MY_ACTION;end</code></td>
4321 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
4322 * <tr><td>Action: </td><td><code>com.example.MY_ACTION</code></td></tr>
4323 * <tr><td>Data: </td><td><code>http://example.com/foo?1234</code></td></tr>
4324 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
4325 * </table></td>
4326 * </tr>
4327 * <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>
4328 * <td><table border="" style="margin:0" >
4329 * <tr><td>Action: </td><td><code>com.example.MY_ACTION</code></td></tr>
4330 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
4331 * <tr><td>Extras: </td><td><code>some_int=(int)100<br />some_str=(String)hello</code></td></tr>
4332 * </table></td>
4333 * </tr>
4334 * </tbody>
4335 * </table>
4336 */
4337 public static final int URI_ANDROID_APP_SCHEME = 1<<1;
4338
Dianne Hackborn24b1c232014-11-20 17:17:39 -08004339 /**
4340 * Flag for use with {@link #toUri} and {@link #parseUri}: allow parsing
4341 * of unsafe information. In particular, the flags {@link #FLAG_GRANT_READ_URI_PERMISSION},
4342 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, {@link #FLAG_GRANT_PERSISTABLE_URI_PERMISSION},
4343 * and {@link #FLAG_GRANT_PREFIX_URI_PERMISSION} flags can not be set, so that the
4344 * generated Intent can not cause unexpected data access to happen.
4345 *
4346 * <p>If you do not trust the source of the URI being parsed, you should still do further
4347 * processing to protect yourself from it. In particular, when using it to start an
4348 * activity you should usually add in {@link #CATEGORY_BROWSABLE} to limit the activities
4349 * that can handle it.</p>
4350 */
4351 public static final int URI_ALLOW_UNSAFE = 1<<2;
4352
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004353 // ---------------------------------------------------------------------
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004354
4355 private String mAction;
4356 private Uri mData;
4357 private String mType;
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004358 private String mPackage;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004359 private ComponentName mComponent;
4360 private int mFlags;
Dianne Hackbornadd005c2013-07-17 18:43:12 -07004361 private ArraySet<String> mCategories;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004362 private Bundle mExtras;
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08004363 private Rect mSourceBounds;
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004364 private Intent mSelector;
Dianne Hackborn21c241e2012-03-08 13:57:23 -08004365 private ClipData mClipData;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01004366 private int mContentUserHint = UserHandle.USER_CURRENT;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004367
4368 // ---------------------------------------------------------------------
4369
4370 /**
4371 * Create an empty intent.
4372 */
4373 public Intent() {
4374 }
4375
4376 /**
4377 * Copy constructor.
4378 */
4379 public Intent(Intent o) {
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 this.mFlags = o.mFlags;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01004386 this.mContentUserHint = o.mContentUserHint;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004387 if (o.mCategories != null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07004388 this.mCategories = new ArraySet<String>(o.mCategories);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004389 }
4390 if (o.mExtras != null) {
4391 this.mExtras = new Bundle(o.mExtras);
4392 }
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08004393 if (o.mSourceBounds != null) {
4394 this.mSourceBounds = new Rect(o.mSourceBounds);
4395 }
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004396 if (o.mSelector != null) {
4397 this.mSelector = new Intent(o.mSelector);
4398 }
Dianne Hackborn21c241e2012-03-08 13:57:23 -08004399 if (o.mClipData != null) {
4400 this.mClipData = new ClipData(o.mClipData);
4401 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004402 }
4403
4404 @Override
4405 public Object clone() {
4406 return new Intent(this);
4407 }
4408
4409 private Intent(Intent o, boolean all) {
4410 this.mAction = o.mAction;
4411 this.mData = o.mData;
4412 this.mType = o.mType;
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004413 this.mPackage = o.mPackage;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004414 this.mComponent = o.mComponent;
4415 if (o.mCategories != null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07004416 this.mCategories = new ArraySet<String>(o.mCategories);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004417 }
4418 }
4419
4420 /**
4421 * Make a clone of only the parts of the Intent that are relevant for
4422 * filter matching: the action, data, type, component, and categories.
4423 */
4424 public Intent cloneFilter() {
4425 return new Intent(this, false);
4426 }
4427
4428 /**
4429 * Create an intent with a given action. All other fields (data, type,
4430 * class) are null. Note that the action <em>must</em> be in a
4431 * namespace because Intents are used globally in the system -- for
4432 * example the system VIEW action is android.intent.action.VIEW; an
4433 * application's custom action would be something like
4434 * com.google.app.myapp.CUSTOM_ACTION.
4435 *
4436 * @param action The Intent action, such as ACTION_VIEW.
4437 */
4438 public Intent(String action) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08004439 setAction(action);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004440 }
4441
4442 /**
4443 * Create an intent with a given action and for a given data url. Note
4444 * that the action <em>must</em> be in a namespace because Intents are
4445 * used globally in the system -- for example the system VIEW action is
4446 * android.intent.action.VIEW; an application's custom action would be
4447 * something like com.google.app.myapp.CUSTOM_ACTION.
4448 *
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07004449 * <p><em>Note: scheme and host name matching in the Android framework is
4450 * case-sensitive, unlike the formal RFC. As a result,
4451 * you should always ensure that you write your Uri with these elements
4452 * using lower case letters, and normalize any Uris you receive from
4453 * outside of Android to ensure the scheme and host is lower case.</em></p>
4454 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004455 * @param action The Intent action, such as ACTION_VIEW.
4456 * @param uri The Intent data URI.
4457 */
4458 public Intent(String action, Uri uri) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08004459 setAction(action);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004460 mData = uri;
4461 }
4462
4463 /**
4464 * Create an intent for a specific component. All other fields (action, data,
4465 * type, class) are null, though they can be modified later with explicit
4466 * calls. This provides a convenient way to create an intent that is
4467 * intended to execute a hard-coded class name, rather than relying on the
4468 * system to find an appropriate class for you; see {@link #setComponent}
4469 * for more information on the repercussions of this.
4470 *
4471 * @param packageContext A Context of the application package implementing
4472 * this class.
4473 * @param cls The component class that is to be used for the intent.
4474 *
4475 * @see #setClass
4476 * @see #setComponent
4477 * @see #Intent(String, android.net.Uri , Context, Class)
4478 */
4479 public Intent(Context packageContext, Class<?> cls) {
4480 mComponent = new ComponentName(packageContext, cls);
4481 }
4482
4483 /**
4484 * Create an intent for a specific component with a specified action and data.
Craig Mautner2dac0562014-05-06 09:06:44 -07004485 * This is equivalent to using {@link #Intent(String, android.net.Uri)} to
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004486 * construct the Intent and then calling {@link #setClass} to set its
4487 * class.
4488 *
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07004489 * <p><em>Note: scheme and host name matching in the Android framework is
4490 * case-sensitive, unlike the formal RFC. As a result,
4491 * you should always ensure that you write your Uri with these elements
4492 * using lower case letters, and normalize any Uris you receive from
4493 * outside of Android to ensure the scheme and host is lower case.</em></p>
4494 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004495 * @param action The Intent action, such as ACTION_VIEW.
4496 * @param uri The Intent data URI.
4497 * @param packageContext A Context of the application package implementing
4498 * this class.
4499 * @param cls The component class that is to be used for the intent.
4500 *
4501 * @see #Intent(String, android.net.Uri)
4502 * @see #Intent(Context, Class)
4503 * @see #setClass
4504 * @see #setComponent
4505 */
4506 public Intent(String action, Uri uri,
4507 Context packageContext, Class<?> cls) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08004508 setAction(action);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004509 mData = uri;
4510 mComponent = new ComponentName(packageContext, cls);
4511 }
4512
4513 /**
Dianne Hackborn30d71892010-12-11 10:37:55 -08004514 * Create an intent to launch the main (root) activity of a task. This
4515 * is the Intent that is started when the application's 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 the given Activity component as its explicit
4521 * component, {@link #ACTION_MAIN} as its action, and includes the
4522 * category {@link #CATEGORY_LAUNCHER}. This does <em>not</em> have
4523 * {@link #FLAG_ACTIVITY_NEW_TASK} set, though typically you will want
4524 * to do that through {@link #addFlags(int)} on the returned Intent.
4525 *
4526 * @param mainActivity The main activity component that this Intent will
4527 * launch.
4528 * @return Returns a newly created Intent that can be used to launch the
4529 * activity as a main application entry.
4530 *
4531 * @see #setClass
4532 * @see #setComponent
4533 */
4534 public static Intent makeMainActivity(ComponentName mainActivity) {
4535 Intent intent = new Intent(ACTION_MAIN);
4536 intent.setComponent(mainActivity);
4537 intent.addCategory(CATEGORY_LAUNCHER);
4538 return intent;
4539 }
4540
4541 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004542 * Make an Intent for the main activity of an application, without
4543 * specifying a specific activity to run but giving a selector to find
4544 * the activity. This results in a final Intent that is structured
4545 * the same as when the application is launched from
4546 * Home. For anything else that wants to launch an application in the
4547 * same way, it is important that they use an Intent structured the same
4548 * way, and can use this function to ensure this is the case.
4549 *
4550 * <p>The returned Intent has {@link #ACTION_MAIN} as its action, and includes the
4551 * category {@link #CATEGORY_LAUNCHER}. This does <em>not</em> have
4552 * {@link #FLAG_ACTIVITY_NEW_TASK} set, though typically you will want
4553 * to do that through {@link #addFlags(int)} on the returned Intent.
4554 *
4555 * @param selectorAction The action name of the Intent's selector.
4556 * @param selectorCategory The name of a category to add to the Intent's
4557 * selector.
4558 * @return Returns a newly created Intent that can be used to launch the
4559 * activity as a main application entry.
4560 *
4561 * @see #setSelector(Intent)
4562 */
4563 public static Intent makeMainSelectorActivity(String selectorAction,
4564 String selectorCategory) {
4565 Intent intent = new Intent(ACTION_MAIN);
4566 intent.addCategory(CATEGORY_LAUNCHER);
4567 Intent selector = new Intent();
4568 selector.setAction(selectorAction);
4569 selector.addCategory(selectorCategory);
4570 intent.setSelector(selector);
4571 return intent;
4572 }
4573
4574 /**
Dianne Hackborn30d71892010-12-11 10:37:55 -08004575 * Make an Intent that can be used to re-launch an application's task
4576 * in its base state. This is like {@link #makeMainActivity(ComponentName)},
4577 * but also sets the flags {@link #FLAG_ACTIVITY_NEW_TASK} and
4578 * {@link #FLAG_ACTIVITY_CLEAR_TASK}.
4579 *
4580 * @param mainActivity The activity component that is the root of the
4581 * task; this is the activity that has been published in the application's
4582 * manifest as the main launcher icon.
4583 *
4584 * @return Returns a newly created Intent that can be used to relaunch the
4585 * activity's task in its root state.
4586 */
4587 public static Intent makeRestartActivityTask(ComponentName mainActivity) {
4588 Intent intent = makeMainActivity(mainActivity);
4589 intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK
4590 | Intent.FLAG_ACTIVITY_CLEAR_TASK);
4591 return intent;
4592 }
4593
4594 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004595 * Call {@link #parseUri} with 0 flags.
4596 * @deprecated Use {@link #parseUri} instead.
4597 */
4598 @Deprecated
4599 public static Intent getIntent(String uri) throws URISyntaxException {
4600 return parseUri(uri, 0);
4601 }
Tom Taylord4a47292009-12-21 13:59:18 -08004602
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004603 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004604 * Create an intent from a URI. This URI may encode the action,
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004605 * category, and other intent fields, if it was returned by
Dianne Hackborn7f205432009-07-28 00:13:47 -07004606 * {@link #toUri}. If the Intent was not generate by toUri(), its data
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004607 * will be the entire URI and its action will be ACTION_VIEW.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004608 *
4609 * <p>The URI given here must not be relative -- that is, it must include
4610 * the scheme and full path.
4611 *
4612 * @param uri The URI to turn into an Intent.
Dianne Hackborn85d558c2014-11-04 10:31:54 -08004613 * @param flags Additional processing flags. Either 0,
4614 * {@link #URI_INTENT_SCHEME}, or {@link #URI_ANDROID_APP_SCHEME}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004615 *
4616 * @return Intent The newly created Intent object.
4617 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004618 * @throws URISyntaxException Throws URISyntaxError if the basic URI syntax
4619 * it bad (as parsed by the Uri class) or the Intent data within the
4620 * URI is invalid.
Tom Taylord4a47292009-12-21 13:59:18 -08004621 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004622 * @see #toUri
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004623 */
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004624 public static Intent parseUri(String uri, int flags) throws URISyntaxException {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004625 int i = 0;
4626 try {
Dianne Hackborn85d558c2014-11-04 10:31:54 -08004627 final boolean androidApp = uri.startsWith("android-app:");
4628
4629 // Validate intent scheme if requested.
4630 if ((flags&(URI_INTENT_SCHEME|URI_ANDROID_APP_SCHEME)) != 0) {
4631 if (!uri.startsWith("intent:") && !androidApp) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004632 Intent intent = new Intent(ACTION_VIEW);
4633 try {
4634 intent.setData(Uri.parse(uri));
4635 } catch (IllegalArgumentException e) {
4636 throw new URISyntaxException(uri, e.getMessage());
4637 }
4638 return intent;
4639 }
4640 }
Tom Taylord4a47292009-12-21 13:59:18 -08004641
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004642 i = uri.lastIndexOf("#");
Dianne Hackborn85d558c2014-11-04 10:31:54 -08004643 // simple case
4644 if (i == -1) {
4645 if (!androidApp) {
4646 return new Intent(ACTION_VIEW, Uri.parse(uri));
4647 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004648
4649 // old format Intent URI
Dianne Hackborn85d558c2014-11-04 10:31:54 -08004650 } else if (!uri.startsWith("#Intent;", i)) {
4651 if (!androidApp) {
Dianne Hackborn24b1c232014-11-20 17:17:39 -08004652 return getIntentOld(uri, flags);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08004653 } else {
4654 i = -1;
4655 }
4656 }
The Android Open Source Project10592532009-03-18 17:39:46 -07004657
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004658 // new format
4659 Intent intent = new Intent(ACTION_VIEW);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004660 Intent baseIntent = intent;
Dianne Hackborn85d558c2014-11-04 10:31:54 -08004661 boolean explicitAction = false;
4662 boolean inSelector = false;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004663
4664 // fetch data part, if present
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004665 String scheme = null;
Dianne Hackborn85d558c2014-11-04 10:31:54 -08004666 String data;
4667 if (i >= 0) {
4668 data = uri.substring(0, i);
4669 i += 8; // length of "#Intent;"
4670 } else {
4671 data = uri;
4672 }
The Android Open Source Project10592532009-03-18 17:39:46 -07004673
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004674 // loop over contents of Intent, all name=value;
Dianne Hackborn85d558c2014-11-04 10:31:54 -08004675 while (i >= 0 && !uri.startsWith("end", i)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004676 int eq = uri.indexOf('=', i);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004677 if (eq < 0) eq = i-1;
4678 int semi = uri.indexOf(';', i);
4679 String value = eq < semi ? Uri.decode(uri.substring(eq + 1, semi)) : "";
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004680
4681 // action
4682 if (uri.startsWith("action=", i)) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08004683 intent.setAction(value);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08004684 if (!inSelector) {
4685 explicitAction = true;
4686 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004687 }
4688
4689 // categories
4690 else if (uri.startsWith("category=", i)) {
4691 intent.addCategory(value);
4692 }
4693
4694 // type
4695 else if (uri.startsWith("type=", i)) {
4696 intent.mType = value;
4697 }
4698
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08004699 // launch flags
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004700 else if (uri.startsWith("launchFlags=", i)) {
4701 intent.mFlags = Integer.decode(value).intValue();
Dianne Hackborn24b1c232014-11-20 17:17:39 -08004702 if ((flags& URI_ALLOW_UNSAFE) == 0) {
4703 intent.mFlags &= ~IMMUTABLE_FLAGS;
4704 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004705 }
4706
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004707 // package
4708 else if (uri.startsWith("package=", i)) {
4709 intent.mPackage = value;
4710 }
4711
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004712 // component
4713 else if (uri.startsWith("component=", i)) {
4714 intent.mComponent = ComponentName.unflattenFromString(value);
4715 }
The Android Open Source Project10592532009-03-18 17:39:46 -07004716
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004717 // scheme
4718 else if (uri.startsWith("scheme=", i)) {
Dianne Hackborn85d558c2014-11-04 10:31:54 -08004719 if (inSelector) {
Dianne Hackborn80b1c562014-12-09 20:22:08 -08004720 intent.mData = Uri.parse(value + ":");
Dianne Hackborn85d558c2014-11-04 10:31:54 -08004721 } else {
4722 scheme = value;
4723 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004724 }
4725
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08004726 // source bounds
4727 else if (uri.startsWith("sourceBounds=", i)) {
4728 intent.mSourceBounds = Rect.unflattenFromString(value);
4729 }
4730
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004731 // selector
4732 else if (semi == (i+3) && uri.startsWith("SEL", i)) {
4733 intent = new Intent();
Dianne Hackborn85d558c2014-11-04 10:31:54 -08004734 inSelector = true;
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004735 }
4736
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004737 // extra
4738 else {
4739 String key = Uri.decode(uri.substring(i + 2, eq));
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004740 // create Bundle if it doesn't already exist
4741 if (intent.mExtras == null) intent.mExtras = new Bundle();
4742 Bundle b = intent.mExtras;
4743 // add EXTRA
4744 if (uri.startsWith("S.", i)) b.putString(key, value);
4745 else if (uri.startsWith("B.", i)) b.putBoolean(key, Boolean.parseBoolean(value));
4746 else if (uri.startsWith("b.", i)) b.putByte(key, Byte.parseByte(value));
4747 else if (uri.startsWith("c.", i)) b.putChar(key, value.charAt(0));
4748 else if (uri.startsWith("d.", i)) b.putDouble(key, Double.parseDouble(value));
4749 else if (uri.startsWith("f.", i)) b.putFloat(key, Float.parseFloat(value));
4750 else if (uri.startsWith("i.", i)) b.putInt(key, Integer.parseInt(value));
4751 else if (uri.startsWith("l.", i)) b.putLong(key, Long.parseLong(value));
4752 else if (uri.startsWith("s.", i)) b.putShort(key, Short.parseShort(value));
4753 else throw new URISyntaxException(uri, "unknown EXTRA type", i);
4754 }
The Android Open Source Project10592532009-03-18 17:39:46 -07004755
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004756 // move to the next item
4757 i = semi + 1;
4758 }
4759
Dianne Hackborn85d558c2014-11-04 10:31:54 -08004760 if (inSelector) {
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004761 // The Intent had a selector; fix it up.
Dianne Hackborn85d558c2014-11-04 10:31:54 -08004762 if (baseIntent.mPackage == null) {
4763 baseIntent.setSelector(intent);
4764 }
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004765 intent = baseIntent;
4766 }
4767
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004768 if (data != null) {
4769 if (data.startsWith("intent:")) {
4770 data = data.substring(7);
4771 if (scheme != null) {
4772 data = scheme + ':' + data;
4773 }
Dianne Hackborn85d558c2014-11-04 10:31:54 -08004774 } else if (data.startsWith("android-app:")) {
4775 if (data.charAt(12) == '/' && data.charAt(13) == '/') {
4776 // Correctly formed android-app, first part is package name.
4777 int end = data.indexOf('/', 14);
4778 if (end < 0) {
4779 // All we have is a package name.
4780 intent.mPackage = data.substring(14);
4781 if (!explicitAction) {
4782 intent.setAction(ACTION_MAIN);
4783 }
4784 data = "";
4785 } else {
4786 // Target the Intent at the given package name always.
4787 String authority = null;
4788 intent.mPackage = data.substring(14, end);
4789 int newEnd;
Dianne Hackborn80b1c562014-12-09 20:22:08 -08004790 if ((end+1) < data.length()) {
4791 if ((newEnd=data.indexOf('/', end+1)) >= 0) {
4792 // Found a scheme, remember it.
4793 scheme = data.substring(end+1, newEnd);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08004794 end = newEnd;
Dianne Hackborn80b1c562014-12-09 20:22:08 -08004795 if (end < data.length() && (newEnd=data.indexOf('/', end+1)) >= 0) {
4796 // Found a authority, remember it.
4797 authority = data.substring(end+1, newEnd);
4798 end = newEnd;
4799 }
4800 } else {
4801 // All we have is a scheme.
4802 scheme = data.substring(end+1);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08004803 }
4804 }
4805 if (scheme == null) {
4806 // If there was no scheme, then this just targets the package.
4807 if (!explicitAction) {
4808 intent.setAction(ACTION_MAIN);
4809 }
4810 data = "";
4811 } else if (authority == null) {
4812 data = scheme + ":";
4813 } else {
4814 data = scheme + "://" + authority + data.substring(end);
4815 }
4816 }
4817 } else {
4818 data = "";
4819 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004820 }
Tom Taylord4a47292009-12-21 13:59:18 -08004821
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004822 if (data.length() > 0) {
4823 try {
4824 intent.mData = Uri.parse(data);
4825 } catch (IllegalArgumentException e) {
4826 throw new URISyntaxException(uri, e.getMessage());
4827 }
4828 }
4829 }
Tom Taylord4a47292009-12-21 13:59:18 -08004830
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004831 return intent;
The Android Open Source Project10592532009-03-18 17:39:46 -07004832
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004833 } catch (IndexOutOfBoundsException e) {
4834 throw new URISyntaxException(uri, "illegal Intent URI format", i);
4835 }
4836 }
The Android Open Source Project10592532009-03-18 17:39:46 -07004837
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004838 public static Intent getIntentOld(String uri) throws URISyntaxException {
Dianne Hackborn24b1c232014-11-20 17:17:39 -08004839 return getIntentOld(uri, 0);
4840 }
4841
4842 private static Intent getIntentOld(String uri, int flags) throws URISyntaxException {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004843 Intent intent;
4844
4845 int i = uri.lastIndexOf('#');
4846 if (i >= 0) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004847 String action = null;
Dianne Hackborn6cca1592009-09-20 12:40:03 -07004848 final int intentFragmentStart = i;
4849 boolean isIntentFragment = false;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004850
4851 i++;
4852
4853 if (uri.regionMatches(i, "action(", 0, 7)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07004854 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004855 i += 7;
4856 int j = uri.indexOf(')', i);
4857 action = uri.substring(i, j);
4858 i = j + 1;
4859 }
4860
Dianne Hackborn6cca1592009-09-20 12:40:03 -07004861 intent = new Intent(action);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004862
4863 if (uri.regionMatches(i, "categories(", 0, 11)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07004864 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004865 i += 11;
4866 int j = uri.indexOf(')', i);
4867 while (i < j) {
4868 int sep = uri.indexOf('!', i);
Alan Viverette0adf32b2014-09-18 12:53:16 -07004869 if (sep < 0 || sep > j) sep = j;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004870 if (i < sep) {
4871 intent.addCategory(uri.substring(i, sep));
4872 }
4873 i = sep + 1;
4874 }
4875 i = j + 1;
4876 }
4877
4878 if (uri.regionMatches(i, "type(", 0, 5)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07004879 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004880 i += 5;
4881 int j = uri.indexOf(')', i);
4882 intent.mType = uri.substring(i, j);
4883 i = j + 1;
4884 }
4885
4886 if (uri.regionMatches(i, "launchFlags(", 0, 12)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07004887 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004888 i += 12;
4889 int j = uri.indexOf(')', i);
4890 intent.mFlags = Integer.decode(uri.substring(i, j)).intValue();
Dianne Hackborn24b1c232014-11-20 17:17:39 -08004891 if ((flags& URI_ALLOW_UNSAFE) == 0) {
4892 intent.mFlags &= ~IMMUTABLE_FLAGS;
4893 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004894 i = j + 1;
4895 }
4896
4897 if (uri.regionMatches(i, "component(", 0, 10)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07004898 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004899 i += 10;
4900 int j = uri.indexOf(')', i);
4901 int sep = uri.indexOf('!', i);
4902 if (sep >= 0 && sep < j) {
4903 String pkg = uri.substring(i, sep);
4904 String cls = uri.substring(sep + 1, j);
4905 intent.mComponent = new ComponentName(pkg, cls);
4906 }
4907 i = j + 1;
4908 }
4909
4910 if (uri.regionMatches(i, "extras(", 0, 7)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07004911 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004912 i += 7;
The Android Open Source Project10592532009-03-18 17:39:46 -07004913
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004914 final int closeParen = uri.indexOf(')', i);
4915 if (closeParen == -1) throw new URISyntaxException(uri,
4916 "EXTRA missing trailing ')'", i);
4917
4918 while (i < closeParen) {
4919 // fetch the key value
4920 int j = uri.indexOf('=', i);
4921 if (j <= i + 1 || i >= closeParen) {
4922 throw new URISyntaxException(uri, "EXTRA missing '='", i);
4923 }
4924 char type = uri.charAt(i);
4925 i++;
4926 String key = uri.substring(i, j);
4927 i = j + 1;
The Android Open Source Project10592532009-03-18 17:39:46 -07004928
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004929 // get type-value
4930 j = uri.indexOf('!', i);
4931 if (j == -1 || j >= closeParen) j = closeParen;
4932 if (i >= j) throw new URISyntaxException(uri, "EXTRA missing '!'", i);
4933 String value = uri.substring(i, j);
4934 i = j;
4935
4936 // create Bundle if it doesn't already exist
4937 if (intent.mExtras == null) intent.mExtras = new Bundle();
The Android Open Source Project10592532009-03-18 17:39:46 -07004938
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004939 // add item to bundle
4940 try {
4941 switch (type) {
4942 case 'S':
4943 intent.mExtras.putString(key, Uri.decode(value));
4944 break;
4945 case 'B':
4946 intent.mExtras.putBoolean(key, Boolean.parseBoolean(value));
4947 break;
4948 case 'b':
4949 intent.mExtras.putByte(key, Byte.parseByte(value));
4950 break;
4951 case 'c':
4952 intent.mExtras.putChar(key, Uri.decode(value).charAt(0));
4953 break;
4954 case 'd':
4955 intent.mExtras.putDouble(key, Double.parseDouble(value));
4956 break;
4957 case 'f':
4958 intent.mExtras.putFloat(key, Float.parseFloat(value));
4959 break;
4960 case 'i':
4961 intent.mExtras.putInt(key, Integer.parseInt(value));
4962 break;
4963 case 'l':
4964 intent.mExtras.putLong(key, Long.parseLong(value));
4965 break;
4966 case 's':
4967 intent.mExtras.putShort(key, Short.parseShort(value));
4968 break;
4969 default:
4970 throw new URISyntaxException(uri, "EXTRA has unknown type", i);
4971 }
4972 } catch (NumberFormatException e) {
4973 throw new URISyntaxException(uri, "EXTRA value can't be parsed", i);
4974 }
The Android Open Source Project10592532009-03-18 17:39:46 -07004975
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004976 char ch = uri.charAt(i);
4977 if (ch == ')') break;
4978 if (ch != '!') throw new URISyntaxException(uri, "EXTRA missing '!'", i);
4979 i++;
4980 }
4981 }
4982
Dianne Hackborn6cca1592009-09-20 12:40:03 -07004983 if (isIntentFragment) {
4984 intent.mData = Uri.parse(uri.substring(0, intentFragmentStart));
4985 } else {
4986 intent.mData = Uri.parse(uri);
4987 }
Tom Taylord4a47292009-12-21 13:59:18 -08004988
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004989 if (intent.mAction == null) {
4990 // By default, if no action is specified, then use VIEW.
4991 intent.mAction = ACTION_VIEW;
4992 }
4993
4994 } else {
4995 intent = new Intent(ACTION_VIEW, Uri.parse(uri));
4996 }
4997
4998 return intent;
4999 }
5000
5001 /**
5002 * Retrieve the general action to be performed, such as
5003 * {@link #ACTION_VIEW}. The action describes the general way the rest of
5004 * the information in the intent should be interpreted -- most importantly,
5005 * what to do with the data returned by {@link #getData}.
5006 *
5007 * @return The action of this intent or null if none is specified.
5008 *
5009 * @see #setAction
5010 */
5011 public String getAction() {
5012 return mAction;
5013 }
5014
5015 /**
5016 * Retrieve data this intent is operating on. This URI specifies the name
5017 * of the data; often it uses the content: scheme, specifying data in a
5018 * content provider. Other schemes may be handled by specific activities,
5019 * such as http: by the web browser.
5020 *
5021 * @return The URI of the data this intent is targeting or null.
5022 *
5023 * @see #getScheme
5024 * @see #setData
5025 */
5026 public Uri getData() {
5027 return mData;
5028 }
5029
5030 /**
5031 * The same as {@link #getData()}, but returns the URI as an encoded
5032 * String.
5033 */
5034 public String getDataString() {
5035 return mData != null ? mData.toString() : null;
5036 }
5037
5038 /**
5039 * Return the scheme portion of the intent's data. If the data is null or
5040 * does not include a scheme, null is returned. Otherwise, the scheme
5041 * prefix without the final ':' is returned, i.e. "http".
5042 *
5043 * <p>This is the same as calling getData().getScheme() (and checking for
5044 * null data).
5045 *
5046 * @return The scheme of this intent.
5047 *
5048 * @see #getData
5049 */
5050 public String getScheme() {
5051 return mData != null ? mData.getScheme() : null;
5052 }
5053
5054 /**
5055 * Retrieve any explicit MIME type included in the intent. This is usually
5056 * null, as the type is determined by the intent data.
5057 *
5058 * @return If a type was manually set, it is returned; else null is
5059 * returned.
5060 *
5061 * @see #resolveType(ContentResolver)
5062 * @see #setType
5063 */
5064 public String getType() {
5065 return mType;
5066 }
5067
5068 /**
5069 * Return the MIME data type of this intent. If the type field is
5070 * explicitly set, that is simply returned. Otherwise, if the data is set,
5071 * the type of that data is returned. If neither fields are set, a null is
5072 * returned.
5073 *
5074 * @return The MIME type of this intent.
5075 *
5076 * @see #getType
5077 * @see #resolveType(ContentResolver)
5078 */
5079 public String resolveType(Context context) {
5080 return resolveType(context.getContentResolver());
5081 }
5082
5083 /**
5084 * Return the MIME data type of this intent. If the type field is
5085 * explicitly set, that is simply returned. Otherwise, if the data is set,
5086 * the type of that data is returned. If neither fields are set, a null is
5087 * returned.
5088 *
5089 * @param resolver A ContentResolver that can be used to determine the MIME
5090 * type of the intent's data.
5091 *
5092 * @return The MIME type of this intent.
5093 *
5094 * @see #getType
5095 * @see #resolveType(Context)
5096 */
5097 public String resolveType(ContentResolver resolver) {
5098 if (mType != null) {
5099 return mType;
5100 }
5101 if (mData != null) {
5102 if ("content".equals(mData.getScheme())) {
5103 return resolver.getType(mData);
5104 }
5105 }
5106 return null;
5107 }
5108
5109 /**
5110 * Return the MIME data type of this intent, only if it will be needed for
5111 * intent resolution. This is not generally useful for application code;
5112 * it is used by the frameworks for communicating with back-end system
5113 * services.
5114 *
5115 * @param resolver A ContentResolver that can be used to determine the MIME
5116 * type of the intent's data.
5117 *
5118 * @return The MIME type of this intent, or null if it is unknown or not
5119 * needed.
5120 */
5121 public String resolveTypeIfNeeded(ContentResolver resolver) {
5122 if (mComponent != null) {
5123 return mType;
5124 }
5125 return resolveType(resolver);
5126 }
5127
5128 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09005129 * Check if a category exists in the intent.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005130 *
5131 * @param category The category to check.
5132 *
5133 * @return boolean True if the intent contains the category, else false.
5134 *
5135 * @see #getCategories
5136 * @see #addCategory
5137 */
5138 public boolean hasCategory(String category) {
5139 return mCategories != null && mCategories.contains(category);
5140 }
5141
5142 /**
5143 * Return the set of all categories in the intent. If there are no categories,
5144 * returns NULL.
5145 *
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005146 * @return The set of categories you can examine. Do not modify!
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005147 *
5148 * @see #hasCategory
5149 * @see #addCategory
5150 */
5151 public Set<String> getCategories() {
5152 return mCategories;
5153 }
5154
5155 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005156 * Return the specific selector associated with this Intent. If there is
5157 * none, returns null. See {@link #setSelector} for more information.
5158 *
5159 * @see #setSelector
5160 */
5161 public Intent getSelector() {
5162 return mSelector;
5163 }
5164
5165 /**
Dianne Hackborn21c241e2012-03-08 13:57:23 -08005166 * Return the {@link ClipData} associated with this Intent. If there is
5167 * none, returns null. See {@link #setClipData} for more information.
5168 *
John Spurlock125d1332013-11-25 11:58:37 -05005169 * @see #setClipData
Dianne Hackborn21c241e2012-03-08 13:57:23 -08005170 */
5171 public ClipData getClipData() {
5172 return mClipData;
5173 }
5174
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01005175 /** @hide */
5176 public int getContentUserHint() {
5177 return mContentUserHint;
5178 }
5179
Dianne Hackborn21c241e2012-03-08 13:57:23 -08005180 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005181 * Sets the ClassLoader that will be used when unmarshalling
5182 * any Parcelable values from the extras of this Intent.
5183 *
5184 * @param loader a ClassLoader, or null to use the default loader
5185 * at the time of unmarshalling.
5186 */
5187 public void setExtrasClassLoader(ClassLoader loader) {
5188 if (mExtras != null) {
5189 mExtras.setClassLoader(loader);
5190 }
5191 }
5192
5193 /**
5194 * Returns true if an extra value is associated with the given name.
5195 * @param name the extra's name
5196 * @return true if the given extra is present.
5197 */
5198 public boolean hasExtra(String name) {
5199 return mExtras != null && mExtras.containsKey(name);
5200 }
5201
5202 /**
5203 * Returns true if the Intent's extras contain a parcelled file descriptor.
5204 * @return true if the Intent contains a parcelled file descriptor.
5205 */
5206 public boolean hasFileDescriptors() {
5207 return mExtras != null && mExtras.hasFileDescriptors();
5208 }
The Android Open Source Project10592532009-03-18 17:39:46 -07005209
Dianne Hackborn9ecebbf2011-09-28 23:19:47 -04005210 /** @hide */
5211 public void setAllowFds(boolean allowFds) {
5212 if (mExtras != null) {
5213 mExtras.setAllowFds(allowFds);
5214 }
5215 }
5216
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005217 /**
5218 * Retrieve extended data from the intent.
5219 *
5220 * @param name The name of the desired item.
5221 *
5222 * @return the value of an item that previously added with putExtra()
5223 * or null if none was found.
5224 *
5225 * @deprecated
5226 * @hide
5227 */
5228 @Deprecated
5229 public Object getExtra(String name) {
5230 return getExtra(name, null);
5231 }
5232
5233 /**
5234 * Retrieve extended data from the intent.
5235 *
5236 * @param name The name of the desired item.
5237 * @param defaultValue the value to be returned if no value of the desired
5238 * type is stored with the given name.
5239 *
5240 * @return the value of an item that previously added with putExtra()
5241 * or the default value if none was found.
5242 *
5243 * @see #putExtra(String, boolean)
5244 */
5245 public boolean getBooleanExtra(String name, boolean defaultValue) {
5246 return mExtras == null ? defaultValue :
5247 mExtras.getBoolean(name, defaultValue);
5248 }
5249
5250 /**
5251 * Retrieve extended data from the intent.
5252 *
5253 * @param name The name of the desired item.
5254 * @param defaultValue the value to be returned if no value of the desired
5255 * type is stored with the given name.
5256 *
5257 * @return the value of an item that previously added with putExtra()
5258 * or the default value if none was found.
5259 *
5260 * @see #putExtra(String, byte)
5261 */
5262 public byte getByteExtra(String name, byte defaultValue) {
5263 return mExtras == null ? defaultValue :
5264 mExtras.getByte(name, defaultValue);
5265 }
5266
5267 /**
5268 * Retrieve extended data from the intent.
5269 *
5270 * @param name The name of the desired item.
5271 * @param defaultValue the value to be returned if no value of the desired
5272 * type is stored with the given name.
5273 *
5274 * @return the value of an item that previously added with putExtra()
5275 * or the default value if none was found.
5276 *
5277 * @see #putExtra(String, short)
5278 */
5279 public short getShortExtra(String name, short defaultValue) {
5280 return mExtras == null ? defaultValue :
5281 mExtras.getShort(name, defaultValue);
5282 }
5283
5284 /**
5285 * Retrieve extended data from the intent.
5286 *
5287 * @param name The name of the desired item.
5288 * @param defaultValue the value to be returned if no value of the desired
5289 * type is stored with the given name.
5290 *
5291 * @return the value of an item that previously added with putExtra()
5292 * or the default value if none was found.
5293 *
5294 * @see #putExtra(String, char)
5295 */
5296 public char getCharExtra(String name, char defaultValue) {
5297 return mExtras == null ? defaultValue :
5298 mExtras.getChar(name, defaultValue);
5299 }
5300
5301 /**
5302 * Retrieve extended data from the intent.
5303 *
5304 * @param name The name of the desired item.
5305 * @param defaultValue the value to be returned if no value of the desired
5306 * type is stored with the given name.
5307 *
5308 * @return the value of an item that previously added with putExtra()
5309 * or the default value if none was found.
5310 *
5311 * @see #putExtra(String, int)
5312 */
5313 public int getIntExtra(String name, int defaultValue) {
5314 return mExtras == null ? defaultValue :
5315 mExtras.getInt(name, defaultValue);
5316 }
5317
5318 /**
5319 * Retrieve extended data from the intent.
5320 *
5321 * @param name The name of the desired item.
5322 * @param defaultValue the value to be returned if no value of the desired
5323 * type is stored with the given name.
5324 *
5325 * @return the value of an item that previously added with putExtra()
5326 * or the default value if none was found.
5327 *
5328 * @see #putExtra(String, long)
5329 */
5330 public long getLongExtra(String name, long defaultValue) {
5331 return mExtras == null ? defaultValue :
5332 mExtras.getLong(name, defaultValue);
5333 }
5334
5335 /**
5336 * Retrieve extended data from the intent.
5337 *
5338 * @param name The name of the desired item.
5339 * @param defaultValue the value to be returned if no value of the desired
5340 * type is stored with the given name.
5341 *
5342 * @return the value of an item that previously added with putExtra(),
5343 * or the default value if no such item is present
5344 *
5345 * @see #putExtra(String, float)
5346 */
5347 public float getFloatExtra(String name, float defaultValue) {
5348 return mExtras == null ? defaultValue :
5349 mExtras.getFloat(name, defaultValue);
5350 }
5351
5352 /**
5353 * Retrieve extended data from the intent.
5354 *
5355 * @param name The name of the desired item.
5356 * @param defaultValue the value to be returned if no value of the desired
5357 * type is stored with the given name.
5358 *
5359 * @return the value of an item that previously added with putExtra()
5360 * or the default value if none was found.
5361 *
5362 * @see #putExtra(String, double)
5363 */
5364 public double getDoubleExtra(String name, double defaultValue) {
5365 return mExtras == null ? defaultValue :
5366 mExtras.getDouble(name, defaultValue);
5367 }
5368
5369 /**
5370 * Retrieve extended data from the intent.
5371 *
5372 * @param name The name of the desired item.
5373 *
5374 * @return the value of an item that previously added with putExtra()
5375 * or null if no String value was found.
5376 *
5377 * @see #putExtra(String, String)
5378 */
5379 public String getStringExtra(String name) {
5380 return mExtras == null ? null : mExtras.getString(name);
5381 }
5382
5383 /**
5384 * Retrieve extended data from the intent.
5385 *
5386 * @param name The name of the desired item.
5387 *
5388 * @return the value of an item that previously added with putExtra()
5389 * or null if no CharSequence value was found.
5390 *
5391 * @see #putExtra(String, CharSequence)
5392 */
5393 public CharSequence getCharSequenceExtra(String name) {
5394 return mExtras == null ? null : mExtras.getCharSequence(name);
5395 }
5396
5397 /**
5398 * Retrieve extended data from the intent.
5399 *
5400 * @param name The name of the desired item.
5401 *
5402 * @return the value of an item that previously added with putExtra()
5403 * or null if no Parcelable value was found.
5404 *
5405 * @see #putExtra(String, Parcelable)
5406 */
5407 public <T extends Parcelable> T getParcelableExtra(String name) {
5408 return mExtras == null ? null : mExtras.<T>getParcelable(name);
5409 }
5410
5411 /**
5412 * Retrieve extended data from the intent.
5413 *
5414 * @param name The name of the desired item.
5415 *
5416 * @return the value of an item that previously added with putExtra()
5417 * or null if no Parcelable[] value was found.
5418 *
5419 * @see #putExtra(String, Parcelable[])
5420 */
5421 public Parcelable[] getParcelableArrayExtra(String name) {
5422 return mExtras == null ? null : mExtras.getParcelableArray(name);
5423 }
5424
5425 /**
5426 * Retrieve extended data from the intent.
5427 *
5428 * @param name The name of the desired item.
5429 *
5430 * @return the value of an item that previously added with putExtra()
5431 * or null if no ArrayList<Parcelable> value was found.
5432 *
5433 * @see #putParcelableArrayListExtra(String, ArrayList)
5434 */
5435 public <T extends Parcelable> ArrayList<T> getParcelableArrayListExtra(String name) {
5436 return mExtras == null ? null : mExtras.<T>getParcelableArrayList(name);
5437 }
5438
5439 /**
5440 * Retrieve extended data from the intent.
5441 *
5442 * @param name The name of the desired item.
5443 *
5444 * @return the value of an item that previously added with putExtra()
5445 * or null if no Serializable value was found.
5446 *
5447 * @see #putExtra(String, Serializable)
5448 */
5449 public Serializable getSerializableExtra(String name) {
5450 return mExtras == null ? null : mExtras.getSerializable(name);
5451 }
5452
5453 /**
5454 * Retrieve extended data from the intent.
5455 *
5456 * @param name The name of the desired item.
5457 *
5458 * @return the value of an item that previously added with putExtra()
5459 * or null if no ArrayList<Integer> value was found.
5460 *
5461 * @see #putIntegerArrayListExtra(String, ArrayList)
5462 */
5463 public ArrayList<Integer> getIntegerArrayListExtra(String name) {
5464 return mExtras == null ? null : mExtras.getIntegerArrayList(name);
5465 }
5466
5467 /**
5468 * Retrieve extended data from the intent.
5469 *
5470 * @param name The name of the desired item.
5471 *
5472 * @return the value of an item that previously added with putExtra()
5473 * or null if no ArrayList<String> value was found.
5474 *
5475 * @see #putStringArrayListExtra(String, ArrayList)
5476 */
5477 public ArrayList<String> getStringArrayListExtra(String name) {
5478 return mExtras == null ? null : mExtras.getStringArrayList(name);
5479 }
5480
5481 /**
5482 * Retrieve extended data from the intent.
5483 *
5484 * @param name The name of the desired item.
5485 *
5486 * @return the value of an item that previously added with putExtra()
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00005487 * or null if no ArrayList<CharSequence> value was found.
5488 *
5489 * @see #putCharSequenceArrayListExtra(String, ArrayList)
5490 */
5491 public ArrayList<CharSequence> getCharSequenceArrayListExtra(String name) {
5492 return mExtras == null ? null : mExtras.getCharSequenceArrayList(name);
5493 }
5494
5495 /**
5496 * Retrieve extended data from the intent.
5497 *
5498 * @param name The name of the desired item.
5499 *
5500 * @return the value of an item that previously added with putExtra()
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005501 * or null if no boolean array value was found.
5502 *
5503 * @see #putExtra(String, boolean[])
5504 */
5505 public boolean[] getBooleanArrayExtra(String name) {
5506 return mExtras == null ? null : mExtras.getBooleanArray(name);
5507 }
5508
5509 /**
5510 * Retrieve extended data from the intent.
5511 *
5512 * @param name The name of the desired item.
5513 *
5514 * @return the value of an item that previously added with putExtra()
5515 * or null if no byte array value was found.
5516 *
5517 * @see #putExtra(String, byte[])
5518 */
5519 public byte[] getByteArrayExtra(String name) {
5520 return mExtras == null ? null : mExtras.getByteArray(name);
5521 }
5522
5523 /**
5524 * Retrieve extended data from the intent.
5525 *
5526 * @param name The name of the desired item.
5527 *
5528 * @return the value of an item that previously added with putExtra()
5529 * or null if no short array value was found.
5530 *
5531 * @see #putExtra(String, short[])
5532 */
5533 public short[] getShortArrayExtra(String name) {
5534 return mExtras == null ? null : mExtras.getShortArray(name);
5535 }
5536
5537 /**
5538 * Retrieve extended data from the intent.
5539 *
5540 * @param name The name of the desired item.
5541 *
5542 * @return the value of an item that previously added with putExtra()
5543 * or null if no char array value was found.
5544 *
5545 * @see #putExtra(String, char[])
5546 */
5547 public char[] getCharArrayExtra(String name) {
5548 return mExtras == null ? null : mExtras.getCharArray(name);
5549 }
5550
5551 /**
5552 * Retrieve extended data from the intent.
5553 *
5554 * @param name The name of the desired item.
5555 *
5556 * @return the value of an item that previously added with putExtra()
5557 * or null if no int array value was found.
5558 *
5559 * @see #putExtra(String, int[])
5560 */
5561 public int[] getIntArrayExtra(String name) {
5562 return mExtras == null ? null : mExtras.getIntArray(name);
5563 }
5564
5565 /**
5566 * Retrieve extended data from the intent.
5567 *
5568 * @param name The name of the desired item.
5569 *
5570 * @return the value of an item that previously added with putExtra()
5571 * or null if no long array value was found.
5572 *
5573 * @see #putExtra(String, long[])
5574 */
5575 public long[] getLongArrayExtra(String name) {
5576 return mExtras == null ? null : mExtras.getLongArray(name);
5577 }
5578
5579 /**
5580 * Retrieve extended data from the intent.
5581 *
5582 * @param name The name of the desired item.
5583 *
5584 * @return the value of an item that previously added with putExtra()
5585 * or null if no float array value was found.
5586 *
5587 * @see #putExtra(String, float[])
5588 */
5589 public float[] getFloatArrayExtra(String name) {
5590 return mExtras == null ? null : mExtras.getFloatArray(name);
5591 }
5592
5593 /**
5594 * Retrieve extended data from the intent.
5595 *
5596 * @param name The name of the desired item.
5597 *
5598 * @return the value of an item that previously added with putExtra()
5599 * or null if no double array value was found.
5600 *
5601 * @see #putExtra(String, double[])
5602 */
5603 public double[] getDoubleArrayExtra(String name) {
5604 return mExtras == null ? null : mExtras.getDoubleArray(name);
5605 }
5606
5607 /**
5608 * Retrieve extended data from the intent.
5609 *
5610 * @param name The name of the desired item.
5611 *
5612 * @return the value of an item that previously added with putExtra()
5613 * or null if no String array value was found.
5614 *
5615 * @see #putExtra(String, String[])
5616 */
5617 public String[] getStringArrayExtra(String name) {
5618 return mExtras == null ? null : mExtras.getStringArray(name);
5619 }
5620
5621 /**
5622 * Retrieve extended data from the intent.
5623 *
5624 * @param name The name of the desired item.
5625 *
5626 * @return the value of an item that previously added with putExtra()
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00005627 * or null if no CharSequence array value was found.
5628 *
5629 * @see #putExtra(String, CharSequence[])
5630 */
5631 public CharSequence[] getCharSequenceArrayExtra(String name) {
5632 return mExtras == null ? null : mExtras.getCharSequenceArray(name);
5633 }
5634
5635 /**
5636 * Retrieve extended data from the intent.
5637 *
5638 * @param name The name of the desired item.
5639 *
5640 * @return the value of an item that previously added with putExtra()
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005641 * or null if no Bundle value was found.
5642 *
5643 * @see #putExtra(String, Bundle)
5644 */
5645 public Bundle getBundleExtra(String name) {
5646 return mExtras == null ? null : mExtras.getBundle(name);
5647 }
5648
5649 /**
5650 * Retrieve extended data from the intent.
5651 *
5652 * @param name The name of the desired item.
5653 *
5654 * @return the value of an item that previously added with putExtra()
5655 * or null if no IBinder value was found.
5656 *
5657 * @see #putExtra(String, IBinder)
5658 *
5659 * @deprecated
5660 * @hide
5661 */
5662 @Deprecated
5663 public IBinder getIBinderExtra(String name) {
5664 return mExtras == null ? null : mExtras.getIBinder(name);
5665 }
5666
5667 /**
5668 * Retrieve extended data from the intent.
5669 *
5670 * @param name The name of the desired item.
5671 * @param defaultValue The default value to return in case no item is
5672 * associated with the key 'name'
5673 *
5674 * @return the value of an item that previously added with putExtra()
5675 * or defaultValue if none was found.
5676 *
5677 * @see #putExtra
5678 *
5679 * @deprecated
5680 * @hide
5681 */
5682 @Deprecated
5683 public Object getExtra(String name, Object defaultValue) {
5684 Object result = defaultValue;
5685 if (mExtras != null) {
5686 Object result2 = mExtras.get(name);
5687 if (result2 != null) {
5688 result = result2;
5689 }
5690 }
5691
5692 return result;
5693 }
5694
5695 /**
5696 * Retrieves a map of extended data from the intent.
5697 *
5698 * @return the map of all extras previously added with putExtra(),
5699 * or null if none have been added.
5700 */
5701 public Bundle getExtras() {
5702 return (mExtras != null)
5703 ? new Bundle(mExtras)
5704 : null;
5705 }
5706
5707 /**
Dianne Hackborna83ce1d2015-03-11 15:16:13 -07005708 * Filter extras to only basic types.
5709 * @hide
5710 */
5711 public void removeUnsafeExtras() {
5712 if (mExtras != null) {
5713 mExtras.filterValues();
5714 }
5715 }
5716
5717 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005718 * Retrieve any special flags associated with this intent. You will
5719 * normally just set them with {@link #setFlags} and let the system
5720 * take the appropriate action with them.
5721 *
5722 * @return int The currently set flags.
5723 *
5724 * @see #setFlags
5725 */
5726 public int getFlags() {
5727 return mFlags;
5728 }
5729
Dianne Hackborne7f97212011-02-24 14:40:20 -08005730 /** @hide */
5731 public boolean isExcludingStopped() {
5732 return (mFlags&(FLAG_EXCLUDE_STOPPED_PACKAGES|FLAG_INCLUDE_STOPPED_PACKAGES))
5733 == FLAG_EXCLUDE_STOPPED_PACKAGES;
5734 }
5735
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005736 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005737 * Retrieve the application package name this Intent is limited to. When
5738 * resolving an Intent, if non-null this limits the resolution to only
5739 * components in the given application package.
5740 *
5741 * @return The name of the application package for the Intent.
5742 *
5743 * @see #resolveActivity
5744 * @see #setPackage
5745 */
5746 public String getPackage() {
5747 return mPackage;
5748 }
5749
5750 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005751 * Retrieve the concrete component associated with the intent. When receiving
5752 * an intent, this is the component that was found to best handle it (that is,
5753 * yourself) and will always be non-null; in all other cases it will be
5754 * null unless explicitly set.
5755 *
5756 * @return The name of the application component to handle the intent.
5757 *
5758 * @see #resolveActivity
5759 * @see #setComponent
5760 */
5761 public ComponentName getComponent() {
5762 return mComponent;
5763 }
5764
5765 /**
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08005766 * Get the bounds of the sender of this intent, in screen coordinates. This can be
5767 * used as a hint to the receiver for animations and the like. Null means that there
5768 * is no source bounds.
5769 */
5770 public Rect getSourceBounds() {
5771 return mSourceBounds;
5772 }
5773
5774 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005775 * Return the Activity component that should be used to handle this intent.
5776 * The appropriate component is determined based on the information in the
5777 * intent, evaluated as follows:
5778 *
5779 * <p>If {@link #getComponent} returns an explicit class, that is returned
5780 * without any further consideration.
5781 *
5782 * <p>The activity must handle the {@link Intent#CATEGORY_DEFAULT} Intent
5783 * category to be considered.
5784 *
5785 * <p>If {@link #getAction} is non-NULL, the activity must handle this
5786 * action.
5787 *
5788 * <p>If {@link #resolveType} returns non-NULL, the activity must handle
5789 * this type.
5790 *
5791 * <p>If {@link #addCategory} has added any categories, the activity must
5792 * handle ALL of the categories specified.
5793 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005794 * <p>If {@link #getPackage} is non-NULL, only activity components in
5795 * that application package will be considered.
5796 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005797 * <p>If there are no activities that satisfy all of these conditions, a
5798 * null string is returned.
5799 *
5800 * <p>If multiple activities are found to satisfy the intent, the one with
5801 * the highest priority will be used. If there are multiple activities
5802 * with the same priority, the system will either pick the best activity
5803 * based on user preference, or resolve to a system class that will allow
5804 * the user to pick an activity and forward from there.
5805 *
5806 * <p>This method is implemented simply by calling
5807 * {@link PackageManager#resolveActivity} with the "defaultOnly" parameter
5808 * true.</p>
5809 * <p> This API is called for you as part of starting an activity from an
5810 * intent. You do not normally need to call it yourself.</p>
5811 *
5812 * @param pm The package manager with which to resolve the Intent.
5813 *
5814 * @return Name of the component implementing an activity that can
5815 * display the intent.
5816 *
5817 * @see #setComponent
5818 * @see #getComponent
5819 * @see #resolveActivityInfo
5820 */
5821 public ComponentName resolveActivity(PackageManager pm) {
5822 if (mComponent != null) {
5823 return mComponent;
5824 }
5825
5826 ResolveInfo info = pm.resolveActivity(
5827 this, PackageManager.MATCH_DEFAULT_ONLY);
5828 if (info != null) {
5829 return new ComponentName(
5830 info.activityInfo.applicationInfo.packageName,
5831 info.activityInfo.name);
5832 }
5833
5834 return null;
5835 }
5836
5837 /**
5838 * Resolve the Intent into an {@link ActivityInfo}
5839 * describing the activity that should execute the intent. Resolution
5840 * follows the same rules as described for {@link #resolveActivity}, but
5841 * you get back the completely information about the resolved activity
5842 * instead of just its class name.
5843 *
5844 * @param pm The package manager with which to resolve the Intent.
5845 * @param flags Addition information to retrieve as per
5846 * {@link PackageManager#getActivityInfo(ComponentName, int)
5847 * PackageManager.getActivityInfo()}.
5848 *
5849 * @return PackageManager.ActivityInfo
5850 *
5851 * @see #resolveActivity
5852 */
5853 public ActivityInfo resolveActivityInfo(PackageManager pm, int flags) {
5854 ActivityInfo ai = null;
5855 if (mComponent != null) {
5856 try {
5857 ai = pm.getActivityInfo(mComponent, flags);
5858 } catch (PackageManager.NameNotFoundException e) {
5859 // ignore
5860 }
5861 } else {
5862 ResolveInfo info = pm.resolveActivity(
Dianne Hackborn9bfb7072009-09-22 11:37:40 -07005863 this, PackageManager.MATCH_DEFAULT_ONLY | flags);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005864 if (info != null) {
5865 ai = info.activityInfo;
5866 }
5867 }
5868
5869 return ai;
5870 }
5871
5872 /**
Dianne Hackborn221ea892013-08-04 16:50:16 -07005873 * Special function for use by the system to resolve service
5874 * intents to system apps. Throws an exception if there are
5875 * multiple potential matches to the Intent. Returns null if
5876 * there are no matches.
5877 * @hide
5878 */
5879 public ComponentName resolveSystemService(PackageManager pm, int flags) {
5880 if (mComponent != null) {
5881 return mComponent;
5882 }
5883
5884 List<ResolveInfo> results = pm.queryIntentServices(this, flags);
5885 if (results == null) {
5886 return null;
5887 }
5888 ComponentName comp = null;
5889 for (int i=0; i<results.size(); i++) {
5890 ResolveInfo ri = results.get(i);
5891 if ((ri.serviceInfo.applicationInfo.flags&ApplicationInfo.FLAG_SYSTEM) == 0) {
5892 continue;
5893 }
5894 ComponentName foundComp = new ComponentName(ri.serviceInfo.applicationInfo.packageName,
5895 ri.serviceInfo.name);
5896 if (comp != null) {
5897 throw new IllegalStateException("Multiple system services handle " + this
5898 + ": " + comp + ", " + foundComp);
5899 }
5900 comp = foundComp;
5901 }
5902 return comp;
5903 }
5904
5905 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005906 * Set the general action to be performed.
5907 *
5908 * @param action An action name, such as ACTION_VIEW. Application-specific
5909 * actions should be prefixed with the vendor's package name.
5910 *
5911 * @return Returns the same Intent object, for chaining multiple calls
5912 * into a single statement.
5913 *
5914 * @see #getAction
5915 */
5916 public Intent setAction(String action) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08005917 mAction = action != null ? action.intern() : null;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005918 return this;
5919 }
5920
5921 /**
5922 * Set the data this intent is operating on. This method automatically
Nick Pellyccae4122012-01-09 14:12:58 -08005923 * clears any type that was previously set by {@link #setType} or
5924 * {@link #setTypeAndNormalize}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005925 *
Nick Pellyccae4122012-01-09 14:12:58 -08005926 * <p><em>Note: scheme matching in the Android framework is
5927 * case-sensitive, unlike the formal RFC. As a result,
5928 * you should always write your Uri with a lower case scheme,
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04005929 * or use {@link Uri#normalizeScheme} or
Nick Pellyccae4122012-01-09 14:12:58 -08005930 * {@link #setDataAndNormalize}
5931 * to ensure that the scheme is converted to lower case.</em>
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07005932 *
Nick Pellyccae4122012-01-09 14:12:58 -08005933 * @param data The Uri of the data this intent is now targeting.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005934 *
5935 * @return Returns the same Intent object, for chaining multiple calls
5936 * into a single statement.
5937 *
5938 * @see #getData
Nick Pellyccae4122012-01-09 14:12:58 -08005939 * @see #setDataAndNormalize
Dianne Hackborn221ea892013-08-04 16:50:16 -07005940 * @see android.net.Uri#normalizeScheme()
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005941 */
5942 public Intent setData(Uri data) {
5943 mData = data;
5944 mType = null;
5945 return this;
5946 }
5947
5948 /**
Nick Pellyccae4122012-01-09 14:12:58 -08005949 * Normalize and set the data this intent is operating on.
5950 *
5951 * <p>This method automatically clears any type that was
5952 * previously set (for example, by {@link #setType}).
5953 *
5954 * <p>The data Uri is normalized using
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04005955 * {@link android.net.Uri#normalizeScheme} before it is set,
Nick Pellyccae4122012-01-09 14:12:58 -08005956 * so really this is just a convenience method for
5957 * <pre>
5958 * setData(data.normalize())
5959 * </pre>
5960 *
5961 * @param data The Uri of the data this intent is now targeting.
5962 *
5963 * @return Returns the same Intent object, for chaining multiple calls
5964 * into a single statement.
5965 *
5966 * @see #getData
5967 * @see #setType
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04005968 * @see android.net.Uri#normalizeScheme
Nick Pellyccae4122012-01-09 14:12:58 -08005969 */
5970 public Intent setDataAndNormalize(Uri data) {
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04005971 return setData(data.normalizeScheme());
Nick Pellyccae4122012-01-09 14:12:58 -08005972 }
5973
5974 /**
5975 * Set an explicit MIME data type.
5976 *
5977 * <p>This is used to create intents that only specify a type and not data,
5978 * for example to indicate the type of data to return.
5979 *
5980 * <p>This method automatically clears any data that was
5981 * previously set (for example by {@link #setData}).
Romain Guy4969af72009-06-17 10:53:19 -07005982 *
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07005983 * <p><em>Note: MIME type matching in the Android framework is
5984 * case-sensitive, unlike formal RFC MIME types. As a result,
5985 * you should always write your MIME types with lower case letters,
Nick Pellyccae4122012-01-09 14:12:58 -08005986 * or use {@link #normalizeMimeType} or {@link #setTypeAndNormalize}
5987 * to ensure that it is converted to lower case.</em>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005988 *
5989 * @param type The MIME type of the data being handled by this intent.
5990 *
5991 * @return Returns the same Intent object, for chaining multiple calls
5992 * into a single statement.
5993 *
5994 * @see #getType
Nick Pellyccae4122012-01-09 14:12:58 -08005995 * @see #setTypeAndNormalize
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005996 * @see #setDataAndType
Nick Pellyccae4122012-01-09 14:12:58 -08005997 * @see #normalizeMimeType
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005998 */
5999 public Intent setType(String type) {
6000 mData = null;
6001 mType = type;
6002 return this;
6003 }
6004
6005 /**
Nick Pellyccae4122012-01-09 14:12:58 -08006006 * Normalize and set an explicit MIME data type.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006007 *
Nick Pellyccae4122012-01-09 14:12:58 -08006008 * <p>This is used to create intents that only specify a type and not data,
6009 * for example to indicate the type of data to return.
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07006010 *
Nick Pellyccae4122012-01-09 14:12:58 -08006011 * <p>This method automatically clears any data that was
6012 * previously set (for example by {@link #setData}).
6013 *
6014 * <p>The MIME type is normalized using
6015 * {@link #normalizeMimeType} before it is set,
6016 * so really this is just a convenience method for
6017 * <pre>
6018 * setType(Intent.normalizeMimeType(type))
6019 * </pre>
6020 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006021 * @param type The MIME type of the data being handled by this intent.
6022 *
6023 * @return Returns the same Intent object, for chaining multiple calls
6024 * into a single statement.
6025 *
Nick Pellyccae4122012-01-09 14:12:58 -08006026 * @see #getType
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006027 * @see #setData
Nick Pellyccae4122012-01-09 14:12:58 -08006028 * @see #normalizeMimeType
6029 */
6030 public Intent setTypeAndNormalize(String type) {
6031 return setType(normalizeMimeType(type));
6032 }
6033
6034 /**
6035 * (Usually optional) Set the data for the intent along with an explicit
6036 * MIME data type. This method should very rarely be used -- it allows you
6037 * to override the MIME type that would ordinarily be inferred from the
6038 * data with your own type given here.
6039 *
6040 * <p><em>Note: MIME type and Uri scheme matching in the
6041 * Android framework is case-sensitive, unlike the formal RFC definitions.
6042 * As a result, you should always write these elements with lower case letters,
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04006043 * or use {@link #normalizeMimeType} or {@link android.net.Uri#normalizeScheme} or
Nick Pellyccae4122012-01-09 14:12:58 -08006044 * {@link #setDataAndTypeAndNormalize}
6045 * to ensure that they are converted to lower case.</em>
6046 *
6047 * @param data The Uri of the data this intent is now targeting.
6048 * @param type The MIME type of the data being handled by this intent.
6049 *
6050 * @return Returns the same Intent object, for chaining multiple calls
6051 * into a single statement.
6052 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006053 * @see #setType
Nick Pellyccae4122012-01-09 14:12:58 -08006054 * @see #setData
6055 * @see #normalizeMimeType
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04006056 * @see android.net.Uri#normalizeScheme
Nick Pellyccae4122012-01-09 14:12:58 -08006057 * @see #setDataAndTypeAndNormalize
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006058 */
6059 public Intent setDataAndType(Uri data, String type) {
6060 mData = data;
6061 mType = type;
6062 return this;
6063 }
6064
6065 /**
Nick Pellyccae4122012-01-09 14:12:58 -08006066 * (Usually optional) Normalize and set both the data Uri and an explicit
6067 * MIME data type. This method should very rarely be used -- it allows you
6068 * to override the MIME type that would ordinarily be inferred from the
6069 * data with your own type given here.
6070 *
6071 * <p>The data Uri and the MIME type are normalize using
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04006072 * {@link android.net.Uri#normalizeScheme} and {@link #normalizeMimeType}
Nick Pellyccae4122012-01-09 14:12:58 -08006073 * before they are set, so really this is just a convenience method for
6074 * <pre>
6075 * setDataAndType(data.normalize(), Intent.normalizeMimeType(type))
6076 * </pre>
6077 *
6078 * @param data The Uri of the data this intent is now targeting.
6079 * @param type The MIME type of the data being handled by this intent.
6080 *
6081 * @return Returns the same Intent object, for chaining multiple calls
6082 * into a single statement.
6083 *
6084 * @see #setType
6085 * @see #setData
6086 * @see #setDataAndType
6087 * @see #normalizeMimeType
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04006088 * @see android.net.Uri#normalizeScheme
Nick Pellyccae4122012-01-09 14:12:58 -08006089 */
6090 public Intent setDataAndTypeAndNormalize(Uri data, String type) {
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04006091 return setDataAndType(data.normalizeScheme(), normalizeMimeType(type));
Nick Pellyccae4122012-01-09 14:12:58 -08006092 }
6093
6094 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006095 * Add a new category to the intent. Categories provide additional detail
Ken Wakasaf76a50c2012-03-09 19:56:35 +09006096 * about the action the intent performs. When resolving an intent, only
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006097 * activities that provide <em>all</em> of the requested categories will be
6098 * used.
6099 *
6100 * @param category The desired category. This can be either one of the
6101 * predefined Intent categories, or a custom category in your own
6102 * namespace.
6103 *
6104 * @return Returns the same Intent object, for chaining multiple calls
6105 * into a single statement.
6106 *
6107 * @see #hasCategory
6108 * @see #removeCategory
6109 */
6110 public Intent addCategory(String category) {
6111 if (mCategories == null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07006112 mCategories = new ArraySet<String>();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006113 }
Jeff Brown2c376fc2011-01-28 17:34:01 -08006114 mCategories.add(category.intern());
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006115 return this;
6116 }
6117
6118 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09006119 * Remove a category from an intent.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006120 *
6121 * @param category The category to remove.
6122 *
6123 * @see #addCategory
6124 */
6125 public void removeCategory(String category) {
6126 if (mCategories != null) {
6127 mCategories.remove(category);
6128 if (mCategories.size() == 0) {
6129 mCategories = null;
6130 }
6131 }
6132 }
6133
6134 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08006135 * Set a selector for this Intent. This is a modification to the kinds of
6136 * things the Intent will match. If the selector is set, it will be used
6137 * when trying to find entities that can handle the Intent, instead of the
6138 * main contents of the Intent. This allows you build an Intent containing
6139 * a generic protocol while targeting it more specifically.
6140 *
6141 * <p>An example of where this may be used is with things like
6142 * {@link #CATEGORY_APP_BROWSER}. This category allows you to build an
6143 * Intent that will launch the Browser application. However, the correct
6144 * main entry point of an application is actually {@link #ACTION_MAIN}
6145 * {@link #CATEGORY_LAUNCHER} with {@link #setComponent(ComponentName)}
6146 * used to specify the actual Activity to launch. If you launch the browser
6147 * with something different, undesired behavior may happen if the user has
6148 * previously or later launches it the normal way, since they do not match.
6149 * Instead, you can build an Intent with the MAIN action (but no ComponentName
6150 * yet specified) and set a selector with {@link #ACTION_MAIN} and
6151 * {@link #CATEGORY_APP_BROWSER} to point it specifically to the browser activity.
6152 *
6153 * <p>Setting a selector does not impact the behavior of
6154 * {@link #filterEquals(Intent)} and {@link #filterHashCode()}. This is part of the
6155 * desired behavior of a selector -- it does not impact the base meaning
6156 * of the Intent, just what kinds of things will be matched against it
6157 * when determining who can handle it.</p>
6158 *
6159 * <p>You can not use both a selector and {@link #setPackage(String)} on
6160 * the same base Intent.</p>
6161 *
6162 * @param selector The desired selector Intent; set to null to not use
6163 * a special selector.
6164 */
6165 public void setSelector(Intent selector) {
6166 if (selector == this) {
6167 throw new IllegalArgumentException(
6168 "Intent being set as a selector of itself");
6169 }
6170 if (selector != null && mPackage != null) {
6171 throw new IllegalArgumentException(
6172 "Can't set selector when package name is already set");
6173 }
6174 mSelector = selector;
6175 }
6176
6177 /**
Dianne Hackborn21c241e2012-03-08 13:57:23 -08006178 * Set a {@link ClipData} associated with this Intent. This replaces any
6179 * previously set ClipData.
6180 *
6181 * <p>The ClipData in an intent is not used for Intent matching or other
6182 * such operations. Semantically it is like extras, used to transmit
6183 * additional data with the Intent. The main feature of using this over
6184 * the extras for data is that {@link #FLAG_GRANT_READ_URI_PERMISSION}
6185 * and {@link #FLAG_GRANT_WRITE_URI_PERMISSION} will operate on any URI
6186 * items included in the clip data. This is useful, in particular, if
6187 * you want to transmit an Intent containing multiple <code>content:</code>
6188 * URIs for which the recipient may not have global permission to access the
6189 * content provider.
6190 *
6191 * <p>If the ClipData contains items that are themselves Intents, any
6192 * grant flags in those Intents will be ignored. Only the top-level flags
6193 * of the main Intent are respected, and will be applied to all Uri or
6194 * Intent items in the clip (or sub-items of the clip).
6195 *
6196 * <p>The MIME type, label, and icon in the ClipData object are not
6197 * directly used by Intent. Applications should generally rely on the
6198 * MIME type of the Intent itself, not what it may find in the ClipData.
6199 * A common practice is to construct a ClipData for use with an Intent
John Spurlock33900182014-01-02 11:04:18 -05006200 * with a MIME type of "*&#47;*".
Dianne Hackborn21c241e2012-03-08 13:57:23 -08006201 *
6202 * @param clip The new clip to set. May be null to clear the current clip.
6203 */
6204 public void setClipData(ClipData clip) {
6205 mClipData = clip;
6206 }
6207
6208 /**
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01006209 * This is NOT a secure mechanism to identify the user who sent the intent.
6210 * When the intent is sent to a different user, it is used to fix uris by adding the userId
6211 * who sent the intent.
6212 * @hide
6213 */
Nicolas Prevot107f7b72015-07-01 16:31:48 +01006214 public void prepareToLeaveUser(int userId) {
6215 // If mContentUserHint is not UserHandle.USER_CURRENT, the intent has already left a user.
6216 // We want mContentUserHint to refer to the original user, so don't do anything.
6217 if (mContentUserHint == UserHandle.USER_CURRENT) {
6218 mContentUserHint = userId;
6219 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01006220 }
6221
6222 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006223 * Add extended data to the intent. The name must include a package
6224 * prefix, for example the app com.android.contacts would use names
6225 * like "com.android.contacts.ShowAll".
6226 *
6227 * @param name The name of the extra data, with package prefix.
6228 * @param value The boolean data value.
6229 *
6230 * @return Returns the same Intent object, for chaining multiple calls
6231 * into a single statement.
6232 *
6233 * @see #putExtras
6234 * @see #removeExtra
6235 * @see #getBooleanExtra(String, boolean)
6236 */
6237 public Intent putExtra(String name, boolean value) {
6238 if (mExtras == null) {
6239 mExtras = new Bundle();
6240 }
6241 mExtras.putBoolean(name, value);
6242 return this;
6243 }
6244
6245 /**
6246 * Add extended data to the intent. The name must include a package
6247 * prefix, for example the app com.android.contacts would use names
6248 * like "com.android.contacts.ShowAll".
6249 *
6250 * @param name The name of the extra data, with package prefix.
6251 * @param value The byte data value.
6252 *
6253 * @return Returns the same Intent object, for chaining multiple calls
6254 * into a single statement.
6255 *
6256 * @see #putExtras
6257 * @see #removeExtra
6258 * @see #getByteExtra(String, byte)
6259 */
6260 public Intent putExtra(String name, byte value) {
6261 if (mExtras == null) {
6262 mExtras = new Bundle();
6263 }
6264 mExtras.putByte(name, value);
6265 return this;
6266 }
6267
6268 /**
6269 * Add extended data to the intent. The name must include a package
6270 * prefix, for example the app com.android.contacts would use names
6271 * like "com.android.contacts.ShowAll".
6272 *
6273 * @param name The name of the extra data, with package prefix.
6274 * @param value The char data value.
6275 *
6276 * @return Returns the same Intent object, for chaining multiple calls
6277 * into a single statement.
6278 *
6279 * @see #putExtras
6280 * @see #removeExtra
6281 * @see #getCharExtra(String, char)
6282 */
6283 public Intent putExtra(String name, char value) {
6284 if (mExtras == null) {
6285 mExtras = new Bundle();
6286 }
6287 mExtras.putChar(name, value);
6288 return this;
6289 }
6290
6291 /**
6292 * Add extended data to the intent. The name must include a package
6293 * prefix, for example the app com.android.contacts would use names
6294 * like "com.android.contacts.ShowAll".
6295 *
6296 * @param name The name of the extra data, with package prefix.
6297 * @param value The short data value.
6298 *
6299 * @return Returns the same Intent object, for chaining multiple calls
6300 * into a single statement.
6301 *
6302 * @see #putExtras
6303 * @see #removeExtra
6304 * @see #getShortExtra(String, short)
6305 */
6306 public Intent putExtra(String name, short value) {
6307 if (mExtras == null) {
6308 mExtras = new Bundle();
6309 }
6310 mExtras.putShort(name, value);
6311 return this;
6312 }
6313
6314 /**
6315 * Add extended data to the intent. The name must include a package
6316 * prefix, for example the app com.android.contacts would use names
6317 * like "com.android.contacts.ShowAll".
6318 *
6319 * @param name The name of the extra data, with package prefix.
6320 * @param value The integer data value.
6321 *
6322 * @return Returns the same Intent object, for chaining multiple calls
6323 * into a single statement.
6324 *
6325 * @see #putExtras
6326 * @see #removeExtra
6327 * @see #getIntExtra(String, int)
6328 */
6329 public Intent putExtra(String name, int value) {
6330 if (mExtras == null) {
6331 mExtras = new Bundle();
6332 }
6333 mExtras.putInt(name, value);
6334 return this;
6335 }
6336
6337 /**
6338 * Add extended data to the intent. The name must include a package
6339 * prefix, for example the app com.android.contacts would use names
6340 * like "com.android.contacts.ShowAll".
6341 *
6342 * @param name The name of the extra data, with package prefix.
6343 * @param value The long data value.
6344 *
6345 * @return Returns the same Intent object, for chaining multiple calls
6346 * into a single statement.
6347 *
6348 * @see #putExtras
6349 * @see #removeExtra
6350 * @see #getLongExtra(String, long)
6351 */
6352 public Intent putExtra(String name, long value) {
6353 if (mExtras == null) {
6354 mExtras = new Bundle();
6355 }
6356 mExtras.putLong(name, value);
6357 return this;
6358 }
6359
6360 /**
6361 * Add extended data to the intent. The name must include a package
6362 * prefix, for example the app com.android.contacts would use names
6363 * like "com.android.contacts.ShowAll".
6364 *
6365 * @param name The name of the extra data, with package prefix.
6366 * @param value The float data value.
6367 *
6368 * @return Returns the same Intent object, for chaining multiple calls
6369 * into a single statement.
6370 *
6371 * @see #putExtras
6372 * @see #removeExtra
6373 * @see #getFloatExtra(String, float)
6374 */
6375 public Intent putExtra(String name, float value) {
6376 if (mExtras == null) {
6377 mExtras = new Bundle();
6378 }
6379 mExtras.putFloat(name, value);
6380 return this;
6381 }
6382
6383 /**
6384 * Add extended data to the intent. The name must include a package
6385 * prefix, for example the app com.android.contacts would use names
6386 * like "com.android.contacts.ShowAll".
6387 *
6388 * @param name The name of the extra data, with package prefix.
6389 * @param value The double data value.
6390 *
6391 * @return Returns the same Intent object, for chaining multiple calls
6392 * into a single statement.
6393 *
6394 * @see #putExtras
6395 * @see #removeExtra
6396 * @see #getDoubleExtra(String, double)
6397 */
6398 public Intent putExtra(String name, double value) {
6399 if (mExtras == null) {
6400 mExtras = new Bundle();
6401 }
6402 mExtras.putDouble(name, value);
6403 return this;
6404 }
6405
6406 /**
6407 * Add extended data to the intent. The name must include a package
6408 * prefix, for example the app com.android.contacts would use names
6409 * like "com.android.contacts.ShowAll".
6410 *
6411 * @param name The name of the extra data, with package prefix.
6412 * @param value The String data value.
6413 *
6414 * @return Returns the same Intent object, for chaining multiple calls
6415 * into a single statement.
6416 *
6417 * @see #putExtras
6418 * @see #removeExtra
6419 * @see #getStringExtra(String)
6420 */
6421 public Intent putExtra(String name, String value) {
6422 if (mExtras == null) {
6423 mExtras = new Bundle();
6424 }
6425 mExtras.putString(name, value);
6426 return this;
6427 }
6428
6429 /**
6430 * Add extended data to the intent. The name must include a package
6431 * prefix, for example the app com.android.contacts would use names
6432 * like "com.android.contacts.ShowAll".
6433 *
6434 * @param name The name of the extra data, with package prefix.
6435 * @param value The CharSequence data value.
6436 *
6437 * @return Returns the same Intent object, for chaining multiple calls
6438 * into a single statement.
6439 *
6440 * @see #putExtras
6441 * @see #removeExtra
6442 * @see #getCharSequenceExtra(String)
6443 */
6444 public Intent putExtra(String name, CharSequence value) {
6445 if (mExtras == null) {
6446 mExtras = new Bundle();
6447 }
6448 mExtras.putCharSequence(name, value);
6449 return this;
6450 }
6451
6452 /**
6453 * Add extended data to the intent. The name must include a package
6454 * prefix, for example the app com.android.contacts would use names
6455 * like "com.android.contacts.ShowAll".
6456 *
6457 * @param name The name of the extra data, with package prefix.
6458 * @param value The Parcelable data value.
6459 *
6460 * @return Returns the same Intent object, for chaining multiple calls
6461 * into a single statement.
6462 *
6463 * @see #putExtras
6464 * @see #removeExtra
6465 * @see #getParcelableExtra(String)
6466 */
6467 public Intent putExtra(String name, Parcelable value) {
6468 if (mExtras == null) {
6469 mExtras = new Bundle();
6470 }
6471 mExtras.putParcelable(name, value);
6472 return this;
6473 }
6474
6475 /**
6476 * Add extended data to the intent. The name must include a package
6477 * prefix, for example the app com.android.contacts would use names
6478 * like "com.android.contacts.ShowAll".
6479 *
6480 * @param name The name of the extra data, with package prefix.
6481 * @param value The Parcelable[] data value.
6482 *
6483 * @return Returns the same Intent object, for chaining multiple calls
6484 * into a single statement.
6485 *
6486 * @see #putExtras
6487 * @see #removeExtra
6488 * @see #getParcelableArrayExtra(String)
6489 */
6490 public Intent putExtra(String name, Parcelable[] value) {
6491 if (mExtras == null) {
6492 mExtras = new Bundle();
6493 }
6494 mExtras.putParcelableArray(name, value);
6495 return this;
6496 }
6497
6498 /**
6499 * Add extended data to the intent. The name must include a package
6500 * prefix, for example the app com.android.contacts would use names
6501 * like "com.android.contacts.ShowAll".
6502 *
6503 * @param name The name of the extra data, with package prefix.
6504 * @param value The ArrayList<Parcelable> data value.
6505 *
6506 * @return Returns the same Intent object, for chaining multiple calls
6507 * into a single statement.
6508 *
6509 * @see #putExtras
6510 * @see #removeExtra
6511 * @see #getParcelableArrayListExtra(String)
6512 */
6513 public Intent putParcelableArrayListExtra(String name, ArrayList<? extends Parcelable> value) {
6514 if (mExtras == null) {
6515 mExtras = new Bundle();
6516 }
6517 mExtras.putParcelableArrayList(name, value);
6518 return this;
6519 }
6520
6521 /**
6522 * Add extended data to the intent. The name must include a package
6523 * prefix, for example the app com.android.contacts would use names
6524 * like "com.android.contacts.ShowAll".
6525 *
6526 * @param name The name of the extra data, with package prefix.
6527 * @param value The ArrayList<Integer> data value.
6528 *
6529 * @return Returns the same Intent object, for chaining multiple calls
6530 * into a single statement.
6531 *
6532 * @see #putExtras
6533 * @see #removeExtra
6534 * @see #getIntegerArrayListExtra(String)
6535 */
6536 public Intent putIntegerArrayListExtra(String name, ArrayList<Integer> value) {
6537 if (mExtras == null) {
6538 mExtras = new Bundle();
6539 }
6540 mExtras.putIntegerArrayList(name, value);
6541 return this;
6542 }
6543
6544 /**
6545 * Add extended data to the intent. The name must include a package
6546 * prefix, for example the app com.android.contacts would use names
6547 * like "com.android.contacts.ShowAll".
6548 *
6549 * @param name The name of the extra data, with package prefix.
6550 * @param value The ArrayList<String> data value.
6551 *
6552 * @return Returns the same Intent object, for chaining multiple calls
6553 * into a single statement.
6554 *
6555 * @see #putExtras
6556 * @see #removeExtra
6557 * @see #getStringArrayListExtra(String)
6558 */
6559 public Intent putStringArrayListExtra(String name, ArrayList<String> value) {
6560 if (mExtras == null) {
6561 mExtras = new Bundle();
6562 }
6563 mExtras.putStringArrayList(name, value);
6564 return this;
6565 }
6566
6567 /**
6568 * Add extended data to the intent. The name must include a package
6569 * prefix, for example the app com.android.contacts would use names
6570 * like "com.android.contacts.ShowAll".
6571 *
6572 * @param name The name of the extra data, with package prefix.
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00006573 * @param value The ArrayList<CharSequence> data value.
6574 *
6575 * @return Returns the same Intent object, for chaining multiple calls
6576 * into a single statement.
6577 *
6578 * @see #putExtras
6579 * @see #removeExtra
6580 * @see #getCharSequenceArrayListExtra(String)
6581 */
6582 public Intent putCharSequenceArrayListExtra(String name, ArrayList<CharSequence> value) {
6583 if (mExtras == null) {
6584 mExtras = new Bundle();
6585 }
6586 mExtras.putCharSequenceArrayList(name, value);
6587 return this;
6588 }
6589
6590 /**
6591 * Add extended data to the intent. The name must include a package
6592 * prefix, for example the app com.android.contacts would use names
6593 * like "com.android.contacts.ShowAll".
6594 *
6595 * @param name The name of the extra data, with package prefix.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006596 * @param value The Serializable data value.
6597 *
6598 * @return Returns the same Intent object, for chaining multiple calls
6599 * into a single statement.
6600 *
6601 * @see #putExtras
6602 * @see #removeExtra
6603 * @see #getSerializableExtra(String)
6604 */
6605 public Intent putExtra(String name, Serializable value) {
6606 if (mExtras == null) {
6607 mExtras = new Bundle();
6608 }
6609 mExtras.putSerializable(name, value);
6610 return this;
6611 }
6612
6613 /**
6614 * Add extended data to the intent. The name must include a package
6615 * prefix, for example the app com.android.contacts would use names
6616 * like "com.android.contacts.ShowAll".
6617 *
6618 * @param name The name of the extra data, with package prefix.
6619 * @param value The boolean array data value.
6620 *
6621 * @return Returns the same Intent object, for chaining multiple calls
6622 * into a single statement.
6623 *
6624 * @see #putExtras
6625 * @see #removeExtra
6626 * @see #getBooleanArrayExtra(String)
6627 */
6628 public Intent putExtra(String name, boolean[] value) {
6629 if (mExtras == null) {
6630 mExtras = new Bundle();
6631 }
6632 mExtras.putBooleanArray(name, value);
6633 return this;
6634 }
6635
6636 /**
6637 * Add extended data to the intent. The name must include a package
6638 * prefix, for example the app com.android.contacts would use names
6639 * like "com.android.contacts.ShowAll".
6640 *
6641 * @param name The name of the extra data, with package prefix.
6642 * @param value The byte array data value.
6643 *
6644 * @return Returns the same Intent object, for chaining multiple calls
6645 * into a single statement.
6646 *
6647 * @see #putExtras
6648 * @see #removeExtra
6649 * @see #getByteArrayExtra(String)
6650 */
6651 public Intent putExtra(String name, byte[] value) {
6652 if (mExtras == null) {
6653 mExtras = new Bundle();
6654 }
6655 mExtras.putByteArray(name, value);
6656 return this;
6657 }
6658
6659 /**
6660 * Add extended data to the intent. The name must include a package
6661 * prefix, for example the app com.android.contacts would use names
6662 * like "com.android.contacts.ShowAll".
6663 *
6664 * @param name The name of the extra data, with package prefix.
6665 * @param value The short array data value.
6666 *
6667 * @return Returns the same Intent object, for chaining multiple calls
6668 * into a single statement.
6669 *
6670 * @see #putExtras
6671 * @see #removeExtra
6672 * @see #getShortArrayExtra(String)
6673 */
6674 public Intent putExtra(String name, short[] value) {
6675 if (mExtras == null) {
6676 mExtras = new Bundle();
6677 }
6678 mExtras.putShortArray(name, value);
6679 return this;
6680 }
6681
6682 /**
6683 * Add extended data to the intent. The name must include a package
6684 * prefix, for example the app com.android.contacts would use names
6685 * like "com.android.contacts.ShowAll".
6686 *
6687 * @param name The name of the extra data, with package prefix.
6688 * @param value The char array data value.
6689 *
6690 * @return Returns the same Intent object, for chaining multiple calls
6691 * into a single statement.
6692 *
6693 * @see #putExtras
6694 * @see #removeExtra
6695 * @see #getCharArrayExtra(String)
6696 */
6697 public Intent putExtra(String name, char[] value) {
6698 if (mExtras == null) {
6699 mExtras = new Bundle();
6700 }
6701 mExtras.putCharArray(name, value);
6702 return this;
6703 }
6704
6705 /**
6706 * Add extended data to the intent. The name must include a package
6707 * prefix, for example the app com.android.contacts would use names
6708 * like "com.android.contacts.ShowAll".
6709 *
6710 * @param name The name of the extra data, with package prefix.
6711 * @param value The int array data value.
6712 *
6713 * @return Returns the same Intent object, for chaining multiple calls
6714 * into a single statement.
6715 *
6716 * @see #putExtras
6717 * @see #removeExtra
6718 * @see #getIntArrayExtra(String)
6719 */
6720 public Intent putExtra(String name, int[] value) {
6721 if (mExtras == null) {
6722 mExtras = new Bundle();
6723 }
6724 mExtras.putIntArray(name, value);
6725 return this;
6726 }
6727
6728 /**
6729 * Add extended data to the intent. The name must include a package
6730 * prefix, for example the app com.android.contacts would use names
6731 * like "com.android.contacts.ShowAll".
6732 *
6733 * @param name The name of the extra data, with package prefix.
6734 * @param value The byte array data value.
6735 *
6736 * @return Returns the same Intent object, for chaining multiple calls
6737 * into a single statement.
6738 *
6739 * @see #putExtras
6740 * @see #removeExtra
6741 * @see #getLongArrayExtra(String)
6742 */
6743 public Intent putExtra(String name, long[] value) {
6744 if (mExtras == null) {
6745 mExtras = new Bundle();
6746 }
6747 mExtras.putLongArray(name, value);
6748 return this;
6749 }
6750
6751 /**
6752 * Add extended data to the intent. The name must include a package
6753 * prefix, for example the app com.android.contacts would use names
6754 * like "com.android.contacts.ShowAll".
6755 *
6756 * @param name The name of the extra data, with package prefix.
6757 * @param value The float array data value.
6758 *
6759 * @return Returns the same Intent object, for chaining multiple calls
6760 * into a single statement.
6761 *
6762 * @see #putExtras
6763 * @see #removeExtra
6764 * @see #getFloatArrayExtra(String)
6765 */
6766 public Intent putExtra(String name, float[] value) {
6767 if (mExtras == null) {
6768 mExtras = new Bundle();
6769 }
6770 mExtras.putFloatArray(name, value);
6771 return this;
6772 }
6773
6774 /**
6775 * Add extended data to the intent. The name must include a package
6776 * prefix, for example the app com.android.contacts would use names
6777 * like "com.android.contacts.ShowAll".
6778 *
6779 * @param name The name of the extra data, with package prefix.
6780 * @param value The double array data value.
6781 *
6782 * @return Returns the same Intent object, for chaining multiple calls
6783 * into a single statement.
6784 *
6785 * @see #putExtras
6786 * @see #removeExtra
6787 * @see #getDoubleArrayExtra(String)
6788 */
6789 public Intent putExtra(String name, double[] value) {
6790 if (mExtras == null) {
6791 mExtras = new Bundle();
6792 }
6793 mExtras.putDoubleArray(name, value);
6794 return this;
6795 }
6796
6797 /**
6798 * Add extended data to the intent. The name must include a package
6799 * prefix, for example the app com.android.contacts would use names
6800 * like "com.android.contacts.ShowAll".
6801 *
6802 * @param name The name of the extra data, with package prefix.
6803 * @param value The String array data value.
6804 *
6805 * @return Returns the same Intent object, for chaining multiple calls
6806 * into a single statement.
6807 *
6808 * @see #putExtras
6809 * @see #removeExtra
6810 * @see #getStringArrayExtra(String)
6811 */
6812 public Intent putExtra(String name, String[] value) {
6813 if (mExtras == null) {
6814 mExtras = new Bundle();
6815 }
6816 mExtras.putStringArray(name, value);
6817 return this;
6818 }
6819
6820 /**
6821 * Add extended data to the intent. The name must include a package
6822 * prefix, for example the app com.android.contacts would use names
6823 * like "com.android.contacts.ShowAll".
6824 *
6825 * @param name The name of the extra data, with package prefix.
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00006826 * @param value The CharSequence array data value.
6827 *
6828 * @return Returns the same Intent object, for chaining multiple calls
6829 * into a single statement.
6830 *
6831 * @see #putExtras
6832 * @see #removeExtra
6833 * @see #getCharSequenceArrayExtra(String)
6834 */
6835 public Intent putExtra(String name, CharSequence[] value) {
6836 if (mExtras == null) {
6837 mExtras = new Bundle();
6838 }
6839 mExtras.putCharSequenceArray(name, value);
6840 return this;
6841 }
6842
6843 /**
6844 * Add extended data to the intent. The name must include a package
6845 * prefix, for example the app com.android.contacts would use names
6846 * like "com.android.contacts.ShowAll".
6847 *
6848 * @param name The name of the extra data, with package prefix.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006849 * @param value The Bundle data value.
6850 *
6851 * @return Returns the same Intent object, for chaining multiple calls
6852 * into a single statement.
6853 *
6854 * @see #putExtras
6855 * @see #removeExtra
6856 * @see #getBundleExtra(String)
6857 */
6858 public Intent putExtra(String name, Bundle value) {
6859 if (mExtras == null) {
6860 mExtras = new Bundle();
6861 }
6862 mExtras.putBundle(name, value);
6863 return this;
6864 }
6865
6866 /**
6867 * Add extended data to the intent. The name must include a package
6868 * prefix, for example the app com.android.contacts would use names
6869 * like "com.android.contacts.ShowAll".
6870 *
6871 * @param name The name of the extra data, with package prefix.
6872 * @param value The IBinder data value.
6873 *
6874 * @return Returns the same Intent object, for chaining multiple calls
6875 * into a single statement.
6876 *
6877 * @see #putExtras
6878 * @see #removeExtra
6879 * @see #getIBinderExtra(String)
6880 *
6881 * @deprecated
6882 * @hide
6883 */
6884 @Deprecated
6885 public Intent putExtra(String name, IBinder value) {
6886 if (mExtras == null) {
6887 mExtras = new Bundle();
6888 }
6889 mExtras.putIBinder(name, value);
6890 return this;
6891 }
6892
6893 /**
6894 * Copy all extras in 'src' in to this intent.
6895 *
6896 * @param src Contains the extras to copy.
6897 *
6898 * @see #putExtra
6899 */
6900 public Intent putExtras(Intent src) {
6901 if (src.mExtras != null) {
6902 if (mExtras == null) {
6903 mExtras = new Bundle(src.mExtras);
6904 } else {
6905 mExtras.putAll(src.mExtras);
6906 }
6907 }
6908 return this;
6909 }
6910
6911 /**
6912 * Add a set of extended data to the intent. The keys must include a package
6913 * prefix, for example the app com.android.contacts would use names
6914 * like "com.android.contacts.ShowAll".
6915 *
6916 * @param extras The Bundle of extras to add to this intent.
6917 *
6918 * @see #putExtra
6919 * @see #removeExtra
6920 */
6921 public Intent putExtras(Bundle extras) {
6922 if (mExtras == null) {
6923 mExtras = new Bundle();
6924 }
6925 mExtras.putAll(extras);
6926 return this;
6927 }
6928
6929 /**
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08006930 * Completely replace the extras in the Intent with the extras in the
6931 * given Intent.
The Android Open Source Project10592532009-03-18 17:39:46 -07006932 *
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08006933 * @param src The exact extras contained in this Intent are copied
6934 * into the target intent, replacing any that were previously there.
6935 */
6936 public Intent replaceExtras(Intent src) {
6937 mExtras = src.mExtras != null ? new Bundle(src.mExtras) : null;
6938 return this;
6939 }
The Android Open Source Project10592532009-03-18 17:39:46 -07006940
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08006941 /**
6942 * Completely replace the extras in the Intent with the given Bundle of
6943 * extras.
The Android Open Source Project10592532009-03-18 17:39:46 -07006944 *
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08006945 * @param extras The new set of extras in the Intent, or null to erase
6946 * all extras.
6947 */
6948 public Intent replaceExtras(Bundle extras) {
6949 mExtras = extras != null ? new Bundle(extras) : null;
6950 return this;
6951 }
The Android Open Source Project10592532009-03-18 17:39:46 -07006952
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08006953 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006954 * Remove extended data from the intent.
6955 *
6956 * @see #putExtra
6957 */
6958 public void removeExtra(String name) {
6959 if (mExtras != null) {
6960 mExtras.remove(name);
6961 if (mExtras.size() == 0) {
6962 mExtras = null;
6963 }
6964 }
6965 }
6966
6967 /**
6968 * Set special flags controlling how this intent is handled. Most values
6969 * here depend on the type of component being executed by the Intent,
6970 * specifically the FLAG_ACTIVITY_* flags are all for use with
6971 * {@link Context#startActivity Context.startActivity()} and the
6972 * FLAG_RECEIVER_* flags are all for use with
6973 * {@link Context#sendBroadcast(Intent) Context.sendBroadcast()}.
6974 *
Scott Main7aee61f2011-02-08 11:25:01 -08006975 * <p>See the
6976 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
6977 * Stack</a> documentation for important information on how some of these options impact
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006978 * the behavior of your application.
6979 *
6980 * @param flags The desired flags.
6981 *
6982 * @return Returns the same Intent object, for chaining multiple calls
6983 * into a single statement.
6984 *
6985 * @see #getFlags
6986 * @see #addFlags
6987 *
6988 * @see #FLAG_GRANT_READ_URI_PERMISSION
6989 * @see #FLAG_GRANT_WRITE_URI_PERMISSION
Jeff Sharkey846318a2014-04-04 12:12:41 -07006990 * @see #FLAG_GRANT_PERSISTABLE_URI_PERMISSION
6991 * @see #FLAG_GRANT_PREFIX_URI_PERMISSION
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006992 * @see #FLAG_DEBUG_LOG_RESOLUTION
6993 * @see #FLAG_FROM_BACKGROUND
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006994 * @see #FLAG_ACTIVITY_BROUGHT_TO_FRONT
Dianne Hackborn621e17d2010-11-22 15:59:56 -08006995 * @see #FLAG_ACTIVITY_CLEAR_TASK
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006996 * @see #FLAG_ACTIVITY_CLEAR_TOP
Dianne Hackborn621e17d2010-11-22 15:59:56 -08006997 * @see #FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006998 * @see #FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS
6999 * @see #FLAG_ACTIVITY_FORWARD_RESULT
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08007000 * @see #FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007001 * @see #FLAG_ACTIVITY_MULTIPLE_TASK
Craig Mautnerd00f4742014-03-12 14:17:26 -07007002 * @see #FLAG_ACTIVITY_NEW_DOCUMENT
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007003 * @see #FLAG_ACTIVITY_NEW_TASK
Dianne Hackborn621e17d2010-11-22 15:59:56 -08007004 * @see #FLAG_ACTIVITY_NO_ANIMATION
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007005 * @see #FLAG_ACTIVITY_NO_HISTORY
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08007006 * @see #FLAG_ACTIVITY_NO_USER_ACTION
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08007007 * @see #FLAG_ACTIVITY_PREVIOUS_IS_TOP
7008 * @see #FLAG_ACTIVITY_RESET_TASK_IF_NEEDED
Dianne Hackborn621e17d2010-11-22 15:59:56 -08007009 * @see #FLAG_ACTIVITY_REORDER_TO_FRONT
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007010 * @see #FLAG_ACTIVITY_SINGLE_TOP
Dianne Hackborn621e17d2010-11-22 15:59:56 -08007011 * @see #FLAG_ACTIVITY_TASK_ON_HOME
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007012 * @see #FLAG_RECEIVER_REGISTERED_ONLY
7013 */
7014 public Intent setFlags(int flags) {
7015 mFlags = flags;
7016 return this;
7017 }
7018
7019 /**
7020 * Add additional flags to the intent (or with existing flags
7021 * value).
7022 *
7023 * @param flags The new flags to set.
7024 *
7025 * @return Returns the same Intent object, for chaining multiple calls
7026 * into a single statement.
7027 *
7028 * @see #setFlags
7029 */
7030 public Intent addFlags(int flags) {
7031 mFlags |= flags;
7032 return this;
7033 }
7034
7035 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007036 * (Usually optional) Set an explicit application package name that limits
7037 * the components this Intent will resolve to. If left to the default
7038 * value of null, all components in all applications will considered.
7039 * If non-null, the Intent can only match the components in the given
7040 * application package.
7041 *
7042 * @param packageName The name of the application package to handle the
7043 * intent, or null to allow any application package.
7044 *
7045 * @return Returns the same Intent object, for chaining multiple calls
7046 * into a single statement.
7047 *
7048 * @see #getPackage
7049 * @see #resolveActivity
7050 */
7051 public Intent setPackage(String packageName) {
Dianne Hackbornf5b86712011-12-05 17:42:41 -08007052 if (packageName != null && mSelector != null) {
7053 throw new IllegalArgumentException(
7054 "Can't set package name when selector is already set");
7055 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007056 mPackage = packageName;
7057 return this;
7058 }
7059
7060 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007061 * (Usually optional) Explicitly set the component to handle the intent.
7062 * If left with the default value of null, the system will determine the
7063 * appropriate class to use based on the other fields (action, data,
7064 * type, categories) in the Intent. If this class is defined, the
7065 * specified class will always be used regardless of the other fields. You
7066 * should only set this value when you know you absolutely want a specific
7067 * class to be used; otherwise it is better to let the system find the
7068 * appropriate class so that you will respect the installed applications
7069 * and user preferences.
7070 *
7071 * @param component The name of the application component to handle the
7072 * intent, or null to let the system find one for you.
7073 *
7074 * @return Returns the same Intent object, for chaining multiple calls
7075 * into a single statement.
7076 *
7077 * @see #setClass
7078 * @see #setClassName(Context, String)
7079 * @see #setClassName(String, String)
7080 * @see #getComponent
7081 * @see #resolveActivity
7082 */
7083 public Intent setComponent(ComponentName component) {
7084 mComponent = component;
7085 return this;
7086 }
7087
7088 /**
7089 * Convenience for calling {@link #setComponent} with an
7090 * explicit class name.
7091 *
7092 * @param packageContext A Context of the application package implementing
7093 * this class.
7094 * @param className The name of a class inside of the application package
7095 * that will be used as the component for this Intent.
7096 *
7097 * @return Returns the same Intent object, for chaining multiple calls
7098 * into a single statement.
7099 *
7100 * @see #setComponent
7101 * @see #setClass
7102 */
7103 public Intent setClassName(Context packageContext, String className) {
7104 mComponent = new ComponentName(packageContext, className);
7105 return this;
7106 }
7107
7108 /**
7109 * Convenience for calling {@link #setComponent} with an
7110 * explicit application package name and class name.
7111 *
7112 * @param packageName The name of the package implementing the desired
7113 * component.
7114 * @param className The name of a class inside of the application package
7115 * that will be used as the component for this Intent.
7116 *
7117 * @return Returns the same Intent object, for chaining multiple calls
7118 * into a single statement.
7119 *
7120 * @see #setComponent
7121 * @see #setClass
7122 */
7123 public Intent setClassName(String packageName, String className) {
7124 mComponent = new ComponentName(packageName, className);
7125 return this;
7126 }
7127
7128 /**
7129 * Convenience for calling {@link #setComponent(ComponentName)} with the
7130 * name returned by a {@link Class} object.
7131 *
7132 * @param packageContext A Context of the application package implementing
7133 * this class.
7134 * @param cls The class name to set, equivalent to
7135 * <code>setClassName(context, cls.getName())</code>.
7136 *
7137 * @return Returns the same Intent object, for chaining multiple calls
7138 * into a single statement.
7139 *
7140 * @see #setComponent
7141 */
7142 public Intent setClass(Context packageContext, Class<?> cls) {
7143 mComponent = new ComponentName(packageContext, cls);
7144 return this;
7145 }
7146
7147 /**
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08007148 * Set the bounds of the sender of this intent, in screen coordinates. This can be
7149 * used as a hint to the receiver for animations and the like. Null means that there
7150 * is no source bounds.
7151 */
7152 public void setSourceBounds(Rect r) {
7153 if (r != null) {
7154 mSourceBounds = new Rect(r);
7155 } else {
Daniel Lehmanna5b58df2011-10-12 16:24:22 -07007156 mSourceBounds = null;
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08007157 }
7158 }
7159
Tor Norbyed9273d62013-05-30 15:59:53 -07007160 /** @hide */
7161 @IntDef(flag = true,
7162 value = {
7163 FILL_IN_ACTION,
7164 FILL_IN_DATA,
7165 FILL_IN_CATEGORIES,
7166 FILL_IN_COMPONENT,
7167 FILL_IN_PACKAGE,
7168 FILL_IN_SOURCE_BOUNDS,
7169 FILL_IN_SELECTOR,
7170 FILL_IN_CLIP_DATA
7171 })
7172 @Retention(RetentionPolicy.SOURCE)
7173 public @interface FillInFlags {}
7174
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08007175 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007176 * Use with {@link #fillIn} to allow the current action value to be
7177 * overwritten, even if it is already set.
7178 */
7179 public static final int FILL_IN_ACTION = 1<<0;
7180
7181 /**
7182 * Use with {@link #fillIn} to allow the current data or type value
7183 * overwritten, even if it is already set.
7184 */
7185 public static final int FILL_IN_DATA = 1<<1;
7186
7187 /**
7188 * Use with {@link #fillIn} to allow the current categories to be
7189 * overwritten, even if they are already set.
7190 */
7191 public static final int FILL_IN_CATEGORIES = 1<<2;
7192
7193 /**
7194 * Use with {@link #fillIn} to allow the current component value to be
7195 * overwritten, even if it is already set.
7196 */
7197 public static final int FILL_IN_COMPONENT = 1<<3;
7198
7199 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007200 * Use with {@link #fillIn} to allow the current package value to be
7201 * overwritten, even if it is already set.
7202 */
7203 public static final int FILL_IN_PACKAGE = 1<<4;
7204
7205 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08007206 * Use with {@link #fillIn} to allow the current bounds rectangle to be
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08007207 * overwritten, even if it is already set.
7208 */
7209 public static final int FILL_IN_SOURCE_BOUNDS = 1<<5;
7210
7211 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08007212 * Use with {@link #fillIn} to allow the current selector to be
7213 * overwritten, even if it is already set.
7214 */
7215 public static final int FILL_IN_SELECTOR = 1<<6;
7216
7217 /**
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007218 * Use with {@link #fillIn} to allow the current ClipData to be
7219 * overwritten, even if it is already set.
7220 */
7221 public static final int FILL_IN_CLIP_DATA = 1<<7;
7222
7223 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007224 * Copy the contents of <var>other</var> in to this object, but only
7225 * where fields are not defined by this object. For purposes of a field
7226 * being defined, the following pieces of data in the Intent are
7227 * considered to be separate fields:
7228 *
7229 * <ul>
7230 * <li> action, as set by {@link #setAction}.
Nick Pellyccae4122012-01-09 14:12:58 -08007231 * <li> data Uri and MIME type, as set by {@link #setData(Uri)},
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007232 * {@link #setType(String)}, or {@link #setDataAndType(Uri, String)}.
7233 * <li> categories, as set by {@link #addCategory}.
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007234 * <li> package, as set by {@link #setPackage}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007235 * <li> component, as set by {@link #setComponent(ComponentName)} or
7236 * related methods.
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007237 * <li> source bounds, as set by {@link #setSourceBounds}.
7238 * <li> selector, as set by {@link #setSelector(Intent)}.
7239 * <li> clip data, as set by {@link #setClipData(ClipData)}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007240 * <li> each top-level name in the associated extras.
7241 * </ul>
7242 *
7243 * <p>In addition, you can use the {@link #FILL_IN_ACTION},
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007244 * {@link #FILL_IN_DATA}, {@link #FILL_IN_CATEGORIES}, {@link #FILL_IN_PACKAGE},
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007245 * {@link #FILL_IN_COMPONENT}, {@link #FILL_IN_SOURCE_BOUNDS},
7246 * {@link #FILL_IN_SELECTOR}, and {@link #FILL_IN_CLIP_DATA} to override
7247 * the restriction where the corresponding field will not be replaced if
7248 * it is already set.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007249 *
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007250 * <p>Note: The component field will only be copied if {@link #FILL_IN_COMPONENT}
7251 * is explicitly specified. The selector will only be copied if
7252 * {@link #FILL_IN_SELECTOR} is explicitly specified.
Brett Chabot3e391752009-07-21 16:07:23 -07007253 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007254 * <p>For example, consider Intent A with {data="foo", categories="bar"}
7255 * and Intent B with {action="gotit", data-type="some/thing",
7256 * categories="one","two"}.
7257 *
7258 * <p>Calling A.fillIn(B, Intent.FILL_IN_DATA) will result in A now
7259 * containing: {action="gotit", data-type="some/thing",
7260 * categories="bar"}.
7261 *
7262 * @param other Another Intent whose values are to be used to fill in
7263 * the current one.
7264 * @param flags Options to control which fields can be filled in.
7265 *
7266 * @return Returns a bit mask of {@link #FILL_IN_ACTION},
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007267 * {@link #FILL_IN_DATA}, {@link #FILL_IN_CATEGORIES}, {@link #FILL_IN_PACKAGE},
Tor Norbyed9273d62013-05-30 15:59:53 -07007268 * {@link #FILL_IN_COMPONENT}, {@link #FILL_IN_SOURCE_BOUNDS},
7269 * {@link #FILL_IN_SELECTOR} and {@link #FILL_IN_CLIP_DATA indicating which fields were
7270 * changed.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007271 */
Tor Norbyed9273d62013-05-30 15:59:53 -07007272 @FillInFlags
7273 public int fillIn(Intent other, @FillInFlags int flags) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007274 int changes = 0;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01007275 boolean mayHaveCopiedUris = false;
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007276 if (other.mAction != null
7277 && (mAction == null || (flags&FILL_IN_ACTION) != 0)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007278 mAction = other.mAction;
7279 changes |= FILL_IN_ACTION;
7280 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007281 if ((other.mData != null || other.mType != null)
7282 && ((mData == null && mType == null)
7283 || (flags&FILL_IN_DATA) != 0)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007284 mData = other.mData;
7285 mType = other.mType;
7286 changes |= FILL_IN_DATA;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01007287 mayHaveCopiedUris = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007288 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007289 if (other.mCategories != null
7290 && (mCategories == null || (flags&FILL_IN_CATEGORIES) != 0)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007291 if (other.mCategories != null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07007292 mCategories = new ArraySet<String>(other.mCategories);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007293 }
7294 changes |= FILL_IN_CATEGORIES;
7295 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007296 if (other.mPackage != null
7297 && (mPackage == null || (flags&FILL_IN_PACKAGE) != 0)) {
Dianne Hackbornf5b86712011-12-05 17:42:41 -08007298 // Only do this if mSelector is not set.
7299 if (mSelector == null) {
7300 mPackage = other.mPackage;
7301 changes |= FILL_IN_PACKAGE;
7302 }
7303 }
7304 // Selector is special: it can only be set if explicitly allowed,
7305 // for the same reason as the component name.
7306 if (other.mSelector != null && (flags&FILL_IN_SELECTOR) != 0) {
7307 if (mPackage == null) {
7308 mSelector = new Intent(other.mSelector);
7309 mPackage = null;
7310 changes |= FILL_IN_SELECTOR;
7311 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007312 }
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007313 if (other.mClipData != null
7314 && (mClipData == null || (flags&FILL_IN_CLIP_DATA) != 0)) {
7315 mClipData = other.mClipData;
7316 changes |= FILL_IN_CLIP_DATA;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01007317 mayHaveCopiedUris = true;
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007318 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007319 // Component is special: it can -only- be set if explicitly allowed,
7320 // since otherwise the sender could force the intent somewhere the
7321 // originator didn't intend.
7322 if (other.mComponent != null && (flags&FILL_IN_COMPONENT) != 0) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007323 mComponent = other.mComponent;
7324 changes |= FILL_IN_COMPONENT;
7325 }
7326 mFlags |= other.mFlags;
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08007327 if (other.mSourceBounds != null
7328 && (mSourceBounds == null || (flags&FILL_IN_SOURCE_BOUNDS) != 0)) {
7329 mSourceBounds = new Rect(other.mSourceBounds);
7330 changes |= FILL_IN_SOURCE_BOUNDS;
7331 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007332 if (mExtras == null) {
7333 if (other.mExtras != null) {
7334 mExtras = new Bundle(other.mExtras);
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01007335 mayHaveCopiedUris = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007336 }
7337 } else if (other.mExtras != null) {
7338 try {
7339 Bundle newb = new Bundle(other.mExtras);
7340 newb.putAll(mExtras);
7341 mExtras = newb;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01007342 mayHaveCopiedUris = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007343 } catch (RuntimeException e) {
7344 // Modifying the extras can cause us to unparcel the contents
7345 // of the bundle, and if we do this in the system process that
7346 // may fail. We really should handle this (i.e., the Bundle
7347 // impl shouldn't be on top of a plain map), but for now just
7348 // ignore it and keep the original contents. :(
7349 Log.w("Intent", "Failure filling in extras", e);
7350 }
7351 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01007352 if (mayHaveCopiedUris && mContentUserHint == UserHandle.USER_CURRENT
7353 && other.mContentUserHint != UserHandle.USER_CURRENT) {
7354 mContentUserHint = other.mContentUserHint;
7355 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007356 return changes;
7357 }
7358
7359 /**
7360 * Wrapper class holding an Intent and implementing comparisons on it for
7361 * the purpose of filtering. The class implements its
7362 * {@link #equals equals()} and {@link #hashCode hashCode()} methods as
7363 * simple calls to {@link Intent#filterEquals(Intent)} filterEquals()} and
7364 * {@link android.content.Intent#filterHashCode()} filterHashCode()}
7365 * on the wrapped Intent.
7366 */
7367 public static final class FilterComparison {
7368 private final Intent mIntent;
7369 private final int mHashCode;
7370
7371 public FilterComparison(Intent intent) {
7372 mIntent = intent;
7373 mHashCode = intent.filterHashCode();
7374 }
7375
7376 /**
7377 * Return the Intent that this FilterComparison represents.
7378 * @return Returns the Intent held by the FilterComparison. Do
7379 * not modify!
7380 */
7381 public Intent getIntent() {
7382 return mIntent;
7383 }
7384
7385 @Override
7386 public boolean equals(Object obj) {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08007387 if (obj instanceof FilterComparison) {
7388 Intent other = ((FilterComparison)obj).mIntent;
7389 return mIntent.filterEquals(other);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007390 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08007391 return false;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007392 }
7393
7394 @Override
7395 public int hashCode() {
7396 return mHashCode;
7397 }
7398 }
7399
7400 /**
7401 * Determine if two intents are the same for the purposes of intent
7402 * resolution (filtering). That is, if their action, data, type,
7403 * class, and categories are the same. This does <em>not</em> compare
7404 * any extra data included in the intents.
7405 *
7406 * @param other The other Intent to compare against.
7407 *
7408 * @return Returns true if action, data, type, class, and categories
7409 * are the same.
7410 */
7411 public boolean filterEquals(Intent other) {
7412 if (other == null) {
7413 return false;
7414 }
Christopher Tate63d9ae12014-06-19 19:07:26 -07007415 if (!Objects.equals(this.mAction, other.mAction)) return false;
7416 if (!Objects.equals(this.mData, other.mData)) return false;
7417 if (!Objects.equals(this.mType, other.mType)) return false;
7418 if (!Objects.equals(this.mPackage, other.mPackage)) return false;
7419 if (!Objects.equals(this.mComponent, other.mComponent)) return false;
7420 if (!Objects.equals(this.mCategories, other.mCategories)) return false;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007421
7422 return true;
7423 }
7424
7425 /**
7426 * Generate hash code that matches semantics of filterEquals().
7427 *
7428 * @return Returns the hash value of the action, data, type, class, and
7429 * categories.
7430 *
7431 * @see #filterEquals
7432 */
7433 public int filterHashCode() {
7434 int code = 0;
7435 if (mAction != null) {
7436 code += mAction.hashCode();
7437 }
7438 if (mData != null) {
7439 code += mData.hashCode();
7440 }
7441 if (mType != null) {
7442 code += mType.hashCode();
7443 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007444 if (mPackage != null) {
7445 code += mPackage.hashCode();
7446 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007447 if (mComponent != null) {
7448 code += mComponent.hashCode();
7449 }
7450 if (mCategories != null) {
7451 code += mCategories.hashCode();
7452 }
7453 return code;
7454 }
7455
7456 @Override
7457 public String toString() {
Dianne Hackborn90c52de2011-09-23 12:57:44 -07007458 StringBuilder b = new StringBuilder(128);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007459
Dianne Hackborn1d442e02009-04-20 18:14:05 -07007460 b.append("Intent { ");
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007461 toShortString(b, true, true, true, false);
Dianne Hackborn1d442e02009-04-20 18:14:05 -07007462 b.append(" }");
7463
7464 return b.toString();
7465 }
7466
7467 /** @hide */
Dianne Hackborn90c52de2011-09-23 12:57:44 -07007468 public String toInsecureString() {
7469 StringBuilder b = new StringBuilder(128);
7470
7471 b.append("Intent { ");
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007472 toShortString(b, false, true, true, false);
Dianne Hackborn90c52de2011-09-23 12:57:44 -07007473 b.append(" }");
7474
Dianne Hackborn1d442e02009-04-20 18:14:05 -07007475 return b.toString();
7476 }
Romain Guy4969af72009-06-17 10:53:19 -07007477
Dianne Hackborn1d442e02009-04-20 18:14:05 -07007478 /** @hide */
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007479 public String toInsecureStringWithClip() {
Dianne Hackborn90c52de2011-09-23 12:57:44 -07007480 StringBuilder b = new StringBuilder(128);
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007481
7482 b.append("Intent { ");
7483 toShortString(b, false, true, true, true);
7484 b.append(" }");
7485
Dianne Hackborn90c52de2011-09-23 12:57:44 -07007486 return b.toString();
7487 }
7488
7489 /** @hide */
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007490 public String toShortString(boolean secure, boolean comp, boolean extras, boolean clip) {
7491 StringBuilder b = new StringBuilder(128);
7492 toShortString(b, secure, comp, extras, clip);
7493 return b.toString();
7494 }
7495
7496 /** @hide */
7497 public void toShortString(StringBuilder b, boolean secure, boolean comp, boolean extras,
7498 boolean clip) {
Dianne Hackborn1d442e02009-04-20 18:14:05 -07007499 boolean first = true;
7500 if (mAction != null) {
7501 b.append("act=").append(mAction);
7502 first = false;
7503 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007504 if (mCategories != null) {
Dianne Hackborn1d442e02009-04-20 18:14:05 -07007505 if (!first) {
7506 b.append(' ');
7507 }
7508 first = false;
7509 b.append("cat=[");
Dianne Hackbornadd005c2013-07-17 18:43:12 -07007510 for (int i=0; i<mCategories.size(); i++) {
7511 if (i > 0) b.append(',');
7512 b.append(mCategories.valueAt(i));
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007513 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07007514 b.append("]");
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007515 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07007516 if (mData != null) {
7517 if (!first) {
7518 b.append(' ');
7519 }
7520 first = false;
Wink Savillea4288072010-10-12 12:36:38 -07007521 b.append("dat=");
Dianne Hackborn90c52de2011-09-23 12:57:44 -07007522 if (secure) {
7523 b.append(mData.toSafeString());
Wink Savillea4288072010-10-12 12:36:38 -07007524 } else {
7525 b.append(mData);
7526 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07007527 }
7528 if (mType != null) {
7529 if (!first) {
7530 b.append(' ');
7531 }
7532 first = false;
7533 b.append("typ=").append(mType);
7534 }
7535 if (mFlags != 0) {
7536 if (!first) {
7537 b.append(' ');
7538 }
7539 first = false;
7540 b.append("flg=0x").append(Integer.toHexString(mFlags));
7541 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007542 if (mPackage != null) {
7543 if (!first) {
7544 b.append(' ');
7545 }
7546 first = false;
7547 b.append("pkg=").append(mPackage);
7548 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07007549 if (comp && mComponent != null) {
7550 if (!first) {
7551 b.append(' ');
7552 }
7553 first = false;
7554 b.append("cmp=").append(mComponent.flattenToShortString());
7555 }
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08007556 if (mSourceBounds != null) {
7557 if (!first) {
7558 b.append(' ');
7559 }
7560 first = false;
7561 b.append("bnds=").append(mSourceBounds.toShortString());
7562 }
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007563 if (mClipData != null) {
7564 if (!first) {
7565 b.append(' ');
7566 }
7567 first = false;
7568 if (clip) {
7569 b.append("clip={");
7570 mClipData.toShortString(b);
7571 b.append('}');
7572 } else {
7573 b.append("(has clip)");
7574 }
7575 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07007576 if (extras && mExtras != null) {
7577 if (!first) {
7578 b.append(' ');
7579 }
7580 first = false;
7581 b.append("(has extras)");
7582 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01007583 if (mContentUserHint != UserHandle.USER_CURRENT) {
7584 if (!first) {
7585 b.append(' ');
7586 }
7587 first = false;
7588 b.append("u=").append(mContentUserHint);
7589 }
Dianne Hackbornf5b86712011-12-05 17:42:41 -08007590 if (mSelector != null) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01007591 b.append(" sel=");
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007592 mSelector.toShortString(b, secure, comp, extras, clip);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08007593 b.append("}");
7594 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007595 }
7596
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007597 /**
7598 * Call {@link #toUri} with 0 flags.
7599 * @deprecated Use {@link #toUri} instead.
7600 */
7601 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007602 public String toURI() {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007603 return toUri(0);
7604 }
7605
7606 /**
7607 * Convert this Intent into a String holding a URI representation of it.
7608 * The returned URI string has been properly URI encoded, so it can be
7609 * used with {@link Uri#parse Uri.parse(String)}. The URI contains the
7610 * Intent's data as the base URI, with an additional fragment describing
7611 * the action, categories, type, flags, package, component, and extras.
Tom Taylord4a47292009-12-21 13:59:18 -08007612 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007613 * <p>You can convert the returned string back to an Intent with
7614 * {@link #getIntent}.
Tom Taylord4a47292009-12-21 13:59:18 -08007615 *
Dianne Hackborn85d558c2014-11-04 10:31:54 -08007616 * @param flags Additional operating flags. Either 0,
7617 * {@link #URI_INTENT_SCHEME}, or {@link #URI_ANDROID_APP_SCHEME}.
Tom Taylord4a47292009-12-21 13:59:18 -08007618 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007619 * @return Returns a URI encoding URI string describing the entire contents
7620 * of the Intent.
7621 */
7622 public String toUri(int flags) {
Dianne Hackborn1d442e02009-04-20 18:14:05 -07007623 StringBuilder uri = new StringBuilder(128);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08007624 if ((flags&URI_ANDROID_APP_SCHEME) != 0) {
7625 if (mPackage == null) {
7626 throw new IllegalArgumentException(
7627 "Intent must include an explicit package name to build an android-app: "
7628 + this);
7629 }
7630 uri.append("android-app://");
7631 uri.append(mPackage);
7632 String scheme = null;
7633 if (mData != null) {
7634 scheme = mData.getScheme();
7635 if (scheme != null) {
7636 uri.append('/');
7637 uri.append(scheme);
7638 String authority = mData.getEncodedAuthority();
7639 if (authority != null) {
7640 uri.append('/');
7641 uri.append(authority);
7642 String path = mData.getEncodedPath();
7643 if (path != null) {
7644 uri.append(path);
7645 }
7646 String queryParams = mData.getEncodedQuery();
7647 if (queryParams != null) {
7648 uri.append('?');
7649 uri.append(queryParams);
7650 }
7651 String fragment = mData.getEncodedFragment();
7652 if (fragment != null) {
7653 uri.append('#');
7654 uri.append(fragment);
7655 }
7656 }
7657 }
7658 }
7659 toUriFragment(uri, null, scheme == null ? Intent.ACTION_MAIN : Intent.ACTION_VIEW,
7660 mPackage, flags);
7661 return uri.toString();
7662 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007663 String scheme = null;
7664 if (mData != null) {
7665 String data = mData.toString();
7666 if ((flags&URI_INTENT_SCHEME) != 0) {
7667 final int N = data.length();
7668 for (int i=0; i<N; i++) {
7669 char c = data.charAt(i);
7670 if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')
7671 || c == '.' || c == '-') {
7672 continue;
7673 }
7674 if (c == ':' && i > 0) {
7675 // Valid scheme.
7676 scheme = data.substring(0, i);
7677 uri.append("intent:");
7678 data = data.substring(i+1);
7679 break;
7680 }
Tom Taylord4a47292009-12-21 13:59:18 -08007681
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007682 // No scheme.
7683 break;
7684 }
7685 }
7686 uri.append(data);
Tom Taylord4a47292009-12-21 13:59:18 -08007687
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007688 } else if ((flags&URI_INTENT_SCHEME) != 0) {
7689 uri.append("intent:");
7690 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007691
Dianne Hackborn85d558c2014-11-04 10:31:54 -08007692 toUriFragment(uri, scheme, Intent.ACTION_VIEW, null, flags);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007693
Dianne Hackborn85d558c2014-11-04 10:31:54 -08007694 return uri.toString();
7695 }
7696
7697 private void toUriFragment(StringBuilder uri, String scheme, String defAction,
7698 String defPackage, int flags) {
7699 StringBuilder frag = new StringBuilder(128);
7700
7701 toUriInner(frag, scheme, defAction, defPackage, flags);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08007702 if (mSelector != null) {
Dianne Hackborn80b1c562014-12-09 20:22:08 -08007703 frag.append("SEL;");
Dianne Hackbornf5b86712011-12-05 17:42:41 -08007704 // Note that for now we are not going to try to handle the
7705 // data part; not clear how to represent this as a URI, and
7706 // not much utility in it.
Dianne Hackborn85d558c2014-11-04 10:31:54 -08007707 mSelector.toUriInner(frag, mSelector.mData != null ? mSelector.mData.getScheme() : null,
7708 null, null, flags);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08007709 }
7710
Dianne Hackborn85d558c2014-11-04 10:31:54 -08007711 if (frag.length() > 0) {
7712 uri.append("#Intent;");
7713 uri.append(frag);
7714 uri.append("end");
7715 }
Dianne Hackbornf5b86712011-12-05 17:42:41 -08007716 }
7717
Dianne Hackborn85d558c2014-11-04 10:31:54 -08007718 private void toUriInner(StringBuilder uri, String scheme, String defAction,
7719 String defPackage, int flags) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007720 if (scheme != null) {
7721 uri.append("scheme=").append(scheme).append(';');
7722 }
Dianne Hackborn85d558c2014-11-04 10:31:54 -08007723 if (mAction != null && !mAction.equals(defAction)) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007724 uri.append("action=").append(Uri.encode(mAction)).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007725 }
7726 if (mCategories != null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07007727 for (int i=0; i<mCategories.size(); i++) {
7728 uri.append("category=").append(Uri.encode(mCategories.valueAt(i))).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007729 }
7730 }
7731 if (mType != null) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007732 uri.append("type=").append(Uri.encode(mType, "/")).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007733 }
7734 if (mFlags != 0) {
7735 uri.append("launchFlags=0x").append(Integer.toHexString(mFlags)).append(';');
7736 }
Dianne Hackborn85d558c2014-11-04 10:31:54 -08007737 if (mPackage != null && !mPackage.equals(defPackage)) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007738 uri.append("package=").append(Uri.encode(mPackage)).append(';');
7739 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007740 if (mComponent != null) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007741 uri.append("component=").append(Uri.encode(
7742 mComponent.flattenToShortString(), "/")).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007743 }
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08007744 if (mSourceBounds != null) {
7745 uri.append("sourceBounds=")
7746 .append(Uri.encode(mSourceBounds.flattenToString()))
7747 .append(';');
7748 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007749 if (mExtras != null) {
7750 for (String key : mExtras.keySet()) {
7751 final Object value = mExtras.get(key);
7752 char entryType =
7753 value instanceof String ? 'S' :
7754 value instanceof Boolean ? 'B' :
7755 value instanceof Byte ? 'b' :
7756 value instanceof Character ? 'c' :
7757 value instanceof Double ? 'd' :
7758 value instanceof Float ? 'f' :
7759 value instanceof Integer ? 'i' :
7760 value instanceof Long ? 'l' :
7761 value instanceof Short ? 's' :
7762 '\0';
7763
7764 if (entryType != '\0') {
7765 uri.append(entryType);
7766 uri.append('.');
7767 uri.append(Uri.encode(key));
7768 uri.append('=');
7769 uri.append(Uri.encode(value.toString()));
7770 uri.append(';');
7771 }
7772 }
7773 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007774 }
The Android Open Source Project10592532009-03-18 17:39:46 -07007775
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007776 public int describeContents() {
7777 return (mExtras != null) ? mExtras.describeContents() : 0;
7778 }
7779
7780 public void writeToParcel(Parcel out, int flags) {
7781 out.writeString(mAction);
7782 Uri.writeToParcel(out, mData);
7783 out.writeString(mType);
7784 out.writeInt(mFlags);
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007785 out.writeString(mPackage);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007786 ComponentName.writeToParcel(mComponent, out);
7787
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08007788 if (mSourceBounds != null) {
7789 out.writeInt(1);
7790 mSourceBounds.writeToParcel(out, flags);
7791 } else {
7792 out.writeInt(0);
7793 }
7794
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007795 if (mCategories != null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07007796 final int N = mCategories.size();
7797 out.writeInt(N);
7798 for (int i=0; i<N; i++) {
7799 out.writeString(mCategories.valueAt(i));
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007800 }
7801 } else {
7802 out.writeInt(0);
7803 }
7804
Dianne Hackbornf5b86712011-12-05 17:42:41 -08007805 if (mSelector != null) {
7806 out.writeInt(1);
7807 mSelector.writeToParcel(out, flags);
7808 } else {
7809 out.writeInt(0);
7810 }
7811
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007812 if (mClipData != null) {
7813 out.writeInt(1);
7814 mClipData.writeToParcel(out, flags);
7815 } else {
7816 out.writeInt(0);
7817 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01007818 out.writeInt(mContentUserHint);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007819 out.writeBundle(mExtras);
7820 }
7821
7822 public static final Parcelable.Creator<Intent> CREATOR
7823 = new Parcelable.Creator<Intent>() {
7824 public Intent createFromParcel(Parcel in) {
7825 return new Intent(in);
7826 }
7827 public Intent[] newArray(int size) {
7828 return new Intent[size];
7829 }
7830 };
7831
Dianne Hackborneb034652009-09-07 00:49:58 -07007832 /** @hide */
7833 protected Intent(Parcel in) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007834 readFromParcel(in);
7835 }
7836
7837 public void readFromParcel(Parcel in) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08007838 setAction(in.readString());
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007839 mData = Uri.CREATOR.createFromParcel(in);
7840 mType = in.readString();
7841 mFlags = in.readInt();
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007842 mPackage = in.readString();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007843 mComponent = ComponentName.readFromParcel(in);
7844
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08007845 if (in.readInt() != 0) {
7846 mSourceBounds = Rect.CREATOR.createFromParcel(in);
7847 }
7848
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007849 int N = in.readInt();
7850 if (N > 0) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07007851 mCategories = new ArraySet<String>();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007852 int i;
7853 for (i=0; i<N; i++) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08007854 mCategories.add(in.readString().intern());
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007855 }
7856 } else {
7857 mCategories = null;
7858 }
7859
Dianne Hackbornf5b86712011-12-05 17:42:41 -08007860 if (in.readInt() != 0) {
7861 mSelector = new Intent(in);
7862 }
7863
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007864 if (in.readInt() != 0) {
7865 mClipData = new ClipData(in);
7866 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01007867 mContentUserHint = in.readInt();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007868 mExtras = in.readBundle();
7869 }
7870
7871 /**
7872 * Parses the "intent" element (and its children) from XML and instantiates
7873 * an Intent object. The given XML parser should be located at the tag
7874 * where parsing should start (often named "intent"), from which the
7875 * basic action, data, type, and package and class name will be
7876 * retrieved. The function will then parse in to any child elements,
7877 * looking for <category android:name="xxx"> tags to add categories and
7878 * <extra android:name="xxx" android:value="yyy"> to attach extra data
7879 * to the intent.
7880 *
7881 * @param resources The Resources to use when inflating resources.
7882 * @param parser The XML parser pointing at an "intent" tag.
7883 * @param attrs The AttributeSet interface for retrieving extended
7884 * attribute data at the current <var>parser</var> location.
7885 * @return An Intent object matching the XML data.
7886 * @throws XmlPullParserException If there was an XML parsing error.
7887 * @throws IOException If there was an I/O error.
7888 */
7889 public static Intent parseIntent(Resources resources, XmlPullParser parser, AttributeSet attrs)
7890 throws XmlPullParserException, IOException {
7891 Intent intent = new Intent();
7892
7893 TypedArray sa = resources.obtainAttributes(attrs,
7894 com.android.internal.R.styleable.Intent);
7895
7896 intent.setAction(sa.getString(com.android.internal.R.styleable.Intent_action));
7897
7898 String data = sa.getString(com.android.internal.R.styleable.Intent_data);
7899 String mimeType = sa.getString(com.android.internal.R.styleable.Intent_mimeType);
7900 intent.setDataAndType(data != null ? Uri.parse(data) : null, mimeType);
7901
7902 String packageName = sa.getString(com.android.internal.R.styleable.Intent_targetPackage);
7903 String className = sa.getString(com.android.internal.R.styleable.Intent_targetClass);
7904 if (packageName != null && className != null) {
7905 intent.setComponent(new ComponentName(packageName, className));
7906 }
7907
7908 sa.recycle();
7909
7910 int outerDepth = parser.getDepth();
7911 int type;
7912 while ((type=parser.next()) != XmlPullParser.END_DOCUMENT
7913 && (type != XmlPullParser.END_TAG || parser.getDepth() > outerDepth)) {
7914 if (type == XmlPullParser.END_TAG || type == XmlPullParser.TEXT) {
7915 continue;
7916 }
7917
7918 String nodeName = parser.getName();
Craig Mautner21d24a22014-04-23 11:45:37 -07007919 if (nodeName.equals(TAG_CATEGORIES)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007920 sa = resources.obtainAttributes(attrs,
7921 com.android.internal.R.styleable.IntentCategory);
7922 String cat = sa.getString(com.android.internal.R.styleable.IntentCategory_name);
7923 sa.recycle();
7924
7925 if (cat != null) {
7926 intent.addCategory(cat);
7927 }
7928 XmlUtils.skipCurrentTag(parser);
7929
Craig Mautner21d24a22014-04-23 11:45:37 -07007930 } else if (nodeName.equals(TAG_EXTRA)) {
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08007931 if (intent.mExtras == null) {
7932 intent.mExtras = new Bundle();
7933 }
Craig Mautner21d24a22014-04-23 11:45:37 -07007934 resources.parseBundleExtra(TAG_EXTRA, attrs, intent.mExtras);
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08007935 XmlUtils.skipCurrentTag(parser);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007936
7937 } else {
7938 XmlUtils.skipCurrentTag(parser);
7939 }
7940 }
7941
7942 return intent;
7943 }
Nick Pellyccae4122012-01-09 14:12:58 -08007944
Craig Mautner21d24a22014-04-23 11:45:37 -07007945 /** @hide */
7946 public void saveToXml(XmlSerializer out) throws IOException {
7947 if (mAction != null) {
7948 out.attribute(null, ATTR_ACTION, mAction);
7949 }
7950 if (mData != null) {
7951 out.attribute(null, ATTR_DATA, mData.toString());
7952 }
7953 if (mType != null) {
7954 out.attribute(null, ATTR_TYPE, mType);
7955 }
7956 if (mComponent != null) {
7957 out.attribute(null, ATTR_COMPONENT, mComponent.flattenToShortString());
7958 }
7959 out.attribute(null, ATTR_FLAGS, Integer.toHexString(getFlags()));
7960
7961 if (mCategories != null) {
7962 out.startTag(null, TAG_CATEGORIES);
7963 for (int categoryNdx = mCategories.size() - 1; categoryNdx >= 0; --categoryNdx) {
7964 out.attribute(null, ATTR_CATEGORY, mCategories.valueAt(categoryNdx));
7965 }
Craig Mautner43e52ed2014-06-16 17:18:52 -07007966 out.endTag(null, TAG_CATEGORIES);
Craig Mautner21d24a22014-04-23 11:45:37 -07007967 }
7968 }
7969
7970 /** @hide */
7971 public static Intent restoreFromXml(XmlPullParser in) throws IOException,
7972 XmlPullParserException {
7973 Intent intent = new Intent();
7974 final int outerDepth = in.getDepth();
7975
7976 int attrCount = in.getAttributeCount();
7977 for (int attrNdx = attrCount - 1; attrNdx >= 0; --attrNdx) {
7978 final String attrName = in.getAttributeName(attrNdx);
7979 final String attrValue = in.getAttributeValue(attrNdx);
7980 if (ATTR_ACTION.equals(attrName)) {
7981 intent.setAction(attrValue);
7982 } else if (ATTR_DATA.equals(attrName)) {
7983 intent.setData(Uri.parse(attrValue));
7984 } else if (ATTR_TYPE.equals(attrName)) {
7985 intent.setType(attrValue);
7986 } else if (ATTR_COMPONENT.equals(attrName)) {
7987 intent.setComponent(ComponentName.unflattenFromString(attrValue));
7988 } else if (ATTR_FLAGS.equals(attrName)) {
7989 intent.setFlags(Integer.valueOf(attrValue, 16));
7990 } else {
7991 Log.e("Intent", "restoreFromXml: unknown attribute=" + attrName);
7992 }
7993 }
7994
7995 int event;
7996 String name;
7997 while (((event = in.next()) != XmlPullParser.END_DOCUMENT) &&
7998 (event != XmlPullParser.END_TAG || in.getDepth() < outerDepth)) {
7999 if (event == XmlPullParser.START_TAG) {
8000 name = in.getName();
8001 if (TAG_CATEGORIES.equals(name)) {
8002 attrCount = in.getAttributeCount();
8003 for (int attrNdx = attrCount - 1; attrNdx >= 0; --attrNdx) {
8004 intent.addCategory(in.getAttributeValue(attrNdx));
8005 }
8006 } else {
8007 Log.w("Intent", "restoreFromXml: unknown name=" + name);
8008 XmlUtils.skipCurrentTag(in);
8009 }
8010 }
8011 }
8012
8013 return intent;
8014 }
8015
Nick Pellyccae4122012-01-09 14:12:58 -08008016 /**
8017 * Normalize a MIME data type.
8018 *
8019 * <p>A normalized MIME type has white-space trimmed,
8020 * content-type parameters removed, and is lower-case.
8021 * This aligns the type with Android best practices for
8022 * intent filtering.
8023 *
8024 * <p>For example, "text/plain; charset=utf-8" becomes "text/plain".
8025 * "text/x-vCard" becomes "text/x-vcard".
8026 *
8027 * <p>All MIME types received from outside Android (such as user input,
8028 * or external sources like Bluetooth, NFC, or the Internet) should
8029 * be normalized before they are used to create an Intent.
8030 *
8031 * @param type MIME data type to normalize
8032 * @return normalized MIME data type, or null if the input was null
John Spurlock125d1332013-11-25 11:58:37 -05008033 * @see #setType
8034 * @see #setTypeAndNormalize
Nick Pellyccae4122012-01-09 14:12:58 -08008035 */
8036 public static String normalizeMimeType(String type) {
8037 if (type == null) {
8038 return null;
8039 }
8040
Elliott Hughescb64d432013-08-02 10:00:44 -07008041 type = type.trim().toLowerCase(Locale.ROOT);
Nick Pellyccae4122012-01-09 14:12:58 -08008042
8043 final int semicolonIndex = type.indexOf(';');
8044 if (semicolonIndex != -1) {
8045 type = type.substring(0, semicolonIndex);
8046 }
8047 return type;
8048 }
Jeff Sharkey678d04f2012-03-23 15:41:58 -07008049
8050 /**
Jeff Sharkeya14acd22013-04-02 18:27:45 -07008051 * Prepare this {@link Intent} to leave an app process.
8052 *
8053 * @hide
8054 */
8055 public void prepareToLeaveProcess() {
8056 setAllowFds(false);
8057
8058 if (mSelector != null) {
8059 mSelector.prepareToLeaveProcess();
8060 }
8061 if (mClipData != null) {
8062 mClipData.prepareToLeaveProcess();
8063 }
8064
8065 if (mData != null && StrictMode.vmFileUriExposureEnabled()) {
8066 // There are several ACTION_MEDIA_* broadcasts that send file://
8067 // Uris, so only check common actions.
8068 if (ACTION_VIEW.equals(mAction) ||
8069 ACTION_EDIT.equals(mAction) ||
8070 ACTION_ATTACH_DATA.equals(mAction)) {
8071 mData.checkFileUriExposed("Intent.getData()");
8072 }
8073 }
8074 }
8075
8076 /**
Nicolas Prevotd85fc722014-04-16 19:52:08 +01008077 * @hide
8078 */
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008079 public void prepareToEnterProcess() {
8080 if (mContentUserHint != UserHandle.USER_CURRENT) {
Nicolas Prevotc4fc00a2014-10-31 12:01:32 +00008081 if (UserHandle.getAppId(Process.myUid()) != Process.SYSTEM_UID) {
8082 fixUris(mContentUserHint);
8083 mContentUserHint = UserHandle.USER_CURRENT;
8084 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008085 }
8086 }
8087
8088 /**
8089 * @hide
8090 */
8091 public void fixUris(int contentUserHint) {
Nicolas Prevotd85fc722014-04-16 19:52:08 +01008092 Uri data = getData();
8093 if (data != null) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008094 mData = maybeAddUserId(data, contentUserHint);
Nicolas Prevotd85fc722014-04-16 19:52:08 +01008095 }
8096 if (mClipData != null) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008097 mClipData.fixUris(contentUserHint);
Nicolas Prevotd85fc722014-04-16 19:52:08 +01008098 }
8099 String action = getAction();
8100 if (ACTION_SEND.equals(action)) {
8101 final Uri stream = getParcelableExtra(EXTRA_STREAM);
8102 if (stream != null) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008103 putExtra(EXTRA_STREAM, maybeAddUserId(stream, contentUserHint));
Nicolas Prevotd85fc722014-04-16 19:52:08 +01008104 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008105 } else if (ACTION_SEND_MULTIPLE.equals(action)) {
Nicolas Prevotd85fc722014-04-16 19:52:08 +01008106 final ArrayList<Uri> streams = getParcelableArrayListExtra(EXTRA_STREAM);
8107 if (streams != null) {
8108 ArrayList<Uri> newStreams = new ArrayList<Uri>();
8109 for (int i = 0; i < streams.size(); i++) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008110 newStreams.add(maybeAddUserId(streams.get(i), contentUserHint));
Nicolas Prevotd85fc722014-04-16 19:52:08 +01008111 }
8112 putParcelableArrayListExtra(EXTRA_STREAM, newStreams);
8113 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008114 } else if (MediaStore.ACTION_IMAGE_CAPTURE.equals(action)
8115 || MediaStore.ACTION_IMAGE_CAPTURE_SECURE.equals(action)
8116 || MediaStore.ACTION_VIDEO_CAPTURE.equals(action)) {
8117 final Uri output = getParcelableExtra(MediaStore.EXTRA_OUTPUT);
8118 if (output != null) {
8119 putExtra(MediaStore.EXTRA_OUTPUT, maybeAddUserId(output, contentUserHint));
8120 }
Nicolas Prevotd85fc722014-04-16 19:52:08 +01008121 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008122 }
Nicolas Prevotd85fc722014-04-16 19:52:08 +01008123
8124 /**
Jeff Sharkey678d04f2012-03-23 15:41:58 -07008125 * Migrate any {@link #EXTRA_STREAM} in {@link #ACTION_SEND} and
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07008126 * {@link #ACTION_SEND_MULTIPLE} to {@link ClipData}. Also inspects nested
8127 * intents in {@link #ACTION_CHOOSER}.
Jeff Sharkey678d04f2012-03-23 15:41:58 -07008128 *
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07008129 * @return Whether any contents were migrated.
Jeff Sharkey678d04f2012-03-23 15:41:58 -07008130 * @hide
8131 */
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07008132 public boolean migrateExtraStreamToClipData() {
Jeff Sharkey678d04f2012-03-23 15:41:58 -07008133 // Refuse to touch if extras already parcelled
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07008134 if (mExtras != null && mExtras.isParcelled()) return false;
Jeff Sharkey678d04f2012-03-23 15:41:58 -07008135
8136 // Bail when someone already gave us ClipData
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07008137 if (getClipData() != null) return false;
Jeff Sharkey678d04f2012-03-23 15:41:58 -07008138
8139 final String action = getAction();
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07008140 if (ACTION_CHOOSER.equals(action)) {
Jeff Sharkeyc004eef2014-09-23 16:40:50 -07008141 // Inspect contained intents to see if we need to migrate extras. We
8142 // don't promote ClipData to the parent, since ChooserActivity will
8143 // already start the picked item as the caller, and we can't combine
8144 // the flags in a safe way.
8145
8146 boolean migrated = false;
Jeff Sharkey1c297002012-05-18 13:55:47 -07008147 try {
Jeff Sharkeyc004eef2014-09-23 16:40:50 -07008148 final Intent intent = getParcelableExtra(EXTRA_INTENT);
8149 if (intent != null) {
8150 migrated |= intent.migrateExtraStreamToClipData();
Jeff Sharkey1c297002012-05-18 13:55:47 -07008151 }
8152 } catch (ClassCastException e) {
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07008153 }
Jeff Sharkeyc004eef2014-09-23 16:40:50 -07008154 try {
8155 final Parcelable[] intents = getParcelableArrayExtra(EXTRA_INITIAL_INTENTS);
8156 if (intents != null) {
8157 for (int i = 0; i < intents.length; i++) {
8158 final Intent intent = (Intent) intents[i];
8159 if (intent != null) {
8160 migrated |= intent.migrateExtraStreamToClipData();
8161 }
8162 }
8163 }
8164 } catch (ClassCastException e) {
8165 }
8166 return migrated;
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07008167
8168 } else if (ACTION_SEND.equals(action)) {
Jeff Sharkeyf27ea662012-03-27 10:34:24 -07008169 try {
Jeff Sharkeydd471e62012-05-01 13:07:01 -07008170 final Uri stream = getParcelableExtra(EXTRA_STREAM);
8171 final CharSequence text = getCharSequenceExtra(EXTRA_TEXT);
8172 final String htmlText = getStringExtra(EXTRA_HTML_TEXT);
8173 if (stream != null || text != null || htmlText != null) {
8174 final ClipData clipData = new ClipData(
8175 null, new String[] { getType() },
8176 new ClipData.Item(text, htmlText, null, stream));
8177 setClipData(clipData);
8178 addFlags(FLAG_GRANT_READ_URI_PERMISSION);
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07008179 return true;
Jeff Sharkeydd471e62012-05-01 13:07:01 -07008180 }
Jeff Sharkeyf27ea662012-03-27 10:34:24 -07008181 } catch (ClassCastException e) {
Jeff Sharkeyf27ea662012-03-27 10:34:24 -07008182 }
Jeff Sharkey678d04f2012-03-23 15:41:58 -07008183
8184 } else if (ACTION_SEND_MULTIPLE.equals(action)) {
Jeff Sharkeyf27ea662012-03-27 10:34:24 -07008185 try {
Jeff Sharkeydd471e62012-05-01 13:07:01 -07008186 final ArrayList<Uri> streams = getParcelableArrayListExtra(EXTRA_STREAM);
8187 final ArrayList<CharSequence> texts = getCharSequenceArrayListExtra(EXTRA_TEXT);
8188 final ArrayList<String> htmlTexts = getStringArrayListExtra(EXTRA_HTML_TEXT);
8189 int num = -1;
8190 if (streams != null) {
8191 num = streams.size();
8192 }
8193 if (texts != null) {
8194 if (num >= 0 && num != texts.size()) {
8195 // Wha...! F- you.
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07008196 return false;
Jeff Sharkeydd471e62012-05-01 13:07:01 -07008197 }
8198 num = texts.size();
8199 }
8200 if (htmlTexts != null) {
8201 if (num >= 0 && num != htmlTexts.size()) {
8202 // Wha...! F- you.
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07008203 return false;
Jeff Sharkeydd471e62012-05-01 13:07:01 -07008204 }
8205 num = htmlTexts.size();
8206 }
8207 if (num > 0) {
8208 final ClipData clipData = new ClipData(
8209 null, new String[] { getType() },
8210 makeClipItem(streams, texts, htmlTexts, 0));
8211
8212 for (int i = 1; i < num; i++) {
8213 clipData.addItem(makeClipItem(streams, texts, htmlTexts, i));
8214 }
8215
8216 setClipData(clipData);
8217 addFlags(FLAG_GRANT_READ_URI_PERMISSION);
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07008218 return true;
Jeff Sharkeydd471e62012-05-01 13:07:01 -07008219 }
Jeff Sharkeyf27ea662012-03-27 10:34:24 -07008220 } catch (ClassCastException e) {
Jeff Sharkeyf27ea662012-03-27 10:34:24 -07008221 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008222 } else if (MediaStore.ACTION_IMAGE_CAPTURE.equals(action)
8223 || MediaStore.ACTION_IMAGE_CAPTURE_SECURE.equals(action)
8224 || MediaStore.ACTION_VIDEO_CAPTURE.equals(action)) {
8225 final Uri output;
8226 try {
8227 output = getParcelableExtra(MediaStore.EXTRA_OUTPUT);
8228 } catch (ClassCastException e) {
8229 return false;
8230 }
8231 if (output != null) {
8232 setClipData(ClipData.newRawUri("", output));
8233 addFlags(FLAG_GRANT_WRITE_URI_PERMISSION|FLAG_GRANT_READ_URI_PERMISSION);
8234 return true;
8235 }
Jeff Sharkey678d04f2012-03-23 15:41:58 -07008236 }
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07008237
8238 return false;
Jeff Sharkey678d04f2012-03-23 15:41:58 -07008239 }
Dianne Hackbornac4243f2012-04-13 17:32:18 -07008240
8241 private static ClipData.Item makeClipItem(ArrayList<Uri> streams, ArrayList<CharSequence> texts,
8242 ArrayList<String> htmlTexts, int which) {
8243 Uri uri = streams != null ? streams.get(which) : null;
8244 CharSequence text = texts != null ? texts.get(which) : null;
8245 String htmlText = htmlTexts != null ? htmlTexts.get(which) : null;
8246 return new ClipData.Item(text, htmlText, null, uri);
8247 }
Craig Mautnerd00f4742014-03-12 14:17:26 -07008248
8249 /** @hide */
8250 public boolean isDocument() {
8251 return (mFlags & FLAG_ACTIVITY_NEW_DOCUMENT) == FLAG_ACTIVITY_NEW_DOCUMENT;
8252 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008253}