blob: 30f2c948df966d8541d16717595a4e3bce6a0eae [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
Tor Norbye7b9c9122013-05-30 16:48:33 -070019import android.annotation.AnyRes;
Tor Norbyed9273d62013-05-30 15:59:53 -070020import android.annotation.IntDef;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070021import android.annotation.SdkConstant;
22import android.annotation.SdkConstant.SdkConstantType;
Jason Monk2f68e8a2016-02-23 17:57:28 -050023import android.annotation.SystemApi;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070024import android.content.pm.ActivityInfo;
Jason Monk2f68e8a2016-02-23 17:57:28 -050025import android.content.pm.ApplicationInfo;
Jeff Sharkeycf3f0a12016-03-17 19:57:58 -060026import android.content.pm.ComponentInfo;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070027import android.content.pm.PackageManager;
28import android.content.pm.ResolveInfo;
29import android.content.res.Resources;
30import android.content.res.TypedArray;
Joe Onoratoc7a63ee2009-12-02 21:13:17 -080031import android.graphics.Rect;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070032import android.net.Uri;
Jeff Sharkeycf3f0a12016-03-17 19:57:58 -060033import android.os.Build;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070034import android.os.Bundle;
35import android.os.IBinder;
36import android.os.Parcel;
37import android.os.Parcelable;
Nicolas Prevotc4fc00a2014-10-31 12:01:32 +000038import android.os.Process;
Jason Monk2f68e8a2016-02-23 17:57:28 -050039import android.os.ResultReceiver;
40import android.os.ShellCommand;
Jeff Sharkeya14acd22013-04-02 18:27:45 -070041import android.os.StrictMode;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +010042import android.os.UserHandle;
Jeff Sharkeybd3b9022013-08-20 15:20:04 -070043import android.provider.DocumentsContract;
Jeff Sharkeyadef88a2013-10-15 13:54:44 -070044import android.provider.DocumentsProvider;
Jason Monk2f68e8a2016-02-23 17:57:28 -050045import android.provider.MediaStore;
Jeff Sharkeyadef88a2013-10-15 13:54:44 -070046import android.provider.OpenableColumns;
Jason Monk2f68e8a2016-02-23 17:57:28 -050047import android.util.ArraySet;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070048import android.util.AttributeSet;
49import android.util.Log;
Dianne Hackborn2269d1572010-02-24 19:54:22 -080050import com.android.internal.util.XmlUtils;
Jason Monk2f68e8a2016-02-23 17:57:28 -050051import org.xmlpull.v1.XmlPullParser;
52import org.xmlpull.v1.XmlPullParserException;
Craig Mautner21d24a22014-04-23 11:45:37 -070053import org.xmlpull.v1.XmlSerializer;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070054
55import java.io.IOException;
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -080056import java.io.PrintWriter;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070057import java.io.Serializable;
Tor Norbyed9273d62013-05-30 15:59:53 -070058import java.lang.annotation.Retention;
59import java.lang.annotation.RetentionPolicy;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070060import java.net.URISyntaxException;
61import java.util.ArrayList;
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -080062import java.util.HashSet;
Dianne Hackborn221ea892013-08-04 16:50:16 -070063import java.util.List;
Nick Pellyccae4122012-01-09 14:12:58 -080064import java.util.Locale;
Christopher Tate63d9ae12014-06-19 19:07:26 -070065import java.util.Objects;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070066import java.util.Set;
67
Jason Monk2f68e8a2016-02-23 17:57:28 -050068import static android.content.ContentProvider.maybeAddUserId;
69
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070070/**
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}
Andrei Stingaceanu69d5ebc2016-01-14 12:59:03 +0000541 * <li> {@link #ACTION_PACKAGES_SUSPENDED}
542 * <li> {@link #ACTION_PACKAGES_UNSUSPENDED}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700543 * <li> {@link #ACTION_UID_REMOVED}
544 * <li> {@link #ACTION_BATTERY_CHANGED}
Cliff Spradlinfda6fae2008-10-22 20:29:16 -0700545 * <li> {@link #ACTION_POWER_CONNECTED}
Romain Guy4969af72009-06-17 10:53:19 -0700546 * <li> {@link #ACTION_POWER_DISCONNECTED}
547 * <li> {@link #ACTION_SHUTDOWN}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700548 * </ul>
549 *
550 * <h3>Standard Categories</h3>
551 *
552 * <p>These are the current standard categories that can be used to further
553 * clarify an Intent via {@link #addCategory}.
554 *
555 * <ul>
556 * <li> {@link #CATEGORY_DEFAULT}
557 * <li> {@link #CATEGORY_BROWSABLE}
558 * <li> {@link #CATEGORY_TAB}
559 * <li> {@link #CATEGORY_ALTERNATIVE}
560 * <li> {@link #CATEGORY_SELECTED_ALTERNATIVE}
561 * <li> {@link #CATEGORY_LAUNCHER}
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800562 * <li> {@link #CATEGORY_INFO}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700563 * <li> {@link #CATEGORY_HOME}
564 * <li> {@link #CATEGORY_PREFERENCE}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700565 * <li> {@link #CATEGORY_TEST}
Mike Lockwood9092ab42009-09-16 13:01:32 -0400566 * <li> {@link #CATEGORY_CAR_DOCK}
567 * <li> {@link #CATEGORY_DESK_DOCK}
Praveen Bharathi21e941b2010-10-06 15:23:14 -0500568 * <li> {@link #CATEGORY_LE_DESK_DOCK}
569 * <li> {@link #CATEGORY_HE_DESK_DOCK}
Bernd Holzheyaea4b672010-03-31 09:46:13 +0200570 * <li> {@link #CATEGORY_CAR_MODE}
Patrick Dubroy6dabe242010-08-30 10:43:47 -0700571 * <li> {@link #CATEGORY_APP_MARKET}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700572 * </ul>
573 *
574 * <h3>Standard Extra Data</h3>
575 *
576 * <p>These are the current standard fields that can be used as extra data via
577 * {@link #putExtra}.
578 *
579 * <ul>
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800580 * <li> {@link #EXTRA_ALARM_COUNT}
581 * <li> {@link #EXTRA_BCC}
582 * <li> {@link #EXTRA_CC}
583 * <li> {@link #EXTRA_CHANGED_COMPONENT_NAME}
584 * <li> {@link #EXTRA_DATA_REMOVED}
585 * <li> {@link #EXTRA_DOCK_STATE}
Praveen Bharathi21e941b2010-10-06 15:23:14 -0500586 * <li> {@link #EXTRA_DOCK_STATE_HE_DESK}
587 * <li> {@link #EXTRA_DOCK_STATE_LE_DESK}
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800588 * <li> {@link #EXTRA_DOCK_STATE_CAR}
589 * <li> {@link #EXTRA_DOCK_STATE_DESK}
590 * <li> {@link #EXTRA_DOCK_STATE_UNDOCKED}
591 * <li> {@link #EXTRA_DONT_KILL_APP}
592 * <li> {@link #EXTRA_EMAIL}
593 * <li> {@link #EXTRA_INITIAL_INTENTS}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700594 * <li> {@link #EXTRA_INTENT}
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800595 * <li> {@link #EXTRA_KEY_EVENT}
rich cannings706e8ba2012-08-20 13:20:14 -0700596 * <li> {@link #EXTRA_ORIGINATING_URI}
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800597 * <li> {@link #EXTRA_PHONE_NUMBER}
rich cannings368ed012012-06-07 15:37:57 -0700598 * <li> {@link #EXTRA_REFERRER}
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800599 * <li> {@link #EXTRA_REMOTE_INTENT_TOKEN}
600 * <li> {@link #EXTRA_REPLACING}
601 * <li> {@link #EXTRA_SHORTCUT_ICON}
602 * <li> {@link #EXTRA_SHORTCUT_ICON_RESOURCE}
603 * <li> {@link #EXTRA_SHORTCUT_INTENT}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700604 * <li> {@link #EXTRA_STREAM}
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800605 * <li> {@link #EXTRA_SHORTCUT_NAME}
606 * <li> {@link #EXTRA_SUBJECT}
607 * <li> {@link #EXTRA_TEMPLATE}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700608 * <li> {@link #EXTRA_TEXT}
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800609 * <li> {@link #EXTRA_TITLE}
610 * <li> {@link #EXTRA_UID}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700611 * </ul>
612 *
613 * <h3>Flags</h3>
614 *
615 * <p>These are the possible flags that can be used in the Intent via
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800616 * {@link #setFlags} and {@link #addFlags}. See {@link #setFlags} for a list
617 * of all possible flags.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700618 */
Dianne Hackbornee0511d2009-12-21 18:08:13 -0800619public class Intent implements Parcelable, Cloneable {
Craig Mautner21d24a22014-04-23 11:45:37 -0700620 private static final String ATTR_ACTION = "action";
621 private static final String TAG_CATEGORIES = "categories";
622 private static final String ATTR_CATEGORY = "category";
623 private static final String TAG_EXTRA = "extra";
624 private static final String ATTR_TYPE = "type";
625 private static final String ATTR_COMPONENT = "component";
626 private static final String ATTR_DATA = "data";
627 private static final String ATTR_FLAGS = "flags";
628
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700629 // ---------------------------------------------------------------------
630 // ---------------------------------------------------------------------
631 // Standard intent activity actions (see action variable).
632
633 /**
634 * Activity Action: Start as a main entry point, does not expect to
635 * receive data.
636 * <p>Input: nothing
637 * <p>Output: nothing
638 */
639 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
640 public static final String ACTION_MAIN = "android.intent.action.MAIN";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800641
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700642 /**
643 * Activity Action: Display the data to the user. This is the most common
644 * action performed on data -- it is the generic action you can use on
645 * a piece of data to get the most reasonable thing to occur. For example,
646 * when used on a contacts entry it will view the entry; when used on a
647 * mailto: URI it will bring up a compose window filled with the information
648 * supplied by the URI; when used with a tel: URI it will invoke the
649 * dialer.
650 * <p>Input: {@link #getData} is URI from which to retrieve data.
651 * <p>Output: nothing.
652 */
653 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
654 public static final String ACTION_VIEW = "android.intent.action.VIEW";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800655
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700656 /**
657 * A synonym for {@link #ACTION_VIEW}, the "standard" action that is
658 * performed on a piece of data.
659 */
660 public static final String ACTION_DEFAULT = ACTION_VIEW;
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800661
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700662 /**
Tomasz Mikolajewski319fb492016-01-20 12:24:01 +0900663 * Activity Action: Quick view the data. Launches a quick viewer for
664 * a URI or a list of URIs.
Tomasz Mikolajewskife023132016-03-10 17:42:35 +0900665 * <p>Activities handling this intent action should handle the vast majority of
666 * MIME types rather than only specific ones.
Tomasz Mikolajewski319fb492016-01-20 12:24:01 +0900667 * <p>Input: {@link #getData} is a mandatory content URI of the item to
668 * preview. {@link #getClipData} contains an optional list of content URIs
669 * if there is more than one item to preview. {@link #EXTRA_INDEX} is an
670 * optional index of the URI in the clip data to show first.
Steve McKayc78bcb82015-07-31 14:35:22 -0700671 * <p>Output: nothing.
Steve McKayc78bcb82015-07-31 14:35:22 -0700672 */
673 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
674 public static final String ACTION_QUICK_VIEW = "android.intent.action.QUICK_VIEW";
675
676 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700677 * Used to indicate that some piece of data should be attached to some other
678 * place. For example, image data could be attached to a contact. It is up
679 * to the recipient to decide where the data should be attached; the intent
680 * does not specify the ultimate destination.
681 * <p>Input: {@link #getData} is URI of data to be attached.
682 * <p>Output: nothing.
683 */
684 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
685 public static final String ACTION_ATTACH_DATA = "android.intent.action.ATTACH_DATA";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800686
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700687 /**
688 * Activity Action: Provide explicit editable access to the given data.
689 * <p>Input: {@link #getData} is URI of data to be edited.
690 * <p>Output: nothing.
691 */
692 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
693 public static final String ACTION_EDIT = "android.intent.action.EDIT";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800694
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700695 /**
696 * Activity Action: Pick an existing item, or insert a new item, and then edit it.
697 * <p>Input: {@link #getType} is the desired MIME type of the item to create or edit.
698 * The extras can contain type specific data to pass through to the editing/creating
699 * activity.
700 * <p>Output: The URI of the item that was picked. This must be a content:
701 * URI so that any receiver can access it.
702 */
703 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
704 public static final String ACTION_INSERT_OR_EDIT = "android.intent.action.INSERT_OR_EDIT";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800705
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700706 /**
707 * Activity Action: Pick an item from the data, returning what was selected.
708 * <p>Input: {@link #getData} is URI containing a directory of data
709 * (vnd.android.cursor.dir/*) from which to pick an item.
710 * <p>Output: The URI of the item that was picked.
711 */
712 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
713 public static final String ACTION_PICK = "android.intent.action.PICK";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800714
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700715 /**
716 * Activity Action: Creates a shortcut.
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800717 * <p>Input: Nothing.</p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700718 * <p>Output: An Intent representing the shortcut. The intent must contain three
719 * extras: SHORTCUT_INTENT (value: Intent), SHORTCUT_NAME (value: String),
720 * and SHORTCUT_ICON (value: Bitmap) or SHORTCUT_ICON_RESOURCE
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800721 * (value: ShortcutIconResource).</p>
722 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700723 * @see #EXTRA_SHORTCUT_INTENT
724 * @see #EXTRA_SHORTCUT_NAME
725 * @see #EXTRA_SHORTCUT_ICON
726 * @see #EXTRA_SHORTCUT_ICON_RESOURCE
727 * @see android.content.Intent.ShortcutIconResource
728 */
729 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
730 public static final String ACTION_CREATE_SHORTCUT = "android.intent.action.CREATE_SHORTCUT";
731
732 /**
733 * The name of the extra used to define the Intent of a shortcut.
734 *
735 * @see #ACTION_CREATE_SHORTCUT
736 */
737 public static final String EXTRA_SHORTCUT_INTENT = "android.intent.extra.shortcut.INTENT";
738 /**
739 * The name of the extra used to define the name of a shortcut.
740 *
741 * @see #ACTION_CREATE_SHORTCUT
742 */
743 public static final String EXTRA_SHORTCUT_NAME = "android.intent.extra.shortcut.NAME";
744 /**
745 * The name of the extra used to define the icon, as a Bitmap, of a shortcut.
746 *
747 * @see #ACTION_CREATE_SHORTCUT
748 */
749 public static final String EXTRA_SHORTCUT_ICON = "android.intent.extra.shortcut.ICON";
750 /**
751 * The name of the extra used to define the icon, as a ShortcutIconResource, of a shortcut.
752 *
753 * @see #ACTION_CREATE_SHORTCUT
754 * @see android.content.Intent.ShortcutIconResource
755 */
756 public static final String EXTRA_SHORTCUT_ICON_RESOURCE =
757 "android.intent.extra.shortcut.ICON_RESOURCE";
758
759 /**
Jason Monk2f68e8a2016-02-23 17:57:28 -0500760 * An activity that provides a user interface for adjusting application preferences.
761 * Optional but recommended settings for all applications which have settings.
762 */
763 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
764 public static final String ACTION_APPLICATION_PREFERENCES
765 = "android.intent.action.APPLICATION_PREFERENCES";
766
767 /**
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800768 * Represents a shortcut/live folder icon resource.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700769 *
770 * @see Intent#ACTION_CREATE_SHORTCUT
771 * @see Intent#EXTRA_SHORTCUT_ICON_RESOURCE
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800772 * @see android.provider.LiveFolders#ACTION_CREATE_LIVE_FOLDER
773 * @see android.provider.LiveFolders#EXTRA_LIVE_FOLDER_ICON
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700774 */
775 public static class ShortcutIconResource implements Parcelable {
776 /**
777 * The package name of the application containing the icon.
778 */
779 public String packageName;
780
781 /**
782 * The resource name of the icon, including package, name and type.
783 */
784 public String resourceName;
785
786 /**
787 * Creates a new ShortcutIconResource for the specified context and resource
788 * identifier.
789 *
790 * @param context The context of the application.
Tor Norbye7b9c9122013-05-30 16:48:33 -0700791 * @param resourceId The resource identifier for the icon.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700792 * @return A new ShortcutIconResource with the specified's context package name
Tor Norbye7b9c9122013-05-30 16:48:33 -0700793 * and icon resource identifier.``
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700794 */
Tor Norbye7b9c9122013-05-30 16:48:33 -0700795 public static ShortcutIconResource fromContext(Context context, @AnyRes int resourceId) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700796 ShortcutIconResource icon = new ShortcutIconResource();
797 icon.packageName = context.getPackageName();
798 icon.resourceName = context.getResources().getResourceName(resourceId);
799 return icon;
800 }
801
802 /**
803 * Used to read a ShortcutIconResource from a Parcel.
804 */
805 public static final Parcelable.Creator<ShortcutIconResource> CREATOR =
806 new Parcelable.Creator<ShortcutIconResource>() {
807
808 public ShortcutIconResource createFromParcel(Parcel source) {
809 ShortcutIconResource icon = new ShortcutIconResource();
810 icon.packageName = source.readString();
811 icon.resourceName = source.readString();
812 return icon;
813 }
814
815 public ShortcutIconResource[] newArray(int size) {
816 return new ShortcutIconResource[size];
817 }
818 };
819
820 /**
821 * No special parcel contents.
822 */
823 public int describeContents() {
824 return 0;
825 }
826
827 public void writeToParcel(Parcel dest, int flags) {
828 dest.writeString(packageName);
829 dest.writeString(resourceName);
830 }
831
832 @Override
833 public String toString() {
834 return resourceName;
835 }
836 }
837
838 /**
839 * Activity Action: Display an activity chooser, allowing the user to pick
840 * what they want to before proceeding. This can be used as an alternative
841 * to the standard activity picker that is displayed by the system when
842 * you try to start an activity with multiple possible matches, with these
843 * differences in behavior:
844 * <ul>
845 * <li>You can specify the title that will appear in the activity chooser.
846 * <li>The user does not have the option to make one of the matching
847 * activities a preferred activity, and all possible activities will
848 * always be shown even if one of them is currently marked as the
849 * preferred activity.
850 * </ul>
851 * <p>
852 * This action should be used when the user will naturally expect to
853 * select an activity in order to proceed. An example if when not to use
854 * it is when the user clicks on a "mailto:" link. They would naturally
855 * expect to go directly to their mail app, so startActivity() should be
856 * called directly: it will
857 * either launch the current preferred app, or put up a dialog allowing the
858 * user to pick an app to use and optionally marking that as preferred.
859 * <p>
860 * In contrast, if the user is selecting a menu item to send a picture
861 * they are viewing to someone else, there are many different things they
862 * may want to do at this point: send it through e-mail, upload it to a
863 * web service, etc. In this case the CHOOSER action should be used, to
864 * always present to the user a list of the things they can do, with a
865 * nice title given by the caller such as "Send this photo with:".
866 * <p>
Dianne Hackborne302a162012-05-15 14:58:32 -0700867 * If you need to grant URI permissions through a chooser, you must specify
868 * the permissions to be granted on the ACTION_CHOOSER Intent
869 * <em>in addition</em> to the EXTRA_INTENT inside. This means using
870 * {@link #setClipData} to specify the URIs to be granted as well as
871 * {@link #FLAG_GRANT_READ_URI_PERMISSION} and/or
872 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION} as appropriate.
873 * <p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700874 * As a convenience, an Intent of this form can be created with the
875 * {@link #createChooser} function.
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -0700876 * <p>
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -0700877 * Input: No data should be specified. get*Extra must have
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700878 * a {@link #EXTRA_INTENT} field containing the Intent being executed,
879 * and can optionally have a {@link #EXTRA_TITLE} field containing the
880 * title text to display in the chooser.
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -0700881 * <p>
882 * Output: Depends on the protocol of {@link #EXTRA_INTENT}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700883 */
884 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
885 public static final String ACTION_CHOOSER = "android.intent.action.CHOOSER";
886
887 /**
888 * Convenience function for creating a {@link #ACTION_CHOOSER} Intent.
889 *
Dianne Hackborne302a162012-05-15 14:58:32 -0700890 * <p>Builds a new {@link #ACTION_CHOOSER} Intent that wraps the given
891 * target intent, also optionally supplying a title. If the target
892 * intent has specified {@link #FLAG_GRANT_READ_URI_PERMISSION} or
893 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, then these flags will also be
894 * set in the returned chooser intent, with its ClipData set appropriately:
895 * either a direct reflection of {@link #getClipData()} if that is non-null,
John Spurlock33900182014-01-02 11:04:18 -0500896 * or a new ClipData built from {@link #getData()}.
Dianne Hackborne302a162012-05-15 14:58:32 -0700897 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700898 * @param target The Intent that the user will be selecting an activity
899 * to perform.
900 * @param title Optional title that will be displayed in the chooser.
901 * @return Return a new Intent object that you can hand to
902 * {@link Context#startActivity(Intent) Context.startActivity()} and
903 * related methods.
904 */
905 public static Intent createChooser(Intent target, CharSequence title) {
Adam Powell0b3c1122014-10-09 12:50:14 -0700906 return createChooser(target, title, null);
907 }
908
909 /**
910 * Convenience function for creating a {@link #ACTION_CHOOSER} Intent.
911 *
912 * <p>Builds a new {@link #ACTION_CHOOSER} Intent that wraps the given
913 * target intent, also optionally supplying a title. If the target
914 * intent has specified {@link #FLAG_GRANT_READ_URI_PERMISSION} or
915 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, then these flags will also be
916 * set in the returned chooser intent, with its ClipData set appropriately:
917 * either a direct reflection of {@link #getClipData()} if that is non-null,
918 * or a new ClipData built from {@link #getData()}.</p>
919 *
920 * <p>The caller may optionally supply an {@link IntentSender} to receive a callback
921 * when the user makes a choice. This can be useful if the calling application wants
922 * to remember the last chosen target and surface it as a more prominent or one-touch
923 * affordance elsewhere in the UI for next time.</p>
924 *
925 * @param target The Intent that the user will be selecting an activity
926 * to perform.
927 * @param title Optional title that will be displayed in the chooser.
928 * @param sender Optional IntentSender to be called when a choice is made.
929 * @return Return a new Intent object that you can hand to
930 * {@link Context#startActivity(Intent) Context.startActivity()} and
931 * related methods.
932 */
933 public static Intent createChooser(Intent target, CharSequence title, IntentSender sender) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700934 Intent intent = new Intent(ACTION_CHOOSER);
935 intent.putExtra(EXTRA_INTENT, target);
936 if (title != null) {
937 intent.putExtra(EXTRA_TITLE, title);
938 }
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -0700939
Adam Powell0b3c1122014-10-09 12:50:14 -0700940 if (sender != null) {
941 intent.putExtra(EXTRA_CHOSEN_COMPONENT_INTENT_SENDER, sender);
942 }
943
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -0700944 // Migrate any clip data and flags from target.
Jeff Sharkey846318a2014-04-04 12:12:41 -0700945 int permFlags = target.getFlags() & (FLAG_GRANT_READ_URI_PERMISSION
946 | FLAG_GRANT_WRITE_URI_PERMISSION | FLAG_GRANT_PERSISTABLE_URI_PERMISSION
947 | FLAG_GRANT_PREFIX_URI_PERMISSION);
Dianne Hackborne302a162012-05-15 14:58:32 -0700948 if (permFlags != 0) {
949 ClipData targetClipData = target.getClipData();
950 if (targetClipData == null && target.getData() != null) {
951 ClipData.Item item = new ClipData.Item(target.getData());
952 String[] mimeTypes;
953 if (target.getType() != null) {
954 mimeTypes = new String[] { target.getType() };
955 } else {
956 mimeTypes = new String[] { };
957 }
958 targetClipData = new ClipData(null, mimeTypes, item);
959 }
960 if (targetClipData != null) {
961 intent.setClipData(targetClipData);
962 intent.addFlags(permFlags);
963 }
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -0700964 }
Dianne Hackborne302a162012-05-15 14:58:32 -0700965
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700966 return intent;
967 }
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -0700968
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700969 /**
970 * Activity Action: Allow the user to select a particular kind of data and
971 * return it. This is different than {@link #ACTION_PICK} in that here we
972 * just say what kind of data is desired, not a URI of existing data from
Dianne Hackbornfdb3f092013-01-28 15:10:48 -0800973 * which the user can pick. An ACTION_GET_CONTENT could allow the user to
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700974 * create the data as it runs (for example taking a picture or recording a
Ken Wakasaf76a50c2012-03-09 19:56:35 +0900975 * sound), let them browse over the web and download the desired data,
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700976 * etc.
977 * <p>
Ken Wakasaf76a50c2012-03-09 19:56:35 +0900978 * 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 -0700979 * of data, such as a person contact, you set the MIME type to the kind of
980 * data you want and launch it with {@link Context#startActivity(Intent)}.
981 * The system will then launch the best application to select that kind
982 * of data for you.
983 * <p>
984 * You may also be interested in any of a set of types of content the user
985 * can pick. For example, an e-mail application that wants to allow the
986 * user to add an attachment to an e-mail message can use this action to
987 * bring up a list of all of the types of content the user can attach.
988 * <p>
989 * In this case, you should wrap the GET_CONTENT intent with a chooser
990 * (through {@link #createChooser}), which will give the proper interface
991 * for the user to pick how to send your data and allow you to specify
992 * a prompt indicating what they are doing. You will usually specify a
993 * broad MIME type (such as image/* or {@literal *}/*), resulting in a
994 * broad range of content types the user can select from.
995 * <p>
Ken Wakasaf76a50c2012-03-09 19:56:35 +0900996 * When using such a broad GET_CONTENT action, it is often desirable to
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700997 * only pick from data that can be represented as a stream. This is
998 * accomplished by requiring the {@link #CATEGORY_OPENABLE} in the Intent.
999 * <p>
Dianne Hackbornc4d0e6f2011-01-25 14:55:06 -08001000 * Callers can optionally specify {@link #EXTRA_LOCAL_ONLY} to request that
Ken Wakasaf76a50c2012-03-09 19:56:35 +09001001 * the launched content chooser only returns results representing data that
Dianne Hackbornc4d0e6f2011-01-25 14:55:06 -08001002 * is locally available on the device. For example, if this extra is set
1003 * to true then an image picker should not show any pictures that are available
1004 * from a remote server but not already on the local device (thus requiring
1005 * they be downloaded when opened).
1006 * <p>
Dianne Hackbornfdb3f092013-01-28 15:10:48 -08001007 * If the caller can handle multiple returned items (the user performing
1008 * multiple selection), then it can specify {@link #EXTRA_ALLOW_MULTIPLE}
1009 * to indicate this.
1010 * <p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001011 * Input: {@link #getType} is the desired MIME type to retrieve. Note
1012 * that no URI is supplied in the intent, as there are no constraints on
1013 * where the returned data originally comes from. You may also include the
1014 * {@link #CATEGORY_OPENABLE} if you can only accept data that can be
Dianne Hackbornc4d0e6f2011-01-25 14:55:06 -08001015 * opened as a stream. You may use {@link #EXTRA_LOCAL_ONLY} to limit content
Dianne Hackbornfdb3f092013-01-28 15:10:48 -08001016 * selection to local data. You may use {@link #EXTRA_ALLOW_MULTIPLE} to
1017 * allow the user to select multiple items.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001018 * <p>
1019 * Output: The URI of the item that was picked. This must be a content:
1020 * URI so that any receiver can access it.
1021 */
1022 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1023 public static final String ACTION_GET_CONTENT = "android.intent.action.GET_CONTENT";
1024 /**
1025 * Activity Action: Dial a number as specified by the data. This shows a
1026 * UI with the number being dialed, allowing the user to explicitly
1027 * initiate the call.
1028 * <p>Input: If nothing, an empty dialer is started; else {@link #getData}
1029 * is URI of a phone number to be dialed or a tel: URI of an explicit phone
1030 * number.
1031 * <p>Output: nothing.
1032 */
1033 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1034 public static final String ACTION_DIAL = "android.intent.action.DIAL";
1035 /**
1036 * Activity Action: Perform a call to someone specified by the data.
1037 * <p>Input: If nothing, an empty dialer is started; else {@link #getData}
1038 * is URI of a phone number to be dialed or a tel: URI of an explicit phone
1039 * number.
1040 * <p>Output: nothing.
1041 *
1042 * <p>Note: there will be restrictions on which applications can initiate a
1043 * call; most applications should use the {@link #ACTION_DIAL}.
1044 * <p>Note: this Intent <strong>cannot</strong> be used to call emergency
1045 * numbers. Applications can <strong>dial</strong> emergency numbers using
1046 * {@link #ACTION_DIAL}, however.
Svetoslav7008b512015-06-24 18:47:07 -07001047 *
Dianne Hackborn0e3de6c2015-07-29 15:20:21 -07001048 * <p>Note: if you app targets {@link android.os.Build.VERSION_CODES#M M}
Svetoslav7008b512015-06-24 18:47:07 -07001049 * and above and declares as using the {@link android.Manifest.permission#CALL_PHONE}
Svet Ganov7121e182015-07-13 22:38:12 -07001050 * permission which is not granted, then attempting to use this action will
Svetoslav7008b512015-06-24 18:47:07 -07001051 * result in a {@link java.lang.SecurityException}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001052 */
1053 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1054 public static final String ACTION_CALL = "android.intent.action.CALL";
1055 /**
1056 * Activity Action: Perform a call to an emergency number specified by the
1057 * data.
1058 * <p>Input: {@link #getData} is URI of a phone number to be dialed or a
1059 * tel: URI of an explicit phone number.
1060 * <p>Output: nothing.
1061 * @hide
1062 */
1063 public static final String ACTION_CALL_EMERGENCY = "android.intent.action.CALL_EMERGENCY";
1064 /**
1065 * Activity action: Perform a call to any number (emergency or not)
1066 * specified by the data.
1067 * <p>Input: {@link #getData} is URI of a phone number to be dialed or a
1068 * tel: URI of an explicit phone number.
1069 * <p>Output: nothing.
1070 * @hide
1071 */
1072 public static final String ACTION_CALL_PRIVILEGED = "android.intent.action.CALL_PRIVILEGED";
1073 /**
Santos Cordon15a13782015-03-31 18:32:31 -07001074 * Activity action: Activate the current SIM card. If SIM cards do not require activation,
1075 * sending this intent is a no-op.
1076 * <p>Input: No data should be specified. get*Extra may have an optional
1077 * {@link #EXTRA_SIM_ACTIVATION_RESPONSE} field containing a PendingIntent through which to
1078 * send the activation result.
1079 * <p>Output: nothing.
1080 * @hide
1081 */
1082 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1083 public static final String ACTION_SIM_ACTIVATION_REQUEST =
1084 "android.intent.action.SIM_ACTIVATION_REQUEST";
1085 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001086 * Activity Action: Send a message to someone specified by the data.
1087 * <p>Input: {@link #getData} is URI describing the target.
1088 * <p>Output: nothing.
1089 */
1090 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1091 public static final String ACTION_SENDTO = "android.intent.action.SENDTO";
1092 /**
1093 * Activity Action: Deliver some data to someone else. Who the data is
1094 * being delivered to is not specified; it is up to the receiver of this
1095 * action to ask the user where the data should be sent.
1096 * <p>
1097 * When launching a SEND intent, you should usually wrap it in a chooser
1098 * (through {@link #createChooser}), which will give the proper interface
1099 * for the user to pick how to send your data and allow you to specify
1100 * a prompt indicating what they are doing.
1101 * <p>
1102 * Input: {@link #getType} is the MIME type of the data being sent.
1103 * get*Extra can have either a {@link #EXTRA_TEXT}
1104 * or {@link #EXTRA_STREAM} field, containing the data to be sent. If
1105 * using EXTRA_TEXT, the MIME type should be "text/plain"; otherwise it
1106 * should be the MIME type of the data in EXTRA_STREAM. Use {@literal *}/*
1107 * if the MIME type is unknown (this will only allow senders that can
Dianne Hackbornacb69bb2012-04-13 15:36:06 -07001108 * handle generic data streams). If using {@link #EXTRA_TEXT}, you can
1109 * also optionally supply {@link #EXTRA_HTML_TEXT} for clients to retrieve
1110 * your text with HTML formatting.
1111 * <p>
1112 * As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN}, the data
1113 * being sent can be supplied through {@link #setClipData(ClipData)}. This
1114 * allows you to use {@link #FLAG_GRANT_READ_URI_PERMISSION} when sharing
1115 * content: URIs and other advanced features of {@link ClipData}. If
1116 * using this approach, you still must supply the same data through the
1117 * {@link #EXTRA_TEXT} or {@link #EXTRA_STREAM} fields described below
1118 * for compatibility with old applications. If you don't set a ClipData,
1119 * it will be copied there for you when calling {@link Context#startActivity(Intent)}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001120 * <p>
1121 * Optional standard extras, which may be interpreted by some recipients as
1122 * appropriate, are: {@link #EXTRA_EMAIL}, {@link #EXTRA_CC},
1123 * {@link #EXTRA_BCC}, {@link #EXTRA_SUBJECT}.
1124 * <p>
1125 * Output: nothing.
1126 */
1127 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1128 public static final String ACTION_SEND = "android.intent.action.SEND";
1129 /**
Wu-cheng Li649f99e2009-06-17 14:29:57 +08001130 * Activity Action: Deliver multiple data to someone else.
1131 * <p>
Dianne Hackbornacb69bb2012-04-13 15:36:06 -07001132 * Like {@link #ACTION_SEND}, except the data is multiple.
Wu-cheng Li649f99e2009-06-17 14:29:57 +08001133 * <p>
1134 * Input: {@link #getType} is the MIME type of the data being sent.
1135 * get*ArrayListExtra can have either a {@link #EXTRA_TEXT} or {@link
Dianne Hackbornacb69bb2012-04-13 15:36:06 -07001136 * #EXTRA_STREAM} field, containing the data to be sent. If using
1137 * {@link #EXTRA_TEXT}, you can also optionally supply {@link #EXTRA_HTML_TEXT}
1138 * for clients to retrieve your text with HTML formatting.
Wu-cheng Li649f99e2009-06-17 14:29:57 +08001139 * <p>
Chih-Chung Chang5962d272009-09-04 14:36:01 +08001140 * Multiple types are supported, and receivers should handle mixed types
1141 * whenever possible. The right way for the receiver to check them is to
1142 * use the content resolver on each URI. The intent sender should try to
1143 * put the most concrete mime type in the intent type, but it can fall
1144 * back to {@literal <type>/*} or {@literal *}/* as needed.
1145 * <p>
1146 * e.g. if you are sending image/jpg and image/jpg, the intent's type can
1147 * be image/jpg, but if you are sending image/jpg and image/png, then the
1148 * intent's type should be image/*.
1149 * <p>
Dianne Hackbornacb69bb2012-04-13 15:36:06 -07001150 * As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN}, the data
1151 * being sent can be supplied through {@link #setClipData(ClipData)}. This
1152 * allows you to use {@link #FLAG_GRANT_READ_URI_PERMISSION} when sharing
1153 * content: URIs and other advanced features of {@link ClipData}. If
1154 * using this approach, you still must supply the same data through the
1155 * {@link #EXTRA_TEXT} or {@link #EXTRA_STREAM} fields described below
1156 * for compatibility with old applications. If you don't set a ClipData,
1157 * it will be copied there for you when calling {@link Context#startActivity(Intent)}.
1158 * <p>
Wu-cheng Li649f99e2009-06-17 14:29:57 +08001159 * Optional standard extras, which may be interpreted by some recipients as
1160 * appropriate, are: {@link #EXTRA_EMAIL}, {@link #EXTRA_CC},
1161 * {@link #EXTRA_BCC}, {@link #EXTRA_SUBJECT}.
1162 * <p>
1163 * Output: nothing.
1164 */
1165 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1166 public static final String ACTION_SEND_MULTIPLE = "android.intent.action.SEND_MULTIPLE";
1167 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001168 * Activity Action: Handle an incoming phone call.
1169 * <p>Input: nothing.
1170 * <p>Output: nothing.
1171 */
1172 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1173 public static final String ACTION_ANSWER = "android.intent.action.ANSWER";
1174 /**
1175 * Activity Action: Insert an empty item into the given container.
1176 * <p>Input: {@link #getData} is URI of the directory (vnd.android.cursor.dir/*)
1177 * in which to place the data.
1178 * <p>Output: URI of the new data that was created.
1179 */
1180 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1181 public static final String ACTION_INSERT = "android.intent.action.INSERT";
1182 /**
Dianne Hackborn23fdaf62010-08-06 12:16:55 -07001183 * Activity Action: Create a new item in the given container, initializing it
1184 * from the current contents of the clipboard.
1185 * <p>Input: {@link #getData} is URI of the directory (vnd.android.cursor.dir/*)
1186 * in which to place the data.
1187 * <p>Output: URI of the new data that was created.
1188 */
1189 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1190 public static final String ACTION_PASTE = "android.intent.action.PASTE";
1191 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001192 * Activity Action: Delete the given data from its container.
1193 * <p>Input: {@link #getData} is URI of data to be deleted.
1194 * <p>Output: nothing.
1195 */
1196 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1197 public static final String ACTION_DELETE = "android.intent.action.DELETE";
1198 /**
1199 * Activity Action: Run the data, whatever that means.
1200 * <p>Input: ? (Note: this is currently specific to the test harness.)
1201 * <p>Output: nothing.
1202 */
1203 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1204 public static final String ACTION_RUN = "android.intent.action.RUN";
1205 /**
1206 * Activity Action: Perform a data synchronization.
1207 * <p>Input: ?
1208 * <p>Output: ?
1209 */
1210 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1211 public static final String ACTION_SYNC = "android.intent.action.SYNC";
1212 /**
1213 * Activity Action: Pick an activity given an intent, returning the class
1214 * selected.
1215 * <p>Input: get*Extra field {@link #EXTRA_INTENT} is an Intent
1216 * used with {@link PackageManager#queryIntentActivities} to determine the
1217 * set of activities from which to pick.
1218 * <p>Output: Class name of the activity that was selected.
1219 */
1220 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1221 public static final String ACTION_PICK_ACTIVITY = "android.intent.action.PICK_ACTIVITY";
1222 /**
1223 * Activity Action: Perform a search.
1224 * <p>Input: {@link android.app.SearchManager#QUERY getStringExtra(SearchManager.QUERY)}
1225 * is the text to search for. If empty, simply
1226 * enter your search results Activity with the search UI activated.
1227 * <p>Output: nothing.
1228 */
1229 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1230 public static final String ACTION_SEARCH = "android.intent.action.SEARCH";
1231 /**
Jim Miller7e4ad352009-03-25 18:16:41 -07001232 * Activity Action: Start the platform-defined tutorial
1233 * <p>Input: {@link android.app.SearchManager#QUERY getStringExtra(SearchManager.QUERY)}
1234 * is the text to search for. If empty, simply
1235 * enter your search results Activity with the search UI activated.
1236 * <p>Output: nothing.
1237 */
1238 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1239 public static final String ACTION_SYSTEM_TUTORIAL = "android.intent.action.SYSTEM_TUTORIAL";
1240 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001241 * Activity Action: Perform a web search.
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08001242 * <p>
1243 * Input: {@link android.app.SearchManager#QUERY
1244 * getStringExtra(SearchManager.QUERY)} is the text to search for. If it is
1245 * a url starts with http or https, the site will be opened. If it is plain
1246 * text, Google search will be applied.
1247 * <p>
1248 * Output: nothing.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001249 */
1250 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1251 public static final String ACTION_WEB_SEARCH = "android.intent.action.WEB_SEARCH";
Dianne Hackbornf9c5e0f2013-01-23 14:39:13 -08001252
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001253 /**
Jim Miller07994402012-05-02 14:22:27 -07001254 * Activity Action: Perform assist action.
1255 * <p>
Adam Skory7140a252013-09-11 12:04:58 +01001256 * Input: {@link #EXTRA_ASSIST_PACKAGE}, {@link #EXTRA_ASSIST_CONTEXT}, can provide
1257 * additional optional contextual information about where the user was when they
Dianne Hackborna3acdb32015-06-08 17:07:40 -07001258 * requested the assist; {@link #EXTRA_REFERRER} may be set with additional referrer
1259 * information.
Jim Miller07994402012-05-02 14:22:27 -07001260 * Output: nothing.
1261 */
1262 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1263 public static final String ACTION_ASSIST = "android.intent.action.ASSIST";
Dianne Hackbornf9c5e0f2013-01-23 14:39:13 -08001264
1265 /**
Bjorn Bringertbc086862013-03-01 12:59:24 +00001266 * Activity Action: Perform voice assist action.
1267 * <p>
Adam Skory7140a252013-09-11 12:04:58 +01001268 * Input: {@link #EXTRA_ASSIST_PACKAGE}, {@link #EXTRA_ASSIST_CONTEXT}, can provide
1269 * additional optional contextual information about where the user was when they
Adam Skorydfc7fd72013-08-05 19:23:41 -07001270 * requested the voice assist.
Bjorn Bringertbc086862013-03-01 12:59:24 +00001271 * Output: nothing.
Adam Skory7140a252013-09-11 12:04:58 +01001272 * @hide
Bjorn Bringertbc086862013-03-01 12:59:24 +00001273 */
1274 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1275 public static final String ACTION_VOICE_ASSIST = "android.intent.action.VOICE_ASSIST";
1276
1277 /**
Adam Skory7140a252013-09-11 12:04:58 +01001278 * An optional field on {@link #ACTION_ASSIST} containing the name of the current foreground
1279 * application package at the time the assist was invoked.
Dianne Hackbornf9c5e0f2013-01-23 14:39:13 -08001280 */
1281 public static final String EXTRA_ASSIST_PACKAGE
1282 = "android.intent.extra.ASSIST_PACKAGE";
1283
1284 /**
Dianne Hackborna83ce1d2015-03-11 15:16:13 -07001285 * An optional field on {@link #ACTION_ASSIST} containing the uid of the current foreground
1286 * application package at the time the assist was invoked.
1287 */
1288 public static final String EXTRA_ASSIST_UID
1289 = "android.intent.extra.ASSIST_UID";
1290
1291 /**
Adam Skory7140a252013-09-11 12:04:58 +01001292 * An optional field on {@link #ACTION_ASSIST} and containing additional contextual
1293 * information supplied by the current foreground app at the time of the assist request.
1294 * This is a {@link Bundle} of additional data.
Dianne Hackbornf9c5e0f2013-01-23 14:39:13 -08001295 */
1296 public static final String EXTRA_ASSIST_CONTEXT
1297 = "android.intent.extra.ASSIST_CONTEXT";
1298
Jim Miller07994402012-05-02 14:22:27 -07001299 /**
Michael Wright8ab940a2014-09-01 11:01:27 -07001300 * An optional field on {@link #ACTION_ASSIST} suggesting that the user will likely use a
1301 * keyboard as the primary input device for assistance.
1302 */
1303 public static final String EXTRA_ASSIST_INPUT_HINT_KEYBOARD =
1304 "android.intent.extra.ASSIST_INPUT_HINT_KEYBOARD";
1305
1306 /**
Tim Kilbourn0e5f1102015-06-05 16:18:09 -07001307 * An optional field on {@link #ACTION_ASSIST} containing the InputDevice id
1308 * that was used to invoke the assist.
1309 */
1310 public static final String EXTRA_ASSIST_INPUT_DEVICE_ID =
1311 "android.intent.extra.ASSIST_INPUT_DEVICE_ID";
1312
1313 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001314 * Activity Action: List all available applications
1315 * <p>Input: Nothing.
1316 * <p>Output: nothing.
1317 */
1318 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1319 public static final String ACTION_ALL_APPS = "android.intent.action.ALL_APPS";
1320 /**
1321 * Activity Action: Show settings for choosing wallpaper
1322 * <p>Input: Nothing.
1323 * <p>Output: Nothing.
1324 */
1325 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1326 public static final String ACTION_SET_WALLPAPER = "android.intent.action.SET_WALLPAPER";
1327
1328 /**
1329 * Activity Action: Show activity for reporting a bug.
1330 * <p>Input: Nothing.
1331 * <p>Output: Nothing.
1332 */
1333 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1334 public static final String ACTION_BUG_REPORT = "android.intent.action.BUG_REPORT";
1335
1336 /**
1337 * Activity Action: Main entry point for factory tests. Only used when
1338 * the device is booting in factory test node. The implementing package
1339 * must be installed in the system image.
1340 * <p>Input: nothing
1341 * <p>Output: nothing
1342 */
1343 public static final String ACTION_FACTORY_TEST = "android.intent.action.FACTORY_TEST";
1344
1345 /**
1346 * Activity Action: The user pressed the "call" button to go to the dialer
1347 * or other appropriate UI for placing a call.
1348 * <p>Input: Nothing.
1349 * <p>Output: Nothing.
1350 */
1351 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1352 public static final String ACTION_CALL_BUTTON = "android.intent.action.CALL_BUTTON";
1353
1354 /**
1355 * Activity Action: Start Voice Command.
1356 * <p>Input: Nothing.
1357 * <p>Output: Nothing.
1358 */
1359 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1360 public static final String ACTION_VOICE_COMMAND = "android.intent.action.VOICE_COMMAND";
The Android Open Source Projectba87e3e2009-03-13 13:04:22 -07001361
1362 /**
1363 * Activity Action: Start action associated with long pressing on the
1364 * search key.
1365 * <p>Input: Nothing.
1366 * <p>Output: Nothing.
1367 */
1368 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1369 public static final String ACTION_SEARCH_LONG_PRESS = "android.intent.action.SEARCH_LONG_PRESS";
The Android Open Source Project10592532009-03-18 17:39:46 -07001370
Jacek Surazski86b6c532009-05-13 14:38:28 +02001371 /**
1372 * Activity Action: The user pressed the "Report" button in the crash/ANR dialog.
1373 * This intent is delivered to the package which installed the application, usually
Dirk Dougherty4d7bc6552012-01-27 17:56:49 -08001374 * Google Play.
Jacek Surazski86b6c532009-05-13 14:38:28 +02001375 * <p>Input: No data is specified. The bug report is passed in using
1376 * an {@link #EXTRA_BUG_REPORT} field.
1377 * <p>Output: Nothing.
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001378 *
1379 * @see #EXTRA_BUG_REPORT
Jacek Surazski86b6c532009-05-13 14:38:28 +02001380 */
1381 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1382 public static final String ACTION_APP_ERROR = "android.intent.action.APP_ERROR";
Dianne Hackborn3d74bb42009-06-19 10:35:21 -07001383
1384 /**
1385 * Activity Action: Show power usage information to the user.
1386 * <p>Input: Nothing.
1387 * <p>Output: Nothing.
1388 */
1389 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1390 public static final String ACTION_POWER_USAGE_SUMMARY = "android.intent.action.POWER_USAGE_SUMMARY";
Tom Taylord4a47292009-12-21 13:59:18 -08001391
Dianne Hackbornd7cd29d2009-07-01 11:22:45 -07001392 /**
1393 * Activity Action: Setup wizard to launch after a platform update. This
1394 * activity should have a string meta-data field associated with it,
1395 * {@link #METADATA_SETUP_VERSION}, which defines the current version of
1396 * the platform for setup. The activity will be launched only if
1397 * {@link android.provider.Settings.Secure#LAST_SETUP_SHOWN} is not the
1398 * same value.
1399 * <p>Input: Nothing.
1400 * <p>Output: Nothing.
1401 * @hide
1402 */
1403 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1404 public static final String ACTION_UPGRADE_SETUP = "android.intent.action.UPGRADE_SETUP";
Tom Taylord4a47292009-12-21 13:59:18 -08001405
Dianne Hackbornd7cd29d2009-07-01 11:22:45 -07001406 /**
Jeff Sharkey7f868272011-06-05 16:05:02 -07001407 * Activity Action: Show settings for managing network data usage of a
1408 * specific application. Applications should define an activity that offers
1409 * options to control data usage.
1410 */
1411 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1412 public static final String ACTION_MANAGE_NETWORK_USAGE =
1413 "android.intent.action.MANAGE_NETWORK_USAGE";
1414
1415 /**
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001416 * Activity Action: Launch application installer.
1417 * <p>
1418 * Input: The data must be a content: or file: URI at which the application
Dianne Hackborneba784ff2012-09-19 12:42:37 -07001419 * can be retrieved. As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN_MR1},
1420 * you can also use "package:<package-name>" to install an application for the
1421 * current user that is already installed for another user. You can optionally supply
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001422 * {@link #EXTRA_INSTALLER_PACKAGE_NAME}, {@link #EXTRA_NOT_UNKNOWN_SOURCE},
1423 * {@link #EXTRA_ALLOW_REPLACE}, and {@link #EXTRA_RETURN_RESULT}.
1424 * <p>
1425 * Output: If {@link #EXTRA_RETURN_RESULT}, returns whether the install
1426 * succeeded.
Svet Ganov86877e42015-05-28 08:19:48 -07001427 * <p>
1428 * <strong>Note:</strong>If your app is targeting API level higher than 22 you
1429 * need to hold {@link android.Manifest.permission#REQUEST_INSTALL_PACKAGES}
1430 * in order to launch the application installer.
1431 * </p>
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001432 *
1433 * @see #EXTRA_INSTALLER_PACKAGE_NAME
1434 * @see #EXTRA_NOT_UNKNOWN_SOURCE
1435 * @see #EXTRA_RETURN_RESULT
1436 */
1437 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1438 public static final String ACTION_INSTALL_PACKAGE = "android.intent.action.INSTALL_PACKAGE";
1439
1440 /**
Todd Kennedyb8a279e2015-11-18 09:59:47 -08001441 * Activity Action: Launch ephemeral installer.
1442 * <p>
1443 * Input: The data must be a http: URI that the ephemeral application is registered
1444 * to handle.
1445 * <p class="note">
1446 * This is a protected intent that can only be sent by the system.
1447 * </p>
1448 *
1449 * @hide
1450 */
1451 @SystemApi
1452 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1453 public static final String ACTION_INSTALL_EPHEMERAL_PACKAGE
1454 = "android.intent.action.INSTALL_EPHEMERAL_PACKAGE";
1455
1456 /**
1457 * Service Action: Resolve ephemeral application.
1458 * <p>
1459 * The system will have a persistent connection to this service.
1460 * This is a protected intent that can only be sent by the system.
1461 * </p>
1462 *
1463 * @hide
1464 */
1465 @SystemApi
1466 @SdkConstant(SdkConstantType.SERVICE_ACTION)
1467 public static final String ACTION_RESOLVE_EPHEMERAL_PACKAGE
1468 = "android.intent.action.RESOLVE_EPHEMERAL_PACKAGE";
1469
1470 /**
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001471 * Used as a string extra field with {@link #ACTION_INSTALL_PACKAGE} to install a
1472 * package. Specifies the installer package name; this package will receive the
1473 * {@link #ACTION_APP_ERROR} intent.
1474 */
1475 public static final String EXTRA_INSTALLER_PACKAGE_NAME
1476 = "android.intent.extra.INSTALLER_PACKAGE_NAME";
1477
1478 /**
1479 * Used as a boolean extra field with {@link #ACTION_INSTALL_PACKAGE} to install a
1480 * package. Specifies that the application being installed should not be
1481 * treated as coming from an unknown source, but as coming from the app
1482 * invoking the Intent. For this to work you must start the installer with
1483 * startActivityForResult().
1484 */
1485 public static final String EXTRA_NOT_UNKNOWN_SOURCE
1486 = "android.intent.extra.NOT_UNKNOWN_SOURCE";
1487
1488 /**
rich cannings706e8ba2012-08-20 13:20:14 -07001489 * Used as a URI extra field with {@link #ACTION_INSTALL_PACKAGE} and
1490 * {@link #ACTION_VIEW} to indicate the URI from which the local APK in the Intent
rich cannings368ed012012-06-07 15:37:57 -07001491 * data field originated from.
1492 */
rich cannings706e8ba2012-08-20 13:20:14 -07001493 public static final String EXTRA_ORIGINATING_URI
1494 = "android.intent.extra.ORIGINATING_URI";
rich cannings368ed012012-06-07 15:37:57 -07001495
1496 /**
Dianne Hackborn85d558c2014-11-04 10:31:54 -08001497 * This extra can be used with any Intent used to launch an activity, supplying information
1498 * about who is launching that activity. This field contains a {@link android.net.Uri}
1499 * object, typically an http: or https: URI of the web site that the referral came from;
1500 * it can also use the {@link #URI_ANDROID_APP_SCHEME android-app:} scheme to identify
1501 * a native application that it came from.
1502 *
1503 * <p>To retrieve this value in a client, use {@link android.app.Activity#getReferrer}
1504 * instead of directly retrieving the extra. It is also valid for applications to
1505 * instead supply {@link #EXTRA_REFERRER_NAME} for cases where they can only create
1506 * a string, not a Uri; the field here, if supplied, will always take precedence,
1507 * however.</p>
1508 *
1509 * @see #EXTRA_REFERRER_NAME
rich cannings368ed012012-06-07 15:37:57 -07001510 */
1511 public static final String EXTRA_REFERRER
1512 = "android.intent.extra.REFERRER";
1513
1514 /**
Dianne Hackborn85d558c2014-11-04 10:31:54 -08001515 * Alternate version of {@link #EXTRA_REFERRER} that supplies the URI as a String rather
1516 * than a {@link android.net.Uri} object. Only for use in cases where Uri objects can
1517 * not be created, in particular when Intent extras are supplied through the
1518 * {@link #URI_INTENT_SCHEME intent:} or {@link #URI_ANDROID_APP_SCHEME android-app:}
1519 * schemes.
1520 *
1521 * @see #EXTRA_REFERRER
1522 */
1523 public static final String EXTRA_REFERRER_NAME
1524 = "android.intent.extra.REFERRER_NAME";
1525
1526 /**
Ben Gruver37d83a32012-09-27 13:02:06 -07001527 * Used as an int extra field with {@link #ACTION_INSTALL_PACKAGE} and
1528 * {@link} #ACTION_VIEW} to indicate the uid of the package that initiated the install
1529 * @hide
1530 */
1531 public static final String EXTRA_ORIGINATING_UID
1532 = "android.intent.extra.ORIGINATING_UID";
1533
1534 /**
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001535 * Used as a boolean extra field with {@link #ACTION_INSTALL_PACKAGE} to install a
1536 * package. Tells the installer UI to skip the confirmation with the user
1537 * if the .apk is replacing an existing one.
Dianne Hackborn0e128bb2012-05-01 14:40:15 -07001538 * @deprecated As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN}, Android
1539 * will no longer show an interstitial message about updating existing
1540 * applications so this is no longer needed.
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001541 */
Dianne Hackborn0e128bb2012-05-01 14:40:15 -07001542 @Deprecated
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001543 public static final String EXTRA_ALLOW_REPLACE
1544 = "android.intent.extra.ALLOW_REPLACE";
1545
1546 /**
1547 * Used as a boolean extra field with {@link #ACTION_INSTALL_PACKAGE} or
1548 * {@link #ACTION_UNINSTALL_PACKAGE}. Specifies that the installer UI should
1549 * return to the application the result code of the install/uninstall. The returned result
1550 * code will be {@link android.app.Activity#RESULT_OK} on success or
1551 * {@link android.app.Activity#RESULT_FIRST_USER} on failure.
1552 */
1553 public static final String EXTRA_RETURN_RESULT
1554 = "android.intent.extra.RETURN_RESULT";
1555
1556 /**
1557 * Package manager install result code. @hide because result codes are not
1558 * yet ready to be exposed.
1559 */
1560 public static final String EXTRA_INSTALL_RESULT
1561 = "android.intent.extra.INSTALL_RESULT";
1562
1563 /**
1564 * Activity Action: Launch application uninstaller.
1565 * <p>
1566 * Input: The data must be a package: URI whose scheme specific part is
1567 * the package name of the current installed package to be uninstalled.
1568 * You can optionally supply {@link #EXTRA_RETURN_RESULT}.
1569 * <p>
1570 * Output: If {@link #EXTRA_RETURN_RESULT}, returns whether the install
1571 * succeeded.
1572 */
1573 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1574 public static final String ACTION_UNINSTALL_PACKAGE = "android.intent.action.UNINSTALL_PACKAGE";
1575
1576 /**
Dianne Hackborn6d235d82012-09-16 18:25:40 -07001577 * Specify whether the package should be uninstalled for all users.
1578 * @hide because these should not be part of normal application flow.
1579 */
1580 public static final String EXTRA_UNINSTALL_ALL_USERS
1581 = "android.intent.extra.UNINSTALL_ALL_USERS";
1582
1583 /**
Dianne Hackbornd7cd29d2009-07-01 11:22:45 -07001584 * A string associated with a {@link #ACTION_UPGRADE_SETUP} activity
1585 * describing the last run version of the platform that was setup.
1586 * @hide
1587 */
1588 public static final String METADATA_SETUP_VERSION = "android.SETUP_VERSION";
1589
Svet Ganov3695b8a2015-03-24 16:30:25 -07001590 /**
1591 * Activity action: Launch UI to manage the permissions of an app.
1592 * <p>
1593 * Input: {@link #EXTRA_PACKAGE_NAME} specifies the package whose permissions
1594 * will be managed by the launched UI.
1595 * </p>
1596 * <p>
1597 * Output: Nothing.
1598 * </p>
1599 *
1600 * @see #EXTRA_PACKAGE_NAME
1601 *
1602 * @hide
1603 */
Svet Ganov3695b8a2015-03-24 16:30:25 -07001604 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1605 public static final String ACTION_MANAGE_APP_PERMISSIONS =
1606 "android.intent.action.MANAGE_APP_PERMISSIONS";
1607
1608 /**
Svet Ganov321f0152015-05-16 22:51:50 -07001609 * Activity action: Launch UI to manage permissions.
1610 * <p>
1611 * Input: Nothing.
1612 * </p>
1613 * <p>
1614 * Output: Nothing.
1615 * </p>
1616 *
1617 * @hide
1618 */
Svet Ganov321f0152015-05-16 22:51:50 -07001619 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1620 public static final String ACTION_MANAGE_PERMISSIONS =
1621 "android.intent.action.MANAGE_PERMISSIONS";
1622
1623 /**
Svet Ganov9c165d72015-12-01 19:52:26 -08001624 * Activity action: Launch UI to review permissions for an app.
1625 * The system uses this intent if permission review for apps not
1626 * supporting the new runtime permissions model is enabled. In
1627 * this mode a permission review is required before any of the
1628 * app components can run.
1629 * <p>
1630 * Input: {@link #EXTRA_PACKAGE_NAME} specifies the package whose
1631 * permissions will be reviewed (mandatory).
1632 * </p>
1633 * <p>
1634 * Input: {@link #EXTRA_INTENT} specifies a pending intent to
1635 * be fired after the permission review (optional).
1636 * </p>
1637 * <p>
1638 * Input: {@link #EXTRA_REMOTE_CALLBACK} specifies a callback to
1639 * be invoked after the permission review (optional).
1640 * </p>
1641 * <p>
1642 * Input: {@link #EXTRA_RESULT_NEEDED} specifies whether the intent
1643 * passed via {@link #EXTRA_INTENT} needs a result (optional).
1644 * </p>
1645 * <p>
1646 * Output: Nothing.
1647 * </p>
1648 *
1649 * @see #EXTRA_PACKAGE_NAME
1650 * @see #EXTRA_INTENT
1651 * @see #EXTRA_REMOTE_CALLBACK
1652 * @see #EXTRA_RESULT_NEEDED
1653 *
1654 * @hide
1655 */
1656 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1657 public static final String ACTION_REVIEW_PERMISSIONS =
1658 "android.intent.action.REVIEW_PERMISSIONS";
1659
1660 /**
1661 * Intent extra: A callback for reporting remote result as a bundle.
1662 * <p>
1663 * Type: IRemoteCallback
1664 * </p>
1665 *
1666 * @hide
1667 */
1668 public static final String EXTRA_REMOTE_CALLBACK = "android.intent.extra.REMOTE_CALLBACK";
1669
1670 /**
Svet Ganov3695b8a2015-03-24 16:30:25 -07001671 * Intent extra: An app package name.
1672 * <p>
1673 * Type: String
Svet Ganov0b316702015-05-23 13:25:11 -07001674 * </p>
Svet Ganov3695b8a2015-03-24 16:30:25 -07001675 *
1676 * @hide
1677 */
1678 @SystemApi
1679 public static final String EXTRA_PACKAGE_NAME = "android.intent.extra.PACKAGE_NAME";
1680
1681 /**
Svet Ganov9c165d72015-12-01 19:52:26 -08001682 * Intent extra: An extra for specifying whether a result is needed.
1683 * <p>
1684 * Type: boolean
1685 * </p>
1686 *
1687 * @hide
1688 */
1689 public static final String EXTRA_RESULT_NEEDED = "android.intent.extra.RESULT_NEEDED";
1690
1691 /**
Jason Monk9cfa0cc2015-05-22 14:50:21 -04001692 * Broadcast action that requests current permission granted information. It will respond
1693 * to the request by sending a broadcast with action defined by
1694 * {@link #EXTRA_GET_PERMISSIONS_RESPONSE_INTENT}. The response will contain
Makoto Onukibbb912a2015-06-05 16:27:23 -07001695 * {@link #EXTRA_GET_PERMISSIONS_COUNT_RESULT}, as well as
1696 * {@link #EXTRA_GET_PERMISSIONS_GROUP_LIST_RESULT}, with contents described below or
1697 * a null upon failure.
Jason Monk9cfa0cc2015-05-22 14:50:21 -04001698 *
Makoto Onukibbb912a2015-06-05 16:27:23 -07001699 * <p>If {@link #EXTRA_PACKAGE_NAME} is included then the number of permissions granted, the
1700 * number of permissions requested and the number of granted additional permissions
1701 * by that package will be calculated and included as the first
Jason Monk9cfa0cc2015-05-22 14:50:21 -04001702 * and second elements respectively of an int[] in the response as
Makoto Onukibbb912a2015-06-05 16:27:23 -07001703 * {@link #EXTRA_GET_PERMISSIONS_COUNT_RESULT}. The response will also deliver the list
1704 * of localized permission group names that are granted in
1705 * {@link #EXTRA_GET_PERMISSIONS_GROUP_LIST_RESULT}.
Jason Monk9cfa0cc2015-05-22 14:50:21 -04001706 *
1707 * <p>If {@link #EXTRA_PACKAGE_NAME} is not included then the number of apps granted any runtime
1708 * permissions and the total number of apps requesting runtime permissions will be the first
1709 * and second elements respectively of an int[] in the response as
1710 * {@link #EXTRA_GET_PERMISSIONS_COUNT_RESULT}.
1711 *
1712 * @hide
1713 */
1714 public static final String ACTION_GET_PERMISSIONS_COUNT
1715 = "android.intent.action.GET_PERMISSIONS_COUNT";
1716
1717 /**
Vinod Krishnan61665cc2015-08-31 19:30:20 -07001718 * Broadcast action that requests list of all apps that have runtime permissions. It will
1719 * respond to the request by sending a broadcast with action defined by
1720 * {@link #EXTRA_GET_PERMISSIONS_PACKAGES_RESPONSE_INTENT}. The response will contain
1721 * {@link #EXTRA_GET_PERMISSIONS_APP_LIST_RESULT}, as well as
1722 * {@link #EXTRA_GET_PERMISSIONS_APP_LABEL_LIST_RESULT}, with contents described below or
1723 * a null upon failure.
1724 *
1725 * <p>{@link #EXTRA_GET_PERMISSIONS_APP_LIST_RESULT} will contain a list of package names of
1726 * apps that have runtime permissions. {@link #EXTRA_GET_PERMISSIONS_APP_LABEL_LIST_RESULT}
1727 * will contain the list of app labels corresponding ot the apps in the first list.
1728 *
1729 * @hide
1730 */
1731 public static final String ACTION_GET_PERMISSIONS_PACKAGES
1732 = "android.intent.action.GET_PERMISSIONS_PACKAGES";
1733
1734 /**
Jason Monk9cfa0cc2015-05-22 14:50:21 -04001735 * Extra included in response to {@link #ACTION_GET_PERMISSIONS_COUNT}.
1736 * @hide
1737 */
1738 public static final String EXTRA_GET_PERMISSIONS_COUNT_RESULT
1739 = "android.intent.extra.GET_PERMISSIONS_COUNT_RESULT";
1740
1741 /**
Makoto Onukibbb912a2015-06-05 16:27:23 -07001742 * List of CharSequence of localized permission group labels.
1743 * @hide
1744 */
1745 public static final String EXTRA_GET_PERMISSIONS_GROUP_LIST_RESULT
1746 = "android.intent.extra.GET_PERMISSIONS_GROUP_LIST_RESULT";
1747
1748 /**
Vinod Krishnan61665cc2015-08-31 19:30:20 -07001749 * String list of apps that have one or more runtime permissions.
1750 * @hide
1751 */
1752 public static final String EXTRA_GET_PERMISSIONS_APP_LIST_RESULT
1753 = "android.intent.extra.GET_PERMISSIONS_APP_LIST_RESULT";
1754
1755 /**
1756 * String list of app labels for apps that have one or more runtime permissions.
1757 * @hide
1758 */
1759 public static final String EXTRA_GET_PERMISSIONS_APP_LABEL_LIST_RESULT
1760 = "android.intent.extra.GET_PERMISSIONS_APP_LABEL_LIST_RESULT";
1761
1762 /**
Anthony Hugh3575a402015-10-26 17:47:05 -07001763 * Boolean list describing if the app is a system app for apps that have one or more runtime
1764 * permissions.
1765 * @hide
1766 */
1767 public static final String EXTRA_GET_PERMISSIONS_IS_SYSTEM_APP_LIST_RESULT
1768 = "android.intent.extra.GET_PERMISSIONS_IS_SYSTEM_APP_LIST_RESULT";
1769
1770 /**
Makoto Onukibbb912a2015-06-05 16:27:23 -07001771 * Required extra to be sent with {@link #ACTION_GET_PERMISSIONS_COUNT} broadcasts.
Jason Monk9cfa0cc2015-05-22 14:50:21 -04001772 * @hide
1773 */
1774 public static final String EXTRA_GET_PERMISSIONS_RESPONSE_INTENT
1775 = "android.intent.extra.GET_PERMISSIONS_RESONSE_INTENT";
1776
1777 /**
Vinod Krishnan61665cc2015-08-31 19:30:20 -07001778 * Required extra to be sent with {@link #ACTION_GET_PERMISSIONS_PACKAGES} broadcasts.
1779 * @hide
1780 */
1781 public static final String EXTRA_GET_PERMISSIONS_PACKAGES_RESPONSE_INTENT
1782 = "android.intent.extra.GET_PERMISSIONS_PACKAGES_RESONSE_INTENT";
1783
1784 /**
Svet Ganov3695b8a2015-03-24 16:30:25 -07001785 * Activity action: Launch UI to manage which apps have a given permission.
1786 * <p>
1787 * Input: {@link #EXTRA_PERMISSION_NAME} specifies the permission access
1788 * to which will be managed by the launched UI.
1789 * </p>
1790 * <p>
1791 * Output: Nothing.
1792 * </p>
1793 *
1794 * @see #EXTRA_PERMISSION_NAME
1795 *
1796 * @hide
1797 */
Svet Ganov3695b8a2015-03-24 16:30:25 -07001798 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1799 public static final String ACTION_MANAGE_PERMISSION_APPS =
1800 "android.intent.action.MANAGE_PERMISSION_APPS";
1801
1802 /**
1803 * Intent extra: The name of a permission.
1804 * <p>
1805 * Type: String
1806 * </p>
1807 *
1808 * @hide
1809 */
1810 @SystemApi
1811 public static final String EXTRA_PERMISSION_NAME = "android.intent.extra.PERMISSION_NAME";
1812
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001813 // ---------------------------------------------------------------------
1814 // ---------------------------------------------------------------------
1815 // Standard intent broadcast actions (see action variable).
1816
1817 /**
Jeff Brown037c33e2014-04-09 00:31:55 -07001818 * Broadcast Action: Sent when the device goes to sleep and becomes non-interactive.
1819 * <p>
1820 * For historical reasons, the name of this broadcast action refers to the power
1821 * state of the screen but it is actually sent in response to changes in the
1822 * overall interactive state of the device.
1823 * </p><p>
1824 * This broadcast is sent when the device becomes non-interactive which may have
1825 * nothing to do with the screen turning off. To determine the
1826 * actual state of the screen, use {@link android.view.Display#getState}.
1827 * </p><p>
1828 * See {@link android.os.PowerManager#isInteractive} for details.
1829 * </p>
Casey Hodbf6785c2015-03-17 15:59:39 -07001830 * You <em>cannot</em> receive this through components declared in
1831 * manifests, only by explicitly registering for it with
1832 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
1833 * Context.registerReceiver()}.
Tom Taylord4a47292009-12-21 13:59:18 -08001834 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001835 * <p class="note">This is a protected intent that can only be sent
1836 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001837 */
1838 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1839 public static final String ACTION_SCREEN_OFF = "android.intent.action.SCREEN_OFF";
Jeff Brown037c33e2014-04-09 00:31:55 -07001840
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001841 /**
Jeff Brown037c33e2014-04-09 00:31:55 -07001842 * Broadcast Action: Sent when the device wakes up and becomes interactive.
1843 * <p>
1844 * For historical reasons, the name of this broadcast action refers to the power
1845 * state of the screen but it is actually sent in response to changes in the
1846 * overall interactive state of the device.
1847 * </p><p>
1848 * This broadcast is sent when the device becomes interactive which may have
1849 * nothing to do with the screen turning on. To determine the
1850 * actual state of the screen, use {@link android.view.Display#getState}.
1851 * </p><p>
1852 * See {@link android.os.PowerManager#isInteractive} for details.
1853 * </p>
Casey Hodbf6785c2015-03-17 15:59:39 -07001854 * You <em>cannot</em> receive this through components declared in
1855 * manifests, only by explicitly registering for it with
1856 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
1857 * Context.registerReceiver()}.
Tom Taylord4a47292009-12-21 13:59:18 -08001858 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001859 * <p class="note">This is a protected intent that can only be sent
1860 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001861 */
1862 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1863 public static final String ACTION_SCREEN_ON = "android.intent.action.SCREEN_ON";
The Android Open Source Projectb2a3dd82009-03-09 11:52:12 -07001864
1865 /**
Dianne Hackbornbe87e2f2012-09-28 16:31:34 -07001866 * Broadcast Action: Sent after the system stops dreaming.
1867 *
1868 * <p class="note">This is a protected intent that can only be sent by the system.
1869 * It is only sent to registered receivers.</p>
1870 */
1871 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1872 public static final String ACTION_DREAMING_STOPPED = "android.intent.action.DREAMING_STOPPED";
1873
1874 /**
1875 * Broadcast Action: Sent after the system starts dreaming.
1876 *
1877 * <p class="note">This is a protected intent that can only be sent by the system.
1878 * It is only sent to registered receivers.</p>
1879 */
1880 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1881 public static final String ACTION_DREAMING_STARTED = "android.intent.action.DREAMING_STARTED";
1882
1883 /**
The Android Open Source Project10592532009-03-18 17:39:46 -07001884 * 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 -07001885 * keyguard is gone).
Tom Taylord4a47292009-12-21 13:59:18 -08001886 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001887 * <p class="note">This is a protected intent that can only be sent
1888 * by the system.
The Android Open Source Projectb2a3dd82009-03-09 11:52:12 -07001889 */
1890 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Dianne Hackborn1c633fc2009-12-08 19:45:14 -08001891 public static final String ACTION_USER_PRESENT = "android.intent.action.USER_PRESENT";
The Android Open Source Projectb2a3dd82009-03-09 11:52:12 -07001892
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001893 /**
1894 * Broadcast Action: The current time has changed. Sent every
Casey Hodbf6785c2015-03-17 15:59:39 -07001895 * minute. You <em>cannot</em> receive this through components declared
John Spurlock6098c5d2013-06-17 10:32:46 -04001896 * in manifests, only by explicitly registering for it with
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001897 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
1898 * Context.registerReceiver()}.
Tom Taylord4a47292009-12-21 13:59:18 -08001899 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001900 * <p class="note">This is a protected intent that can only be sent
1901 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001902 */
1903 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1904 public static final String ACTION_TIME_TICK = "android.intent.action.TIME_TICK";
1905 /**
1906 * Broadcast Action: The time was set.
1907 */
1908 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1909 public static final String ACTION_TIME_CHANGED = "android.intent.action.TIME_SET";
1910 /**
1911 * Broadcast Action: The date has changed.
1912 */
1913 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1914 public static final String ACTION_DATE_CHANGED = "android.intent.action.DATE_CHANGED";
1915 /**
1916 * Broadcast Action: The timezone has changed. The intent will have the following extra values:</p>
1917 * <ul>
1918 * <li><em>time-zone</em> - The java.util.TimeZone.getID() value identifying the new time zone.</li>
1919 * </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_TIMEZONE_CHANGED = "android.intent.action.TIMEZONE_CHANGED";
1926 /**
Robert Greenwalt03595d02010-11-02 14:08:23 -07001927 * Clear DNS Cache Action: This is broadcast when networks have changed and old
1928 * DNS entries should be tossed.
1929 * @hide
1930 */
1931 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1932 public static final String ACTION_CLEAR_DNS_CACHE = "android.intent.action.CLEAR_DNS_CACHE";
1933 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001934 * Alarm Changed Action: This is broadcast when the AlarmClock
1935 * application's alarm is set or unset. It is used by the
1936 * AlarmClock application and the StatusBar service.
1937 * @hide
1938 */
1939 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1940 public static final String ACTION_ALARM_CHANGED = "android.intent.action.ALARM_CHANGED";
Jeff Sharkeybedbaa92015-12-02 16:42:25 -07001941
1942 /**
Jeff Sharkeycf3f0a12016-03-17 19:57:58 -06001943 * Broadcast Action: This is broadcast once, after the user has finished
1944 * booting, but while still in the "locked" state. It can be used to perform
1945 * application-specific initialization, such as installing alarms. You must
1946 * hold the {@link android.Manifest.permission#RECEIVE_BOOT_COMPLETED}
1947 * permission in order to receive this broadcast.
Jeff Sharkeybedbaa92015-12-02 16:42:25 -07001948 * <p>
Jeff Sharkeycf3f0a12016-03-17 19:57:58 -06001949 * This broadcast is sent immediately at boot by all devices (regardless of
1950 * direct boot support) running {@link android.os.Build.VERSION_CODES#N} or
1951 * higher. Upon receipt of this broadcast, the user is still locked and only
1952 * device-protected storage can be accessed safely. If you want to access
1953 * credential-protected storage, you need to wait for the user to be
1954 * unlocked (typically by entering their lock pattern or PIN for the first
1955 * time), after which the {@link #ACTION_USER_UNLOCKED} and
1956 * {@link #ACTION_BOOT_COMPLETED} broadcasts are sent.
1957 * <p>
1958 * To receive this broadcast, your receiver component must be marked as
1959 * being {@link ComponentInfo#directBootAware}.
Jeff Sharkeybedbaa92015-12-02 16:42:25 -07001960 * <p class="note">
1961 * This is a protected intent that can only be sent by the system.
Jeff Sharkeycf3f0a12016-03-17 19:57:58 -06001962 *
1963 * @see Context#createDeviceProtectedStorageContext()
Jeff Sharkeybedbaa92015-12-02 16:42:25 -07001964 */
1965 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1966 public static final String ACTION_LOCKED_BOOT_COMPLETED = "android.intent.action.LOCKED_BOOT_COMPLETED";
1967
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001968 /**
Jeff Sharkeycf3f0a12016-03-17 19:57:58 -06001969 * Broadcast Action: This is broadcast once, after the user has finished
1970 * booting. It can be used to perform application-specific initialization,
1971 * such as installing alarms. You must hold the
1972 * {@link android.Manifest.permission#RECEIVE_BOOT_COMPLETED} permission in
1973 * order to receive this broadcast.
1974 * <p>
1975 * This broadcast is sent at boot by all devices (both with and without
1976 * direct boot support). Upon receipt of this broadcast, the user is
1977 * unlocked and both device-protected and credential-protected storage can
1978 * accessed safely.
1979 * <p>
1980 * If you need to run while the user is still locked (before they've entered
1981 * their lock pattern or PIN for the first time), you can listen for the
1982 * {@link #ACTION_LOCKED_BOOT_COMPLETED} broadcast.
1983 * <p class="note">
1984 * This is a protected intent that can only be sent by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001985 */
1986 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1987 public static final String ACTION_BOOT_COMPLETED = "android.intent.action.BOOT_COMPLETED";
Jeff Sharkeybedbaa92015-12-02 16:42:25 -07001988
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001989 /**
1990 * Broadcast Action: This is broadcast when a user action should request a
1991 * temporary system dialog to dismiss. Some examples of temporary system
1992 * dialogs are the notification window-shade and the recent tasks dialog.
1993 */
1994 public static final String ACTION_CLOSE_SYSTEM_DIALOGS = "android.intent.action.CLOSE_SYSTEM_DIALOGS";
1995 /**
1996 * Broadcast Action: Trigger the download and eventual installation
1997 * of a package.
1998 * <p>Input: {@link #getData} is the URI of the package file to download.
Tom Taylord4a47292009-12-21 13:59:18 -08001999 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002000 * <p class="note">This is a protected intent that can only be sent
2001 * by the system.
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07002002 *
2003 * @deprecated This constant has never been used.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002004 */
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07002005 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002006 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2007 public static final String ACTION_PACKAGE_INSTALL = "android.intent.action.PACKAGE_INSTALL";
2008 /**
2009 * Broadcast Action: A new application package has been installed on the
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07002010 * device. The data contains the name of the package. Note that the
2011 * newly installed package does <em>not</em> receive this broadcast.
Jeff Sharkeyd0c6ccb2012-09-14 16:26:37 -07002012 * <p>May include the following extras:
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002013 * <ul>
2014 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the new package.
2015 * <li> {@link #EXTRA_REPLACING} is set to true if this is following
2016 * an {@link #ACTION_PACKAGE_REMOVED} broadcast for the same package.
2017 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002018 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002019 * <p class="note">This is a protected intent that can only be sent
2020 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002021 */
2022 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2023 public static final String ACTION_PACKAGE_ADDED = "android.intent.action.PACKAGE_ADDED";
2024 /**
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07002025 * Broadcast Action: A new version of an application package has been
2026 * installed, replacing an existing version that was previously installed.
2027 * The data contains the name of the package.
Jeff Sharkeyd0c6ccb2012-09-14 16:26:37 -07002028 * <p>May include the following extras:
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07002029 * <ul>
2030 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the new package.
2031 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002032 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002033 * <p class="note">This is a protected intent that can only be sent
2034 * by the system.
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07002035 */
2036 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2037 public static final String ACTION_PACKAGE_REPLACED = "android.intent.action.PACKAGE_REPLACED";
2038 /**
Dianne Hackborne7f97212011-02-24 14:40:20 -08002039 * Broadcast Action: A new version of your application has been installed
2040 * over an existing one. This is only sent to the application that was
2041 * replaced. It does not contain any additional data; to receive it, just
2042 * use an intent filter for this action.
2043 *
2044 * <p class="note">This is a protected intent that can only be sent
2045 * by the system.
2046 */
2047 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2048 public static final String ACTION_MY_PACKAGE_REPLACED = "android.intent.action.MY_PACKAGE_REPLACED";
2049 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002050 * Broadcast Action: An existing application package has been removed from
2051 * the device. The data contains the name of the package. The package
2052 * that is being installed does <em>not</em> receive this Intent.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002053 * <ul>
2054 * <li> {@link #EXTRA_UID} containing the integer uid previously assigned
2055 * to the package.
2056 * <li> {@link #EXTRA_DATA_REMOVED} is set to true if the entire
2057 * application -- data and code -- is being removed.
2058 * <li> {@link #EXTRA_REPLACING} is set to true if this will be followed
2059 * by an {@link #ACTION_PACKAGE_ADDED} broadcast for the same package.
2060 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002061 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002062 * <p class="note">This is a protected intent that can only be sent
2063 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002064 */
2065 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2066 public static final String ACTION_PACKAGE_REMOVED = "android.intent.action.PACKAGE_REMOVED";
2067 /**
Dianne Hackbornf9abb402011-08-10 15:00:59 -07002068 * Broadcast Action: An existing application package has been completely
2069 * removed from the device. The data contains the name of the package.
2070 * This is like {@link #ACTION_PACKAGE_REMOVED}, but only set when
2071 * {@link #EXTRA_DATA_REMOVED} is true and
2072 * {@link #EXTRA_REPLACING} is false of that broadcast.
2073 *
2074 * <ul>
2075 * <li> {@link #EXTRA_UID} containing the integer uid previously assigned
2076 * to the package.
2077 * </ul>
2078 *
2079 * <p class="note">This is a protected intent that can only be sent
2080 * by the system.
2081 */
2082 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2083 public static final String ACTION_PACKAGE_FULLY_REMOVED
2084 = "android.intent.action.PACKAGE_FULLY_REMOVED";
2085 /**
Dianne Hackborn86a72da2009-11-11 20:12:41 -08002086 * Broadcast Action: An existing application package has been changed (e.g.
2087 * a component has been enabled or disabled). The data contains the name of
2088 * the package.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002089 * <ul>
2090 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
Dianne Hackborn86a72da2009-11-11 20:12:41 -08002091 * <li> {@link #EXTRA_CHANGED_COMPONENT_NAME_LIST} containing the class name
Dianne Hackbornfd7aded2013-01-22 17:10:23 -08002092 * of the changed components (or the package name itself).
Dianne Hackborn86a72da2009-11-11 20:12:41 -08002093 * <li> {@link #EXTRA_DONT_KILL_APP} containing boolean field to override the
2094 * default action of restarting the application.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002095 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002096 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002097 * <p class="note">This is a protected intent that can only be sent
2098 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002099 */
2100 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2101 public static final String ACTION_PACKAGE_CHANGED = "android.intent.action.PACKAGE_CHANGED";
2102 /**
Dianne Hackborn21f1bd12010-02-19 17:02:21 -08002103 * @hide
2104 * Broadcast Action: Ask system services if there is any reason to
2105 * restart the given package. The data contains the name of the
2106 * package.
2107 * <ul>
2108 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
2109 * <li> {@link #EXTRA_PACKAGES} String array of all packages to check.
2110 * </ul>
2111 *
2112 * <p class="note">This is a protected intent that can only be sent
2113 * by the system.
2114 */
Soonil Nagarkar0e8fd092015-02-10 10:37:36 -08002115 @SystemApi
Dianne Hackborn21f1bd12010-02-19 17:02:21 -08002116 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2117 public static final String ACTION_QUERY_PACKAGE_RESTART = "android.intent.action.QUERY_PACKAGE_RESTART";
2118 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002119 * Broadcast Action: The user has restarted a package, and all of its
2120 * processes have been killed. All runtime state
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002121 * associated with it (processes, alarms, notifications, etc) should
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07002122 * be removed. Note that the restarted package does <em>not</em>
2123 * receive this broadcast.
2124 * The data contains the name of the package.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002125 * <ul>
2126 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
2127 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002128 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002129 * <p class="note">This is a protected intent that can only be sent
2130 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002131 */
2132 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2133 public static final String ACTION_PACKAGE_RESTARTED = "android.intent.action.PACKAGE_RESTARTED";
2134 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002135 * Broadcast Action: The user has cleared the data of a package. This should
2136 * be preceded by {@link #ACTION_PACKAGE_RESTARTED}, after which all of
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07002137 * its persistent data is erased and this broadcast sent.
2138 * Note that the cleared package does <em>not</em>
2139 * receive this broadcast. The data contains the name of the package.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002140 * <ul>
2141 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
2142 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002143 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002144 * <p class="note">This is a protected intent that can only be sent
2145 * by the system.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002146 */
2147 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2148 public static final String ACTION_PACKAGE_DATA_CLEARED = "android.intent.action.PACKAGE_DATA_CLEARED";
2149 /**
Andrei Stingaceanu69d5ebc2016-01-14 12:59:03 +00002150 * Broadcast Action: Packages have been suspended.
2151 * <p>Includes the following extras:
2152 * <ul>
2153 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages which have been suspended
2154 * </ul>
2155 *
2156 * <p class="note">This is a protected intent that can only be sent
2157 * by the system. It is only sent to registered receivers.
2158 */
2159 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2160 public static final String ACTION_PACKAGES_SUSPENDED = "android.intent.action.PACKAGES_SUSPENDED";
2161 /**
2162 * Broadcast Action: Packages have been unsuspended.
2163 * <p>Includes the following extras:
2164 * <ul>
2165 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages which have been unsuspended
2166 * </ul>
2167 *
2168 * <p class="note">This is a protected intent that can only be sent
2169 * by the system. It is only sent to registered receivers.
2170 */
2171 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2172 public static final String ACTION_PACKAGES_UNSUSPENDED = "android.intent.action.PACKAGES_UNSUSPENDED";
2173 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002174 * Broadcast Action: A user ID has been removed from the system. The user
2175 * ID number is stored in the extra data under {@link #EXTRA_UID}.
Tom Taylord4a47292009-12-21 13:59:18 -08002176 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002177 * <p class="note">This is a protected intent that can only be sent
2178 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002179 */
2180 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2181 public static final String ACTION_UID_REMOVED = "android.intent.action.UID_REMOVED";
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002182
2183 /**
Dianne Hackborne7f97212011-02-24 14:40:20 -08002184 * Broadcast Action: Sent to the installer package of an application
2185 * when that application is first launched (that is the first time it
2186 * is moved out of the stopped state). The data contains the name of the package.
2187 *
2188 * <p class="note">This is a protected intent that can only be sent
2189 * by the system.
2190 */
2191 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2192 public static final String ACTION_PACKAGE_FIRST_LAUNCH = "android.intent.action.PACKAGE_FIRST_LAUNCH";
2193
2194 /**
Kenny Root5ab21572011-07-27 11:11:19 -07002195 * Broadcast Action: Sent to the system package verifier when a package
2196 * needs to be verified. The data contains the package URI.
2197 * <p class="note">
2198 * This is a protected intent that can only be sent by the system.
2199 * </p>
Kenny Root5ab21572011-07-27 11:11:19 -07002200 */
2201 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2202 public static final String ACTION_PACKAGE_NEEDS_VERIFICATION = "android.intent.action.PACKAGE_NEEDS_VERIFICATION";
2203
2204 /**
rich canningsd1b5cfc2012-08-29 14:49:51 -07002205 * Broadcast Action: Sent to the system package verifier when a package is
2206 * verified. The data contains the package URI.
2207 * <p class="note">
2208 * This is a protected intent that can only be sent by the system.
2209 */
2210 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2211 public static final String ACTION_PACKAGE_VERIFIED = "android.intent.action.PACKAGE_VERIFIED";
2212
2213 /**
Fabrice Di Meglio1c1b4712014-11-19 17:12:32 -08002214 * Broadcast Action: Sent to the system intent filter verifier when an intent filter
2215 * needs to be verified. The data contains the filter data hosts to be verified against.
2216 * <p class="note">
2217 * This is a protected intent that can only be sent by the system.
2218 * </p>
2219 *
2220 * @hide
2221 */
2222 @SystemApi
2223 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2224 public static final String ACTION_INTENT_FILTER_NEEDS_VERIFICATION = "android.intent.action.INTENT_FILTER_NEEDS_VERIFICATION";
2225
2226 /**
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002227 * Broadcast Action: Resources for a set of packages (which were
2228 * previously unavailable) are currently
2229 * available since the media on which they exist is available.
2230 * The extra data {@link #EXTRA_CHANGED_PACKAGE_LIST} contains a
2231 * list of packages whose availability changed.
2232 * The extra data {@link #EXTRA_CHANGED_UID_LIST} contains a
2233 * list of uids of packages whose availability changed.
2234 * Note that the
2235 * packages in this list do <em>not</em> receive this broadcast.
2236 * The specified set of packages are now available on the system.
2237 * <p>Includes the following extras:
2238 * <ul>
2239 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages
2240 * whose resources(were previously unavailable) are currently available.
2241 * {@link #EXTRA_CHANGED_UID_LIST} is the set of uids of the
2242 * packages whose resources(were previously unavailable)
2243 * are currently available.
2244 * </ul>
2245 *
2246 * <p class="note">This is a protected intent that can only be sent
2247 * by the system.
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002248 */
2249 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08002250 public static final String ACTION_EXTERNAL_APPLICATIONS_AVAILABLE =
2251 "android.intent.action.EXTERNAL_APPLICATIONS_AVAILABLE";
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002252
2253 /**
2254 * Broadcast Action: Resources for a set of packages are currently
2255 * unavailable since the media on which they exist is unavailable.
2256 * The extra data {@link #EXTRA_CHANGED_PACKAGE_LIST} contains a
2257 * list of packages whose availability changed.
2258 * The extra data {@link #EXTRA_CHANGED_UID_LIST} contains a
2259 * list of uids of packages whose availability changed.
2260 * The specified set of packages can no longer be
2261 * launched and are practically unavailable on the system.
2262 * <p>Inclues the following extras:
2263 * <ul>
2264 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages
2265 * whose resources are no longer available.
2266 * {@link #EXTRA_CHANGED_UID_LIST} is the set of packages
2267 * whose resources are no longer available.
2268 * </ul>
2269 *
2270 * <p class="note">This is a protected intent that can only be sent
2271 * by the system.
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002272 */
2273 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08002274 public static final String ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE =
Joe Onorato8a051a42010-03-04 15:54:50 -05002275 "android.intent.action.EXTERNAL_APPLICATIONS_UNAVAILABLE";
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002276
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002277 /**
2278 * Broadcast Action: The current system wallpaper has changed. See
Scott Main8b2e0002009-09-29 18:17:31 -07002279 * {@link android.app.WallpaperManager} for retrieving the new wallpaper.
Dianne Hackbornc5bf7582012-04-25 19:12:07 -07002280 * This should <em>only</em> be used to determine when the wallpaper
2281 * has changed to show the new wallpaper to the user. You should certainly
2282 * never, in response to this, change the wallpaper or other attributes of
2283 * it such as the suggested size. That would be crazy, right? You'd cause
2284 * all kinds of loops, especially if other apps are doing similar things,
2285 * right? Of course. So please don't do this.
2286 *
2287 * @deprecated Modern applications should use
2288 * {@link android.view.WindowManager.LayoutParams#FLAG_SHOW_WALLPAPER
2289 * WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER} to have the wallpaper
2290 * shown behind their UI, rather than watching for this broadcast and
2291 * rendering the wallpaper on their own.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002292 */
Dianne Hackbornc5bf7582012-04-25 19:12:07 -07002293 @Deprecated @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002294 public static final String ACTION_WALLPAPER_CHANGED = "android.intent.action.WALLPAPER_CHANGED";
2295 /**
2296 * Broadcast Action: The current device {@link android.content.res.Configuration}
2297 * (orientation, locale, etc) has changed. When such a change happens, the
2298 * UIs (view hierarchy) will need to be rebuilt based on this new
2299 * information; for the most part, applications don't need to worry about
2300 * this, because the system will take care of stopping and restarting the
2301 * application to make sure it sees the new changes. Some system code that
2302 * can not be restarted will need to watch for this action and handle it
2303 * appropriately.
Tom Taylord4a47292009-12-21 13:59:18 -08002304 *
Dianne Hackborn362d5b92009-11-11 18:04:39 -08002305 * <p class="note">
Casey Hodbf6785c2015-03-17 15:59:39 -07002306 * You <em>cannot</em> receive this through components declared
Dianne Hackborn362d5b92009-11-11 18:04:39 -08002307 * in manifests, only by explicitly registering for it with
2308 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
2309 * Context.registerReceiver()}.
Tom Taylord4a47292009-12-21 13:59:18 -08002310 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002311 * <p class="note">This is a protected intent that can only be sent
2312 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002313 *
2314 * @see android.content.res.Configuration
2315 */
2316 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2317 public static final String ACTION_CONFIGURATION_CHANGED = "android.intent.action.CONFIGURATION_CHANGED";
2318 /**
Dianne Hackborn362d5b92009-11-11 18:04:39 -08002319 * Broadcast Action: The current device's locale has changed.
Tom Taylord4a47292009-12-21 13:59:18 -08002320 *
Dianne Hackborn362d5b92009-11-11 18:04:39 -08002321 * <p class="note">This is a protected intent that can only be sent
2322 * by the system.
2323 */
2324 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2325 public static final String ACTION_LOCALE_CHANGED = "android.intent.action.LOCALE_CHANGED";
2326 /**
Dianne Hackbornedd93162009-09-19 14:03:05 -07002327 * Broadcast Action: This is a <em>sticky broadcast</em> containing the
2328 * charging state, level, and other information about the battery.
2329 * See {@link android.os.BatteryManager} for documentation on the
2330 * contents of the Intent.
The Android Open Source Project10592532009-03-18 17:39:46 -07002331 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002332 * <p class="note">
Casey Hodbf6785c2015-03-17 15:59:39 -07002333 * You <em>cannot</em> receive this through components declared
Dianne Hackborn854060af2009-07-09 18:14:31 -07002334 * in manifests, only by explicitly registering for it with
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002335 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
Dianne Hackbornedd93162009-09-19 14:03:05 -07002336 * Context.registerReceiver()}. See {@link #ACTION_BATTERY_LOW},
2337 * {@link #ACTION_BATTERY_OKAY}, {@link #ACTION_POWER_CONNECTED},
2338 * and {@link #ACTION_POWER_DISCONNECTED} for distinct battery-related
2339 * broadcasts that are sent and can be received through manifest
2340 * receivers.
Tom Taylord4a47292009-12-21 13:59:18 -08002341 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002342 * <p class="note">This is a protected intent that can only be sent
2343 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002344 */
2345 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2346 public static final String ACTION_BATTERY_CHANGED = "android.intent.action.BATTERY_CHANGED";
2347 /**
2348 * Broadcast Action: Indicates low battery condition on the device.
2349 * This broadcast corresponds to the "Low battery warning" system dialog.
Tom Taylord4a47292009-12-21 13:59:18 -08002350 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002351 * <p class="note">This is a protected intent that can only be sent
2352 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002353 */
2354 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2355 public static final String ACTION_BATTERY_LOW = "android.intent.action.BATTERY_LOW";
2356 /**
Dianne Hackborn1dac2772009-06-26 18:16:48 -07002357 * Broadcast Action: Indicates the battery is now okay after being low.
2358 * This will be sent after {@link #ACTION_BATTERY_LOW} once the battery has
2359 * gone back up to an okay state.
Tom Taylord4a47292009-12-21 13:59:18 -08002360 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002361 * <p class="note">This is a protected intent that can only be sent
2362 * by the system.
Dianne Hackborn1dac2772009-06-26 18:16:48 -07002363 */
2364 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2365 public static final String ACTION_BATTERY_OKAY = "android.intent.action.BATTERY_OKAY";
2366 /**
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002367 * Broadcast Action: External power has been connected to the device.
2368 * This is intended for applications that wish to register specifically to this notification.
2369 * Unlike ACTION_BATTERY_CHANGED, applications will be woken for this and so do not have to
2370 * stay active to receive this notification. This action can be used to implement actions
2371 * that wait until power is available to trigger.
Tom Taylord4a47292009-12-21 13:59:18 -08002372 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002373 * <p class="note">This is a protected intent that can only be sent
2374 * by the system.
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002375 */
2376 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Dianne Hackbornfe240ec2009-08-27 12:51:11 -07002377 public static final String ACTION_POWER_CONNECTED = "android.intent.action.ACTION_POWER_CONNECTED";
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002378 /**
2379 * Broadcast Action: External power has been removed from the device.
2380 * This is intended for applications that wish to register specifically to this notification.
2381 * Unlike ACTION_BATTERY_CHANGED, applications will be woken for this and so do not have to
2382 * stay active to receive this notification. This action can be used to implement actions
Romain Guy4969af72009-06-17 10:53:19 -07002383 * that wait until power is available to trigger.
Tom Taylord4a47292009-12-21 13:59:18 -08002384 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002385 * <p class="note">This is a protected intent that can only be sent
2386 * by the system.
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002387 */
2388 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jean-Baptiste Queru1ef45642008-10-24 11:49:25 -07002389 public static final String ACTION_POWER_DISCONNECTED =
Dianne Hackbornfe240ec2009-08-27 12:51:11 -07002390 "android.intent.action.ACTION_POWER_DISCONNECTED";
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002391 /**
Dianne Hackborn55280a92009-05-07 15:53:46 -07002392 * Broadcast Action: Device is shutting down.
2393 * This is broadcast when the device is being shut down (completely turned
2394 * off, not sleeping). Once the broadcast is complete, the final shutdown
2395 * will proceed and all unsaved data lost. Apps will not normally need
Dianne Hackbornfe240ec2009-08-27 12:51:11 -07002396 * to handle this, since the foreground activity will be paused as well.
Tom Taylord4a47292009-12-21 13:59:18 -08002397 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002398 * <p class="note">This is a protected intent that can only be sent
2399 * by the system.
Dianne Hackborn57a7f592013-07-22 18:21:32 -07002400 * <p>May include the following extras:
2401 * <ul>
2402 * <li> {@link #EXTRA_SHUTDOWN_USERSPACE_ONLY} a boolean that is set to true if this
2403 * shutdown is only for userspace processes. If not set, assumed to be false.
2404 * </ul>
Dianne Hackborn55280a92009-05-07 15:53:46 -07002405 */
2406 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Romain Guy4969af72009-06-17 10:53:19 -07002407 public static final String ACTION_SHUTDOWN = "android.intent.action.ACTION_SHUTDOWN";
Dianne Hackborn55280a92009-05-07 15:53:46 -07002408 /**
Mike Lockwoodbad80e02009-07-30 01:21:08 -07002409 * Activity Action: Start this activity to request system shutdown.
2410 * The optional boolean extra field {@link #EXTRA_KEY_CONFIRM} can be set to true
Yusuke Sato705ffd12015-07-21 15:52:11 -07002411 * to request confirmation from the user before shutting down. The optional boolean
2412 * extra field {@link #EXTRA_USER_REQUESTED_SHUTDOWN} can be set to true to
2413 * indicate that the shutdown is requested by the user.
Mike Lockwoodbad80e02009-07-30 01:21:08 -07002414 *
2415 * <p class="note">This is a protected intent that can only be sent
2416 * by the system.
2417 *
2418 * {@hide}
2419 */
2420 public static final String ACTION_REQUEST_SHUTDOWN = "android.intent.action.ACTION_REQUEST_SHUTDOWN";
2421 /**
Dianne Hackbornedd93162009-09-19 14:03:05 -07002422 * Broadcast Action: A sticky broadcast that indicates low memory
2423 * condition on the device
Tom Taylord4a47292009-12-21 13:59:18 -08002424 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002425 * <p class="note">This is a protected intent that can only be sent
2426 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002427 */
2428 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2429 public static final String ACTION_DEVICE_STORAGE_LOW = "android.intent.action.DEVICE_STORAGE_LOW";
2430 /**
2431 * Broadcast Action: Indicates low memory condition on the device no longer exists
Tom Taylord4a47292009-12-21 13:59:18 -08002432 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002433 * <p class="note">This is a protected intent that can only be sent
2434 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002435 */
2436 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2437 public static final String ACTION_DEVICE_STORAGE_OK = "android.intent.action.DEVICE_STORAGE_OK";
2438 /**
Jake Hambybb371632010-08-23 18:16:48 -07002439 * Broadcast Action: A sticky broadcast that indicates a memory full
2440 * condition on the device. This is intended for activities that want
2441 * to be able to fill the data partition completely, leaving only
2442 * enough free space to prevent system-wide SQLite failures.
2443 *
2444 * <p class="note">This is a protected intent that can only be sent
2445 * by the system.
2446 *
2447 * {@hide}
2448 */
2449 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2450 public static final String ACTION_DEVICE_STORAGE_FULL = "android.intent.action.DEVICE_STORAGE_FULL";
2451 /**
2452 * Broadcast Action: Indicates memory full condition on the device
2453 * no longer exists.
2454 *
2455 * <p class="note">This is a protected intent that can only be sent
2456 * by the system.
2457 *
2458 * {@hide}
2459 */
2460 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2461 public static final String ACTION_DEVICE_STORAGE_NOT_FULL = "android.intent.action.DEVICE_STORAGE_NOT_FULL";
2462 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002463 * Broadcast Action: Indicates low memory condition notification acknowledged by user
2464 * and package management should be started.
2465 * This is triggered by the user from the ACTION_DEVICE_STORAGE_LOW
2466 * notification.
2467 */
2468 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2469 public static final String ACTION_MANAGE_PACKAGE_STORAGE = "android.intent.action.MANAGE_PACKAGE_STORAGE";
2470 /**
2471 * Broadcast Action: The device has entered USB Mass Storage mode.
2472 * This is used mainly for the USB Settings panel.
2473 * Apps should listen for ACTION_MEDIA_MOUNTED and ACTION_MEDIA_UNMOUNTED broadcasts to be notified
2474 * when the SD card file system is mounted or unmounted
Mike Lockwood7e4db372011-06-07 11:23:44 -07002475 * @deprecated replaced by android.os.storage.StorageEventListener
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002476 */
Mike Lockwoodda85e522011-06-07 09:08:34 -07002477 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002478 public static final String ACTION_UMS_CONNECTED = "android.intent.action.UMS_CONNECTED";
2479
2480 /**
2481 * Broadcast Action: The device has exited USB Mass Storage mode.
2482 * This is used mainly for the USB Settings panel.
2483 * Apps should listen for ACTION_MEDIA_MOUNTED and ACTION_MEDIA_UNMOUNTED broadcasts to be notified
2484 * when the SD card file system is mounted or unmounted
Mike Lockwood7e4db372011-06-07 11:23:44 -07002485 * @deprecated replaced by android.os.storage.StorageEventListener
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002486 */
Mike Lockwoodda85e522011-06-07 09:08:34 -07002487 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002488 public static final String ACTION_UMS_DISCONNECTED = "android.intent.action.UMS_DISCONNECTED";
2489
2490 /**
2491 * Broadcast Action: External media has been removed.
2492 * The path to the mount point for the removed media is contained in the Intent.mData field.
2493 */
2494 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2495 public static final String ACTION_MEDIA_REMOVED = "android.intent.action.MEDIA_REMOVED";
2496
2497 /**
2498 * Broadcast Action: External media is present, but not mounted at its mount point.
suyi Yuanbe7af832013-01-04 21:21:59 +08002499 * 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 -07002500 */
2501 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2502 public static final String ACTION_MEDIA_UNMOUNTED = "android.intent.action.MEDIA_UNMOUNTED";
2503
2504 /**
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08002505 * Broadcast Action: External media is present, and being disk-checked
2506 * 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 -08002507 */
2508 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2509 public static final String ACTION_MEDIA_CHECKING = "android.intent.action.MEDIA_CHECKING";
2510
2511 /**
2512 * Broadcast Action: External media is present, but is using an incompatible fs (or is blank)
2513 * 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 -08002514 */
2515 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2516 public static final String ACTION_MEDIA_NOFS = "android.intent.action.MEDIA_NOFS";
2517
2518 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002519 * Broadcast Action: External media is present and mounted at its mount point.
suyi Yuanbe7af832013-01-04 21:21:59 +08002520 * 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 -07002521 * The Intent contains an extra with name "read-only" and Boolean value to indicate if the
2522 * media was mounted read only.
2523 */
2524 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2525 public static final String ACTION_MEDIA_MOUNTED = "android.intent.action.MEDIA_MOUNTED";
2526
2527 /**
2528 * Broadcast Action: External media is unmounted because it is being shared via USB mass storage.
Mike Lockwoodbf2dd442010-03-03 06:16:52 -05002529 * 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 -07002530 */
2531 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2532 public static final String ACTION_MEDIA_SHARED = "android.intent.action.MEDIA_SHARED";
2533
2534 /**
Mike Lockwoodbf2dd442010-03-03 06:16:52 -05002535 * Broadcast Action: External media is no longer being shared via USB mass storage.
2536 * The path to the mount point for the previously shared media is contained in the Intent.mData field.
2537 *
2538 * @hide
2539 */
2540 public static final String ACTION_MEDIA_UNSHARED = "android.intent.action.MEDIA_UNSHARED";
2541
2542 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002543 * Broadcast Action: External media was removed from SD card slot, but mount point was not unmounted.
2544 * The path to the mount point for the removed media is contained in the Intent.mData field.
2545 */
2546 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2547 public static final String ACTION_MEDIA_BAD_REMOVAL = "android.intent.action.MEDIA_BAD_REMOVAL";
2548
2549 /**
2550 * Broadcast Action: External media is present but cannot be mounted.
suyi Yuanbe7af832013-01-04 21:21:59 +08002551 * 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 -07002552 */
2553 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2554 public static final String ACTION_MEDIA_UNMOUNTABLE = "android.intent.action.MEDIA_UNMOUNTABLE";
2555
2556 /**
2557 * Broadcast Action: User has expressed the desire to remove the external storage media.
2558 * Applications should close all files they have open within the mount point when they receive this intent.
2559 * The path to the mount point for the media to be ejected is contained in the Intent.mData field.
2560 */
2561 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2562 public static final String ACTION_MEDIA_EJECT = "android.intent.action.MEDIA_EJECT";
2563
2564 /**
2565 * Broadcast Action: The media scanner has started scanning a directory.
2566 * The path to the directory being scanned is contained in the Intent.mData field.
2567 */
2568 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2569 public static final String ACTION_MEDIA_SCANNER_STARTED = "android.intent.action.MEDIA_SCANNER_STARTED";
2570
2571 /**
2572 * Broadcast Action: The media scanner has finished scanning a directory.
2573 * The path to the scanned directory is contained in the Intent.mData field.
2574 */
2575 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2576 public static final String ACTION_MEDIA_SCANNER_FINISHED = "android.intent.action.MEDIA_SCANNER_FINISHED";
2577
2578 /**
2579 * Broadcast Action: Request the media scanner to scan a file and add it to the media database.
2580 * The path to the file is contained in the Intent.mData field.
2581 */
2582 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2583 public static final String ACTION_MEDIA_SCANNER_SCAN_FILE = "android.intent.action.MEDIA_SCANNER_SCAN_FILE";
2584
2585 /**
2586 * Broadcast Action: The "Media Button" was pressed. Includes a single
2587 * extra field, {@link #EXTRA_KEY_EVENT}, containing the key event that
2588 * caused the broadcast.
2589 */
2590 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2591 public static final String ACTION_MEDIA_BUTTON = "android.intent.action.MEDIA_BUTTON";
2592
2593 /**
2594 * Broadcast Action: The "Camera Button" was pressed. Includes a single
2595 * extra field, {@link #EXTRA_KEY_EVENT}, containing the key event that
2596 * caused the broadcast.
2597 */
2598 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2599 public static final String ACTION_CAMERA_BUTTON = "android.intent.action.CAMERA_BUTTON";
2600
2601 // *** NOTE: @todo(*) The following really should go into a more domain-specific
2602 // location; they are not general-purpose actions.
2603
2604 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09002605 * Broadcast Action: A GTalk connection has been established.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002606 */
2607 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2608 public static final String ACTION_GTALK_SERVICE_CONNECTED =
2609 "android.intent.action.GTALK_CONNECTED";
2610
2611 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09002612 * Broadcast Action: A GTalk connection has been disconnected.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002613 */
2614 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2615 public static final String ACTION_GTALK_SERVICE_DISCONNECTED =
2616 "android.intent.action.GTALK_DISCONNECTED";
The Android Open Source Project10592532009-03-18 17:39:46 -07002617
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08002618 /**
2619 * Broadcast Action: An input method has been changed.
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08002620 */
2621 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2622 public static final String ACTION_INPUT_METHOD_CHANGED =
2623 "android.intent.action.INPUT_METHOD_CHANGED";
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002624
2625 /**
2626 * <p>Broadcast Action: The user has switched the phone into or out of Airplane Mode. One or
2627 * more radios have been turned off or on. The intent will have the following extra value:</p>
2628 * <ul>
2629 * <li><em>state</em> - A boolean value indicating whether Airplane Mode is on. If true,
2630 * then cell radio and possibly other radios such as bluetooth or WiFi may have also been
2631 * turned off</li>
2632 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002633 *
Peng Xua35b5532016-01-20 00:05:45 -08002634 * <p class="note">This is a protected intent that can only be sent by the system.</p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002635 */
2636 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2637 public static final String ACTION_AIRPLANE_MODE_CHANGED = "android.intent.action.AIRPLANE_MODE";
2638
2639 /**
2640 * Broadcast Action: Some content providers have parts of their namespace
2641 * where they publish new events or items that the user may be especially
2642 * interested in. For these things, they may broadcast this action when the
2643 * set of interesting items change.
2644 *
2645 * For example, GmailProvider sends this notification when the set of unread
2646 * mail in the inbox changes.
2647 *
2648 * <p>The data of the intent identifies which part of which provider
2649 * changed. When queried through the content resolver, the data URI will
2650 * return the data set in question.
2651 *
2652 * <p>The intent will have the following extra values:
2653 * <ul>
2654 * <li><em>count</em> - The number of items in the data set. This is the
2655 * same as the number of items in the cursor returned by querying the
2656 * data URI. </li>
2657 * </ul>
2658 *
2659 * This intent will be sent at boot (if the count is non-zero) and when the
2660 * data set changes. It is possible for the data set to change without the
2661 * count changing (for example, if a new unread message arrives in the same
2662 * sync operation in which a message is archived). The phone should still
2663 * ring/vibrate/etc as normal in this case.
2664 */
2665 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2666 public static final String ACTION_PROVIDER_CHANGED =
2667 "android.intent.action.PROVIDER_CHANGED";
2668
2669 /**
2670 * Broadcast Action: Wired Headset plugged in or unplugged.
2671 *
Jean-Michel Trivic5258432014-08-27 15:46:54 -07002672 * Same as {@link android.media.AudioManager#ACTION_HEADSET_PLUG}, to be consulted for value
2673 * and documentation.
2674 * <p>If the minimum SDK version of your application is
Dianne Hackborn955d8d62014-10-07 20:17:19 -07002675 * {@link android.os.Build.VERSION_CODES#LOLLIPOP}, it is recommended to refer
Jean-Michel Trivic5258432014-08-27 15:46:54 -07002676 * to the <code>AudioManager</code> constant in your receiver registration code instead.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002677 */
2678 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jean-Michel Trivic5258432014-08-27 15:46:54 -07002679 public static final String ACTION_HEADSET_PLUG = android.media.AudioManager.ACTION_HEADSET_PLUG;
Eric Laurent59f48272012-04-05 19:42:21 -07002680
2681 /**
Joe Onorato9cdffa12011-04-06 18:27:27 -07002682 * <p>Broadcast Action: The user has switched on advanced settings in the settings app:</p>
2683 * <ul>
2684 * <li><em>state</em> - A boolean value indicating whether the settings is on or off.</li>
2685 * </ul>
2686 *
2687 * <p class="note">This is a protected intent that can only be sent
2688 * by the system.
2689 *
2690 * @hide
2691 */
2692 //@SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2693 public static final String ACTION_ADVANCED_SETTINGS_CHANGED
2694 = "android.intent.action.ADVANCED_SETTINGS";
2695
2696 /**
Robin Lee66e5d962014-04-09 16:44:21 +01002697 * Broadcast Action: Sent after application restrictions are changed.
2698 *
2699 * <p class="note">This is a protected intent that can only be sent
2700 * by the system.</p>
2701 */
2702 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2703 public static final String ACTION_APPLICATION_RESTRICTIONS_CHANGED =
2704 "android.intent.action.APPLICATION_RESTRICTIONS_CHANGED";
2705
2706 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002707 * Broadcast Action: An outgoing call is about to be placed.
2708 *
Dirk Dougherty367ce902013-05-28 17:37:12 -07002709 * <p>The Intent will have the following extra value:</p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002710 * <ul>
The Android Open Source Project10592532009-03-18 17:39:46 -07002711 * <li><em>{@link android.content.Intent#EXTRA_PHONE_NUMBER}</em> -
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002712 * the phone number originally intended to be dialed.</li>
2713 * </ul>
2714 * <p>Once the broadcast is finished, the resultData is used as the actual
2715 * number to call. If <code>null</code>, no call will be placed.</p>
The Android Open Source Project10592532009-03-18 17:39:46 -07002716 * <p>It is perfectly acceptable for multiple receivers to process the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002717 * outgoing call in turn: for example, a parental control application
2718 * might verify that the user is authorized to place the call at that
2719 * time, then a number-rewriting application might add an area code if
2720 * one was not specified.</p>
2721 * <p>For consistency, any receiver whose purpose is to prohibit phone
2722 * calls should have a priority of 0, to ensure it will see the final
2723 * phone number to be dialed.
The Android Open Source Project10592532009-03-18 17:39:46 -07002724 * Any receiver whose purpose is to rewrite phone numbers to be called
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002725 * should have a positive priority.
2726 * Negative priorities are reserved for the system for this broadcast;
2727 * using them may cause problems.</p>
Dirk Dougherty932fbcc2013-05-29 15:19:14 -07002728 * <p>Any BroadcastReceiver receiving this Intent <em>must not</em>
2729 * abort the broadcast.</p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002730 * <p>Emergency calls cannot be intercepted using this mechanism, and
2731 * other calls cannot be modified to call emergency numbers using this
2732 * mechanism.
Santos Cordonba701362013-05-17 14:48:54 -07002733 * <p>Some apps (such as VoIP apps) may want to redirect the outgoing
2734 * call to use their own service instead. Those apps should first prevent
2735 * the call from being placed by setting resultData to <code>null</code>
2736 * and then start their own app to make the call.
The Android Open Source Project10592532009-03-18 17:39:46 -07002737 * <p>You must hold the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002738 * {@link android.Manifest.permission#PROCESS_OUTGOING_CALLS}
2739 * permission to receive this Intent.</p>
Tom Taylord4a47292009-12-21 13:59:18 -08002740 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002741 * <p class="note">This is a protected intent that can only be sent
2742 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002743 */
2744 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2745 public static final String ACTION_NEW_OUTGOING_CALL =
2746 "android.intent.action.NEW_OUTGOING_CALL";
2747
2748 /**
2749 * Broadcast Action: Have the device reboot. This is only for use by
2750 * system code.
Tom Taylord4a47292009-12-21 13:59:18 -08002751 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002752 * <p class="note">This is a protected intent that can only be sent
2753 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002754 */
2755 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2756 public static final String ACTION_REBOOT =
2757 "android.intent.action.REBOOT";
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002758
Wei Huang97ecc9c2009-05-11 17:44:20 -07002759 /**
Dianne Hackborn7299c412010-03-04 18:41:49 -08002760 * Broadcast Action: A sticky broadcast for changes in the physical
2761 * docking state of the device.
Tobias Haamel154f7a12010-02-17 11:56:39 -08002762 *
2763 * <p>The intent will have the following extra values:
2764 * <ul>
2765 * <li><em>{@link #EXTRA_DOCK_STATE}</em> - the current dock
Dianne Hackborn7299c412010-03-04 18:41:49 -08002766 * state, indicating which dock the device is physically in.</li>
Tobias Haamel154f7a12010-02-17 11:56:39 -08002767 * </ul>
Dianne Hackborn7299c412010-03-04 18:41:49 -08002768 * <p>This is intended for monitoring the current physical dock state.
2769 * See {@link android.app.UiModeManager} for the normal API dealing with
2770 * dock mode changes.
Dianne Hackbornedd93162009-09-19 14:03:05 -07002771 */
2772 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2773 public static final String ACTION_DOCK_EVENT =
2774 "android.intent.action.DOCK_EVENT";
2775
2776 /**
Svetoslavb3038ec2013-02-13 14:39:30 -08002777 * Broadcast Action: A broadcast when idle maintenance can be started.
2778 * This means that the user is not interacting with the device and is
2779 * not expected to do so soon. Typical use of the idle maintenance is
2780 * to perform somehow expensive tasks that can be postponed at a moment
2781 * when they will not degrade user experience.
2782 * <p>
2783 * <p class="note">In order to keep the device responsive in case of an
2784 * unexpected user interaction, implementations of a maintenance task
2785 * should be interruptible. In such a scenario a broadcast with action
2786 * {@link #ACTION_IDLE_MAINTENANCE_END} will be sent. In other words, you
2787 * should not do the maintenance work in
2788 * {@link BroadcastReceiver#onReceive(Context, Intent)}, rather start a
2789 * maintenance service by {@link Context#startService(Intent)}. Also
2790 * you should hold a wake lock while your maintenance service is running
2791 * to prevent the device going to sleep.
2792 * </p>
2793 * <p>
2794 * <p class="note">This is a protected intent that can only be sent by
2795 * the system.
2796 * </p>
2797 *
2798 * @see #ACTION_IDLE_MAINTENANCE_END
Svetoslav6a08a122013-05-03 11:24:26 -07002799 *
2800 * @hide
Svetoslavb3038ec2013-02-13 14:39:30 -08002801 */
2802 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2803 public static final String ACTION_IDLE_MAINTENANCE_START =
2804 "android.intent.action.ACTION_IDLE_MAINTENANCE_START";
2805
2806 /**
2807 * Broadcast Action: A broadcast when idle maintenance should be stopped.
2808 * This means that the user was not interacting with the device as a result
2809 * of which a broadcast with action {@link #ACTION_IDLE_MAINTENANCE_START}
2810 * was sent and now the user started interacting with the device. Typical
2811 * use of the idle maintenance is to perform somehow expensive tasks that
2812 * can be postponed at a moment when they will not degrade user experience.
2813 * <p>
2814 * <p class="note">In order to keep the device responsive in case of an
2815 * unexpected user interaction, implementations of a maintenance task
2816 * should be interruptible. Hence, on receiving a broadcast with this
2817 * action, the maintenance task should be interrupted as soon as possible.
2818 * In other words, you should not do the maintenance work in
2819 * {@link BroadcastReceiver#onReceive(Context, Intent)}, rather stop the
2820 * maintenance service that was started on receiving of
2821 * {@link #ACTION_IDLE_MAINTENANCE_START}.Also you should release the wake
2822 * lock you acquired when your maintenance service started.
2823 * </p>
2824 * <p class="note">This is a protected intent that can only be sent
2825 * by the system.
2826 *
2827 * @see #ACTION_IDLE_MAINTENANCE_START
Svetoslav6a08a122013-05-03 11:24:26 -07002828 *
2829 * @hide
Svetoslavb3038ec2013-02-13 14:39:30 -08002830 */
2831 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2832 public static final String ACTION_IDLE_MAINTENANCE_END =
2833 "android.intent.action.ACTION_IDLE_MAINTENANCE_END";
2834
2835 /**
Wei Huang97ecc9c2009-05-11 17:44:20 -07002836 * Broadcast Action: a remote intent is to be broadcasted.
2837 *
2838 * A remote intent is used for remote RPC between devices. The remote intent
2839 * is serialized and sent from one device to another device. The receiving
2840 * device parses the remote intent and broadcasts it. Note that anyone can
2841 * broadcast a remote intent. However, if the intent receiver of the remote intent
2842 * does not trust intent broadcasts from arbitrary intent senders, it should require
2843 * the sender to hold certain permissions so only trusted sender's broadcast will be
2844 * let through.
Dianne Hackbornedd93162009-09-19 14:03:05 -07002845 * @hide
Wei Huang97ecc9c2009-05-11 17:44:20 -07002846 */
2847 public static final String ACTION_REMOTE_INTENT =
Costin Manolache8d83f9e2010-05-12 16:04:10 -07002848 "com.google.android.c2dm.intent.RECEIVE";
Wei Huang97ecc9c2009-05-11 17:44:20 -07002849
Dianne Hackborn9acc0302009-08-25 00:27:12 -07002850 /**
Jeff Sharkeybd91e2f2016-03-22 15:32:31 -06002851 * Broadcast Action: This is broadcast once when the user is booting after a
2852 * system update. It can be used to perform cleanup or upgrades after a
2853 * system update.
2854 * <p>
2855 * This broadcast is sent after the {@link #ACTION_LOCKED_BOOT_COMPLETED}
2856 * broadcast but before the {@link #ACTION_BOOT_COMPLETED} broadcast. It's
2857 * only sent when the {@link Build#FINGERPRINT} has changed, and it's only
2858 * sent to receivers in the system image.
Dianne Hackborn9acc0302009-08-25 00:27:12 -07002859 *
Dianne Hackborn9acc0302009-08-25 00:27:12 -07002860 * @hide
2861 */
2862 public static final String ACTION_PRE_BOOT_COMPLETED =
2863 "android.intent.action.PRE_BOOT_COMPLETED";
2864
Amith Yamasani13593602012-03-22 16:16:17 -07002865 /**
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08002866 * Broadcast to a specific application to query any supported restrictions to impose
Amith Yamasani7e99bc02013-04-16 18:24:51 -07002867 * on restricted users. The broadcast intent contains an extra
2868 * {@link #EXTRA_RESTRICTIONS_BUNDLE} with the currently persisted
2869 * restrictions as a Bundle of key/value pairs. The value types can be Boolean, String or
2870 * String[] depending on the restriction type.<p/>
2871 * The response should contain an extra {@link #EXTRA_RESTRICTIONS_LIST},
Amith Yamasani86118ba2013-03-28 14:33:16 -07002872 * which is of type <code>ArrayList&lt;RestrictionEntry&gt;</code>. It can also
2873 * contain an extra {@link #EXTRA_RESTRICTIONS_INTENT}, which is of type <code>Intent</code>.
2874 * The activity specified by that intent will be launched for a result which must contain
Amith Yamasani3b458ad2013-04-18 18:40:07 -07002875 * one of the extras {@link #EXTRA_RESTRICTIONS_LIST} or {@link #EXTRA_RESTRICTIONS_BUNDLE}.
2876 * The keys and values of the returned restrictions will be persisted.
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08002877 * @see RestrictionEntry
2878 */
2879 public static final String ACTION_GET_RESTRICTION_ENTRIES =
2880 "android.intent.action.GET_RESTRICTION_ENTRIES";
2881
2882 /**
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002883 * Sent the first time a user is starting, to allow system apps to
2884 * perform one time initialization. (This will not be seen by third
2885 * party applications because a newly initialized user does not have any
2886 * third party applications installed for it.) This is sent early in
2887 * starting the user, around the time the home app is started, before
Dianne Hackborn36d337a2012-10-08 14:33:47 -07002888 * {@link #ACTION_BOOT_COMPLETED} is sent. This is sent as a foreground
2889 * broadcast, since it is part of a visible user interaction; be as quick
2890 * as possible when handling it.
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002891 */
2892 public static final String ACTION_USER_INITIALIZE =
2893 "android.intent.action.USER_INITIALIZE";
2894
2895 /**
2896 * Sent when a user switch is happening, causing the process's user to be
2897 * brought to the foreground. This is only sent to receivers registered
2898 * through {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
2899 * Context.registerReceiver}. It is sent to the user that is going to the
Dianne Hackborn36d337a2012-10-08 14:33:47 -07002900 * foreground. This is sent as a foreground
2901 * broadcast, since it is part of a visible user interaction; be as quick
2902 * as possible when handling it.
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002903 */
2904 public static final String ACTION_USER_FOREGROUND =
2905 "android.intent.action.USER_FOREGROUND";
2906
2907 /**
2908 * Sent when a user switch is happening, causing the process's user to be
2909 * sent to the background. This is only sent to receivers registered
2910 * through {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
2911 * Context.registerReceiver}. It is sent to the user that is going to the
Dianne Hackborn36d337a2012-10-08 14:33:47 -07002912 * background. This is sent as a foreground
2913 * broadcast, since it is part of a visible user interaction; be as quick
2914 * as possible when handling it.
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002915 */
2916 public static final String ACTION_USER_BACKGROUND =
2917 "android.intent.action.USER_BACKGROUND";
2918
2919 /**
Dianne Hackborn36d337a2012-10-08 14:33:47 -07002920 * Broadcast sent to the system when a user is added. Carries an extra
2921 * EXTRA_USER_HANDLE that has the userHandle of the new user. It is sent to
2922 * all running users. You must hold
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002923 * {@link android.Manifest.permission#MANAGE_USERS} to receive this broadcast.
Amith Yamasani13593602012-03-22 16:16:17 -07002924 * @hide
2925 */
2926 public static final String ACTION_USER_ADDED =
2927 "android.intent.action.USER_ADDED";
2928
2929 /**
Dianne Hackborn36d337a2012-10-08 14:33:47 -07002930 * Broadcast sent by the system when a user is started. Carries an extra
2931 * EXTRA_USER_HANDLE that has the userHandle of the user. This is only sent to
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002932 * registered receivers, not manifest receivers. It is sent to the user
Dianne Hackborn36d337a2012-10-08 14:33:47 -07002933 * that has been started. This is sent as a foreground
2934 * broadcast, since it is part of a visible user interaction; be as quick
2935 * as possible when handling it.
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002936 * @hide
2937 */
2938 public static final String ACTION_USER_STARTED =
2939 "android.intent.action.USER_STARTED";
2940
2941 /**
Dianne Hackborn36d337a2012-10-08 14:33:47 -07002942 * Broadcast sent when a user is in the process of starting. Carries an extra
2943 * EXTRA_USER_HANDLE that has the userHandle of the user. This is only
2944 * sent to registered receivers, not manifest receivers. It is sent to all
2945 * users (including the one that is being started). You must hold
2946 * {@link android.Manifest.permission#INTERACT_ACROSS_USERS} to receive
2947 * this broadcast. This is sent as a background broadcast, since
2948 * its result is not part of the primary UX flow; to safely keep track of
2949 * started/stopped state of a user you can use this in conjunction with
2950 * {@link #ACTION_USER_STOPPING}. It is <b>not</b> generally safe to use with
2951 * other user state broadcasts since those are foreground broadcasts so can
2952 * execute in a different order.
2953 * @hide
2954 */
2955 public static final String ACTION_USER_STARTING =
2956 "android.intent.action.USER_STARTING";
2957
2958 /**
2959 * Broadcast sent when a user is going to be stopped. Carries an extra
2960 * EXTRA_USER_HANDLE that has the userHandle of the user. This is only
2961 * sent to registered receivers, not manifest receivers. It is sent to all
2962 * users (including the one that is being stopped). You must hold
2963 * {@link android.Manifest.permission#INTERACT_ACROSS_USERS} to receive
2964 * this broadcast. The user will not stop until all receivers have
2965 * handled the broadcast. This is sent as a background broadcast, since
2966 * its result is not part of the primary UX flow; to safely keep track of
2967 * started/stopped state of a user you can use this in conjunction with
2968 * {@link #ACTION_USER_STARTING}. It is <b>not</b> generally safe to use with
2969 * other user state broadcasts since those are foreground broadcasts so can
2970 * execute in a different order.
2971 * @hide
2972 */
2973 public static final String ACTION_USER_STOPPING =
2974 "android.intent.action.USER_STOPPING";
2975
2976 /**
2977 * Broadcast sent to the system when a user is stopped. Carries an extra
2978 * EXTRA_USER_HANDLE that has the userHandle of the user. This is similar to
2979 * {@link #ACTION_PACKAGE_RESTARTED}, but for an entire user instead of a
2980 * specific package. This is only sent to registered receivers, not manifest
2981 * receivers. It is sent to all running users <em>except</em> the one that
2982 * has just been stopped (which is no longer running).
Dianne Hackborn80a4af22012-08-27 19:18:31 -07002983 * @hide
2984 */
2985 public static final String ACTION_USER_STOPPED =
2986 "android.intent.action.USER_STOPPED";
2987
2988 /**
Amith Yamasani2a003292012-08-14 18:25:45 -07002989 * 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 -07002990 * the userHandle of the user. It is sent to all running users except the
Amith Yamasanidb6a14c2012-10-17 21:16:52 -07002991 * one that has been removed. The user will not be completely removed until all receivers have
2992 * handled the broadcast. You must hold
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002993 * {@link android.Manifest.permission#MANAGE_USERS} to receive this broadcast.
Amith Yamasani13593602012-03-22 16:16:17 -07002994 * @hide
2995 */
2996 public static final String ACTION_USER_REMOVED =
2997 "android.intent.action.USER_REMOVED";
2998
2999 /**
Amith Yamasani2a003292012-08-14 18:25:45 -07003000 * Broadcast sent to the system when the user switches. Carries an extra EXTRA_USER_HANDLE that has
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07003001 * the userHandle of the user to become the current one. This is only sent to
3002 * registered receivers, not manifest receivers. It is sent to all running users.
3003 * You must hold
3004 * {@link android.Manifest.permission#MANAGE_USERS} to receive this broadcast.
Amith Yamasani13593602012-03-22 16:16:17 -07003005 * @hide
3006 */
3007 public static final String ACTION_USER_SWITCHED =
3008 "android.intent.action.USER_SWITCHED";
3009
Amith Yamasanie928d7d2012-09-17 21:46:51 -07003010 /**
Jeff Sharkey8924e872015-11-30 12:52:10 -07003011 * Broadcast Action: Sent when the credential-encrypted private storage has
3012 * become unlocked for the target user. This is only sent to registered
3013 * receivers, not manifest receivers.
3014 */
3015 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3016 public static final String ACTION_USER_UNLOCKED = "android.intent.action.USER_UNLOCKED";
3017
3018 /**
Amith Yamasanie928d7d2012-09-17 21:46:51 -07003019 * Broadcast sent to the system when a user's information changes. Carries an extra
3020 * {@link #EXTRA_USER_HANDLE} to indicate which user's information changed.
Amith Yamasani6fc1d4e2013-05-08 16:43:58 -07003021 * This is only sent to registered receivers, not manifest receivers. It is sent to all users.
Amith Yamasanie928d7d2012-09-17 21:46:51 -07003022 * @hide
3023 */
3024 public static final String ACTION_USER_INFO_CHANGED =
3025 "android.intent.action.USER_INFO_CHANGED";
3026
Daniel Sandler2e7d25b2012-10-01 16:43:26 -04003027 /**
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01003028 * Broadcast sent to the primary user when an associated managed profile is added (the profile
3029 * was created and is ready to be used). Carries an extra {@link #EXTRA_USER} that specifies
Adam Connorsd4b584e2014-06-09 13:55:47 +01003030 * the UserHandle of the profile that was added. Only applications (for example Launchers)
3031 * that need to display merged content across both primary and managed profiles need to
3032 * worry about this broadcast. This is only sent to registered receivers,
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01003033 * not manifest receivers.
3034 */
3035 public static final String ACTION_MANAGED_PROFILE_ADDED =
3036 "android.intent.action.MANAGED_PROFILE_ADDED";
3037
3038 /**
3039 * Broadcast sent to the primary user when an associated managed profile is removed. Carries an
Adam Connorsd4b584e2014-06-09 13:55:47 +01003040 * extra {@link #EXTRA_USER} that specifies the UserHandle of the profile that was removed.
3041 * Only applications (for example Launchers) that need to display merged content across both
3042 * primary and managed profiles need to worry about this broadcast. This is only sent to
3043 * registered receivers, not manifest receivers.
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01003044 */
3045 public static final String ACTION_MANAGED_PROFILE_REMOVED =
3046 "android.intent.action.MANAGED_PROFILE_REMOVED";
3047
3048 /**
Kenny Guyb1b30262016-02-09 16:02:35 +00003049 * Broadcast sent to the primary user when the credential-encrypted private storage for
3050 * an associated managed profile is unlocked. Carries an extra {@link #EXTRA_USER} that
3051 * specifies the UserHandle of the profile that was unlocked. Only applications (for example
3052 * Launchers) that need to display merged content across both primary and managed profiles
3053 * need to worry about this broadcast. This is only sent to registered receivers,
3054 * not manifest receivers.
3055 */
3056 public static final String ACTION_MANAGED_PROFILE_UNLOCKED =
3057 "android.intent.action.MANAGED_PROFILE_UNLOCKED";
3058
Rubin Xue95057a2016-04-01 16:49:25 +01003059 /** @hide */
3060 public static final String ACTION_MANAGED_PROFILE_AVAILABILITY_CHANGED =
3061 "android.intent.action.MANAGED_PROFILE_AVAILABILITY_CHANGED";
3062
Kenny Guyb1b30262016-02-09 16:02:35 +00003063 /**
Rubin Xue95057a2016-04-01 16:49:25 +01003064 * Broadcast sent to the primary user when an associated managed profile has become available.
3065 * Currently this includes when the user disables quiet mode for the profile. Carries an extra
Rubin Xuf13c9802016-01-21 18:06:00 +00003066 * {@link #EXTRA_USER} that specifies the UserHandle of the profile. When quiet mode is changed,
3067 * this broadcast will carry a boolean extra {@link #EXTRA_QUIET_MODE} indicating the new state
3068 * of quiet mode. This is only sent to registered receivers, not manifest receivers.
Rubin Xu0a29ecd2015-11-04 15:11:48 +00003069 */
Rubin Xue95057a2016-04-01 16:49:25 +01003070 public static final String ACTION_MANAGED_PROFILE_AVAILABLE =
3071 "android.intent.action.MANAGED_PROFILE_AVAILABLE";
3072
3073 /**
3074 * Broadcast sent to the primary user when an associated managed profile has become unavailable.
3075 * Currently this includes when the user enables quiet mode for the profile. Carries an extra
3076 * {@link #EXTRA_USER} that specifies the UserHandle of the profile. When quiet mode is changed,
3077 * this broadcast will carry a boolean extra {@link #EXTRA_QUIET_MODE} indicating the new state
3078 * of quiet mode. This is only sent to registered receivers, not manifest receivers.
3079 */
3080 public static final String ACTION_MANAGED_PROFILE_UNAVAILABLE =
3081 "android.intent.action.MANAGED_PROFILE_UNAVAILABLE";
Rubin Xu0a29ecd2015-11-04 15:11:48 +00003082
3083 /**
Daniel Sandler2e7d25b2012-10-01 16:43:26 -04003084 * Sent when the user taps on the clock widget in the system's "quick settings" area.
3085 */
3086 public static final String ACTION_QUICK_CLOCK =
3087 "android.intent.action.QUICK_CLOCK";
3088
Michael Wright0087a142013-02-05 16:29:39 -08003089 /**
Alan Viverette5a399492014-07-14 16:19:38 -07003090 * Activity Action: Shows the brightness setting dialog.
Michael Wright0087a142013-02-05 16:29:39 -08003091 * @hide
3092 */
3093 public static final String ACTION_SHOW_BRIGHTNESS_DIALOG =
3094 "android.intent.action.SHOW_BRIGHTNESS_DIALOG";
3095
Justin Kohd378ad72013-04-01 12:18:26 -07003096 /**
3097 * Broadcast Action: A global button was pressed. Includes a single
3098 * extra field, {@link #EXTRA_KEY_EVENT}, containing the key event that
3099 * caused the broadcast.
3100 * @hide
3101 */
3102 public static final String ACTION_GLOBAL_BUTTON = "android.intent.action.GLOBAL_BUTTON";
3103
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003104 /**
Dongwon Kang2034a4c2015-12-14 21:57:34 +09003105 * Broadcast Action: Sent when media resource is granted.
3106 * <p>
3107 * {@link #EXTRA_PACKAGES} specifies the packages on the process holding the media resource
3108 * granted.
3109 * </p>
3110 * <p class="note">
3111 * This is a protected intent that can only be sent by the system.
3112 * </p>
3113 * <p class="note">
Dongwon Kang32cb9ab2016-01-13 18:11:10 -08003114 * This requires {@link android.Manifest.permission#RECEIVE_MEDIA_RESOURCE_USAGE} permission.
Dongwon Kang2034a4c2015-12-14 21:57:34 +09003115 * </p>
3116 *
3117 * @hide
3118 */
3119 public static final String ACTION_MEDIA_RESOURCE_GRANTED =
3120 "android.intent.action.MEDIA_RESOURCE_GRANTED";
3121
3122 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003123 * Activity Action: Allow the user to select and return one or more existing
3124 * documents. When invoked, the system will display the various
3125 * {@link DocumentsProvider} instances installed on the device, letting the
3126 * user interactively navigate through them. These documents include local
3127 * media, such as photos and video, and documents provided by installed
3128 * cloud storage providers.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003129 * <p>
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003130 * Each document is represented as a {@code content://} URI backed by a
3131 * {@link DocumentsProvider}, which can be opened as a stream with
3132 * {@link ContentResolver#openFileDescriptor(Uri, String)}, or queried for
3133 * {@link android.provider.DocumentsContract.Document} metadata.
3134 * <p>
3135 * All selected documents are returned to the calling application with
3136 * persistable read and write permission grants. If you want to maintain
3137 * access to the documents across device reboots, you need to explicitly
3138 * take the persistable permissions using
3139 * {@link ContentResolver#takePersistableUriPermission(Uri, int)}.
3140 * <p>
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003141 * Callers must indicate the acceptable document MIME types through
3142 * {@link #setType(String)}. For example, to select photos, use
3143 * {@code image/*}. If multiple disjoint MIME types are acceptable, define
3144 * them in {@link #EXTRA_MIME_TYPES} and {@link #setType(String)} to
3145 * {@literal *}/*.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003146 * <p>
3147 * If the caller can handle multiple returned items (the user performing
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003148 * multiple selection), then you can specify {@link #EXTRA_ALLOW_MULTIPLE}
3149 * to indicate this.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003150 * <p>
Tomasz Mikolajewskia8057a92015-11-16 11:41:28 +09003151 * Callers must include {@link #CATEGORY_OPENABLE} in the Intent to obtain
3152 * URIs that can be opened with
Jeff Sharkeybd3b9022013-08-20 15:20:04 -07003153 * {@link ContentResolver#openFileDescriptor(Uri, String)}.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003154 * <p>
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003155 * Output: The URI of the item that was picked, returned in
3156 * {@link #getData()}. This must be a {@code content://} URI so that any
3157 * receiver can access it. If multiple documents were selected, they are
3158 * returned in {@link #getClipData()}.
Jeff Sharkeybd3b9022013-08-20 15:20:04 -07003159 *
3160 * @see DocumentsContract
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003161 * @see #ACTION_OPEN_DOCUMENT_TREE
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003162 * @see #ACTION_CREATE_DOCUMENT
3163 * @see #FLAG_GRANT_PERSISTABLE_URI_PERMISSION
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003164 */
3165 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
3166 public static final String ACTION_OPEN_DOCUMENT = "android.intent.action.OPEN_DOCUMENT";
3167
3168 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003169 * Activity Action: Allow the user to create a new document. When invoked,
3170 * the system will display the various {@link DocumentsProvider} instances
3171 * installed on the device, letting the user navigate through them. The
3172 * returned document may be a newly created document with no content, or it
3173 * may be an existing document with the requested MIME type.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003174 * <p>
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003175 * Each document is represented as a {@code content://} URI backed by a
3176 * {@link DocumentsProvider}, which can be opened as a stream with
3177 * {@link ContentResolver#openFileDescriptor(Uri, String)}, or queried for
3178 * {@link android.provider.DocumentsContract.Document} metadata.
3179 * <p>
3180 * Callers must indicate the concrete MIME type of the document being
3181 * created by setting {@link #setType(String)}. This MIME type cannot be
3182 * changed after the document is created.
3183 * <p>
3184 * Callers can provide an initial display name through {@link #EXTRA_TITLE},
3185 * but the user may change this value before creating the file.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003186 * <p>
Tomasz Mikolajewskia8057a92015-11-16 11:41:28 +09003187 * Callers must include {@link #CATEGORY_OPENABLE} in the Intent to obtain
3188 * URIs that can be opened with
Jeff Sharkeybd3b9022013-08-20 15:20:04 -07003189 * {@link ContentResolver#openFileDescriptor(Uri, String)}.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003190 * <p>
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003191 * Output: The URI of the item that was created. This must be a
3192 * {@code content://} URI so that any receiver can access it.
Jeff Sharkeybd3b9022013-08-20 15:20:04 -07003193 *
3194 * @see DocumentsContract
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003195 * @see #ACTION_OPEN_DOCUMENT
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003196 * @see #ACTION_OPEN_DOCUMENT_TREE
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003197 * @see #FLAG_GRANT_PERSISTABLE_URI_PERMISSION
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003198 */
3199 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
3200 public static final String ACTION_CREATE_DOCUMENT = "android.intent.action.CREATE_DOCUMENT";
3201
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003202 /**
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003203 * Activity Action: Allow the user to pick a directory subtree. When
3204 * invoked, the system will display the various {@link DocumentsProvider}
3205 * instances installed on the device, letting the user navigate through
3206 * them. Apps can fully manage documents within the returned directory.
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003207 * <p>
3208 * To gain access to descendant (child, grandchild, etc) documents, use
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003209 * {@link DocumentsContract#buildDocumentUriUsingTree(Uri, String)} and
3210 * {@link DocumentsContract#buildChildDocumentsUriUsingTree(Uri, String)}
3211 * with the returned URI.
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003212 * <p>
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003213 * Output: The URI representing the selected directory tree.
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003214 *
3215 * @see DocumentsContract
3216 */
3217 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003218 public static final String
3219 ACTION_OPEN_DOCUMENT_TREE = "android.intent.action.OPEN_DOCUMENT_TREE";
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003220
Felipe Lemec7b1f892016-01-15 15:02:31 -08003221 /**
Peng Xua35b5532016-01-20 00:05:45 -08003222 * Broadcast Action: List of dynamic sensor is changed due to new sensor being connected or
3223 * exisiting sensor being disconnected.
3224 *
3225 * <p class="note">This is a protected intent that can only be sent by the system.</p>
3226 *
3227 * {@hide}
3228 */
3229 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3230 public static final String
3231 ACTION_DYNAMIC_SENSOR_CHANGED = "android.intent.action.DYNAMIC_SENSOR_CHANGED";
3232
Jeff Sharkey004a4b22014-09-24 11:45:24 -07003233 /** {@hide} */
3234 public static final String ACTION_MASTER_CLEAR = "android.intent.action.MASTER_CLEAR";
3235
Christopher Tate6597e342015-02-17 12:15:25 -08003236 /**
3237 * Broadcast action: report that a settings element is being restored from backup. The intent
3238 * contains three extras: EXTRA_SETTING_NAME is a string naming the restored setting,
3239 * EXTRA_SETTING_NEW_VALUE is the value being restored, and EXTRA_SETTING_PREVIOUS_VALUE
3240 * is the value of that settings entry prior to the restore operation. All of these values are
3241 * represented as strings.
3242 *
3243 * <p>This broadcast is sent only for settings provider entries known to require special handling
3244 * around restore time. These entries are found in the BROADCAST_ON_RESTORE table within
3245 * the provider's backup agent implementation.
3246 *
3247 * @see #EXTRA_SETTING_NAME
3248 * @see #EXTRA_SETTING_PREVIOUS_VALUE
3249 * @see #EXTRA_SETTING_NEW_VALUE
3250 * {@hide}
3251 */
3252 public static final String ACTION_SETTING_RESTORED = "android.os.action.SETTING_RESTORED";
3253
3254 /** {@hide} */
3255 public static final String EXTRA_SETTING_NAME = "setting_name";
3256 /** {@hide} */
3257 public static final String EXTRA_SETTING_PREVIOUS_VALUE = "previous_value";
3258 /** {@hide} */
3259 public static final String EXTRA_SETTING_NEW_VALUE = "new_value";
3260
Clara Bayarri0a26157a2015-03-26 18:38:55 +00003261 /**
3262 * Activity Action: Process a piece of text.
3263 * <p>Input: {@link #EXTRA_PROCESS_TEXT} contains the text to be processed.
3264 * {@link #EXTRA_PROCESS_TEXT_READONLY} states if the resulting text will be read-only.</p>
3265 * <p>Output: {@link #EXTRA_PROCESS_TEXT} contains the processed text.</p>
3266 */
3267 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
3268 public static final String ACTION_PROCESS_TEXT = "android.intent.action.PROCESS_TEXT";
3269 /**
Clara Bayarri92c8e6f2015-05-21 17:50:08 +01003270 * The name of the extra used to define the text to be processed, as a
3271 * CharSequence. Note that this may be a styled CharSequence, so you must use
3272 * {@link Bundle#getCharSequence(String) Bundle.getCharSequence()} to retrieve it.
Clara Bayarri0a26157a2015-03-26 18:38:55 +00003273 */
3274 public static final String EXTRA_PROCESS_TEXT = "android.intent.extra.PROCESS_TEXT";
3275 /**
Clara Bayarri92c8e6f2015-05-21 17:50:08 +01003276 * 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 +00003277 */
3278 public static final String EXTRA_PROCESS_TEXT_READONLY =
3279 "android.intent.extra.PROCESS_TEXT_READONLY";
3280
Bryce Leebc58f592015-09-25 16:43:01 -07003281 /**
3282 * Broadcast action: reports when a new thermal event has been reached. When the device
3283 * is reaching its maximum temperatue, the thermal level reported
3284 * {@hide}
3285 */
3286 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
3287 public static final String ACTION_THERMAL_EVENT = "android.intent.action.THERMAL_EVENT";
3288
3289 /** {@hide} */
3290 public static final String EXTRA_THERMAL_STATE = "android.intent.extra.THERMAL_STATE";
3291
3292 /**
3293 * Thermal state when the device is normal. This state is sent in the
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08003294 * {@link #ACTION_THERMAL_EVENT} broadcast as {@link #EXTRA_THERMAL_STATE}.
Bryce Leebc58f592015-09-25 16:43:01 -07003295 * {@hide}
3296 */
3297 public static final int EXTRA_THERMAL_STATE_NORMAL = 0;
3298
3299 /**
3300 * Thermal state where the device is approaching its maximum threshold. This state is sent in
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08003301 * the {@link #ACTION_THERMAL_EVENT} broadcast as {@link #EXTRA_THERMAL_STATE}.
Bryce Leebc58f592015-09-25 16:43:01 -07003302 * {@hide}
3303 */
3304 public static final int EXTRA_THERMAL_STATE_WARNING = 1;
3305
3306 /**
3307 * Thermal state where the device has reached its maximum threshold. This state is sent in the
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08003308 * {@link #ACTION_THERMAL_EVENT} broadcast as {@link #EXTRA_THERMAL_STATE}.
Bryce Leebc58f592015-09-25 16:43:01 -07003309 * {@hide}
3310 */
3311 public static final int EXTRA_THERMAL_STATE_EXCEEDED = 2;
3312
3313
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003314 // ---------------------------------------------------------------------
3315 // ---------------------------------------------------------------------
3316 // Standard intent categories (see addCategory()).
3317
3318 /**
3319 * Set if the activity should be an option for the default action
3320 * (center press) to perform on a piece of data. Setting this will
3321 * hide from the user any activities without it set when performing an
John Spurlock6098c5d2013-06-17 10:32:46 -04003322 * action on some data. Note that this is normally -not- set in the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003323 * Intent when initiating an action -- it is for use in intent filters
3324 * specified in packages.
3325 */
3326 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3327 public static final String CATEGORY_DEFAULT = "android.intent.category.DEFAULT";
3328 /**
3329 * Activities that can be safely invoked from a browser must support this
3330 * category. For example, if the user is viewing a web page or an e-mail
3331 * and clicks on a link in the text, the Intent generated execute that
3332 * link will require the BROWSABLE category, so that only activities
3333 * supporting this category will be considered as possible actions. By
3334 * supporting this category, you are promising that there is nothing
3335 * damaging (without user intervention) that can happen by invoking any
3336 * matching Intent.
3337 */
3338 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3339 public static final String CATEGORY_BROWSABLE = "android.intent.category.BROWSABLE";
3340 /**
Dianne Hackborn91097de2014-04-04 18:02:06 -07003341 * Categories for activities that can participate in voice interaction.
3342 * An activity that supports this category must be prepared to run with
3343 * no UI shown at all (though in some case it may have a UI shown), and
3344 * rely on {@link android.app.VoiceInteractor} to interact with the user.
3345 */
3346 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3347 public static final String CATEGORY_VOICE = "android.intent.category.VOICE";
3348 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003349 * Set if the activity should be considered as an alternative action to
3350 * the data the user is currently viewing. See also
3351 * {@link #CATEGORY_SELECTED_ALTERNATIVE} for an alternative action that
3352 * applies to the selection in a list of items.
3353 *
3354 * <p>Supporting this category means that you would like your activity to be
3355 * displayed in the set of alternative things the user can do, usually as
3356 * part of the current activity's options menu. You will usually want to
3357 * include a specific label in the &lt;intent-filter&gt; of this action
3358 * describing to the user what it does.
3359 *
3360 * <p>The action of IntentFilter with this category is important in that it
3361 * describes the specific action the target will perform. This generally
3362 * should not be a generic action (such as {@link #ACTION_VIEW}, but rather
3363 * a specific name such as "com.android.camera.action.CROP. Only one
3364 * alternative of any particular action will be shown to the user, so using
3365 * a specific action like this makes sure that your alternative will be
3366 * displayed while also allowing other applications to provide their own
3367 * overrides of that particular action.
3368 */
3369 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3370 public static final String CATEGORY_ALTERNATIVE = "android.intent.category.ALTERNATIVE";
3371 /**
3372 * Set if the activity should be considered as an alternative selection
3373 * action to the data the user has currently selected. This is like
3374 * {@link #CATEGORY_ALTERNATIVE}, but is used in activities showing a list
3375 * of items from which the user can select, giving them alternatives to the
3376 * default action that will be performed on it.
3377 */
3378 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3379 public static final String CATEGORY_SELECTED_ALTERNATIVE = "android.intent.category.SELECTED_ALTERNATIVE";
3380 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09003381 * Intended to be used as a tab inside of a containing TabActivity.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003382 */
3383 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3384 public static final String CATEGORY_TAB = "android.intent.category.TAB";
3385 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003386 * Should be displayed in the top-level launcher.
3387 */
3388 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3389 public static final String CATEGORY_LAUNCHER = "android.intent.category.LAUNCHER";
3390 /**
Jose Lima38b75b62014-03-11 10:41:39 -07003391 * Indicates an activity optimized for Leanback mode, and that should
3392 * be displayed in the Leanback launcher.
3393 */
3394 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3395 public static final String CATEGORY_LEANBACK_LAUNCHER = "android.intent.category.LEANBACK_LAUNCHER";
3396 /**
Jose Lima73915cf2014-07-29 17:16:31 -07003397 * Indicates a Leanback settings activity to be displayed in the Leanback launcher.
3398 * @hide
3399 */
3400 @SystemApi
3401 public static final String CATEGORY_LEANBACK_SETTINGS = "android.intent.category.LEANBACK_SETTINGS";
3402 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003403 * Provides information about the package it is in; typically used if
3404 * a package does not contain a {@link #CATEGORY_LAUNCHER} to provide
3405 * a front-door to the user without having to be shown in the all apps list.
3406 */
3407 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3408 public static final String CATEGORY_INFO = "android.intent.category.INFO";
3409 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003410 * This is the home activity, that is the first activity that is displayed
3411 * when the device boots.
3412 */
3413 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3414 public static final String CATEGORY_HOME = "android.intent.category.HOME";
3415 /**
Anthony Hugh979b81a2015-09-29 16:50:35 -07003416 * This is the home activity that is displayed when the device is finished setting up and ready
3417 * for use.
3418 * @hide
3419 */
3420 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3421 public static final String CATEGORY_HOME_MAIN = "android.intent.category.HOME_MAIN";
3422 /**
Svet Ganov50a8bf42015-07-15 11:04:18 -07003423 * This is the setup wizard activity, that is the first activity that is displayed
3424 * when the user sets up the device for the first time.
3425 * @hide
3426 */
3427 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3428 public static final String CATEGORY_SETUP_WIZARD = "android.intent.category.SETUP_WIZARD";
3429 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003430 * This activity is a preference panel.
3431 */
3432 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3433 public static final String CATEGORY_PREFERENCE = "android.intent.category.PREFERENCE";
3434 /**
3435 * This activity is a development preference panel.
3436 */
3437 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3438 public static final String CATEGORY_DEVELOPMENT_PREFERENCE = "android.intent.category.DEVELOPMENT_PREFERENCE";
3439 /**
3440 * Capable of running inside a parent activity container.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003441 */
3442 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3443 public static final String CATEGORY_EMBED = "android.intent.category.EMBED";
3444 /**
Patrick Dubroy6dabe242010-08-30 10:43:47 -07003445 * This activity allows the user to browse and download new applications.
3446 */
3447 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3448 public static final String CATEGORY_APP_MARKET = "android.intent.category.APP_MARKET";
3449 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003450 * This activity may be exercised by the monkey or other automated test tools.
3451 */
3452 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3453 public static final String CATEGORY_MONKEY = "android.intent.category.MONKEY";
3454 /**
3455 * To be used as a test (not part of the normal user experience).
3456 */
3457 public static final String CATEGORY_TEST = "android.intent.category.TEST";
3458 /**
3459 * To be used as a unit test (run through the Test Harness).
3460 */
3461 public static final String CATEGORY_UNIT_TEST = "android.intent.category.UNIT_TEST";
3462 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09003463 * To be used as a sample code example (not part of the normal user
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003464 * experience).
3465 */
3466 public static final String CATEGORY_SAMPLE_CODE = "android.intent.category.SAMPLE_CODE";
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003467
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003468 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003469 * Used to indicate that an intent only wants URIs that can be opened with
3470 * {@link ContentResolver#openFileDescriptor(Uri, String)}. Openable URIs
3471 * must support at least the columns defined in {@link OpenableColumns} when
3472 * queried.
3473 *
3474 * @see #ACTION_GET_CONTENT
3475 * @see #ACTION_OPEN_DOCUMENT
3476 * @see #ACTION_CREATE_DOCUMENT
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003477 */
3478 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3479 public static final String CATEGORY_OPENABLE = "android.intent.category.OPENABLE";
3480
3481 /**
3482 * To be used as code under test for framework instrumentation tests.
3483 */
3484 public static final String CATEGORY_FRAMEWORK_INSTRUMENTATION_TEST =
3485 "android.intent.category.FRAMEWORK_INSTRUMENTATION_TEST";
Mike Lockwood9092ab42009-09-16 13:01:32 -04003486 /**
3487 * An activity to run when device is inserted into a car dock.
Dianne Hackborn7299c412010-03-04 18:41:49 -08003488 * Used with {@link #ACTION_MAIN} to launch an activity. For more
3489 * information, see {@link android.app.UiModeManager}.
Mike Lockwood9092ab42009-09-16 13:01:32 -04003490 */
3491 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3492 public static final String CATEGORY_CAR_DOCK = "android.intent.category.CAR_DOCK";
3493 /**
3494 * An activity to run when device is inserted into a car dock.
Dianne Hackborn7299c412010-03-04 18:41:49 -08003495 * Used with {@link #ACTION_MAIN} to launch an activity. For more
3496 * information, see {@link android.app.UiModeManager}.
Mike Lockwood9092ab42009-09-16 13:01:32 -04003497 */
3498 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3499 public static final String CATEGORY_DESK_DOCK = "android.intent.category.DESK_DOCK";
Praveen Bharathi21e941b2010-10-06 15:23:14 -05003500 /**
3501 * An activity to run when device is inserted into a analog (low end) dock.
3502 * Used with {@link #ACTION_MAIN} to launch an activity. For more
3503 * information, see {@link android.app.UiModeManager}.
3504 */
3505 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3506 public static final String CATEGORY_LE_DESK_DOCK = "android.intent.category.LE_DESK_DOCK";
3507
3508 /**
3509 * An activity to run when device is inserted into a digital (high end) dock.
3510 * Used with {@link #ACTION_MAIN} to launch an activity. For more
3511 * information, see {@link android.app.UiModeManager}.
3512 */
3513 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3514 public static final String CATEGORY_HE_DESK_DOCK = "android.intent.category.HE_DESK_DOCK";
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05003515
Bernd Holzheyaea4b672010-03-31 09:46:13 +02003516 /**
3517 * Used to indicate that the activity can be used in a car environment.
3518 */
3519 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3520 public static final String CATEGORY_CAR_MODE = "android.intent.category.CAR_MODE";
3521
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003522 // ---------------------------------------------------------------------
3523 // ---------------------------------------------------------------------
Jeff Brown6651a632011-11-28 12:59:11 -08003524 // Application launch intent categories (see addCategory()).
3525
3526 /**
3527 * Used with {@link #ACTION_MAIN} to launch the browser application.
3528 * The activity should be able to browse the Internet.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003529 * <p>NOTE: This should not be used as the primary key of an Intent,
3530 * since it will not result in the app launching with the correct
3531 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003532 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003533 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003534 */
3535 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3536 public static final String CATEGORY_APP_BROWSER = "android.intent.category.APP_BROWSER";
3537
3538 /**
3539 * Used with {@link #ACTION_MAIN} to launch the calculator application.
3540 * The activity should be able to perform standard arithmetic operations.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003541 * <p>NOTE: This should not be used as the primary key of an Intent,
3542 * since it will not result in the app launching with the correct
3543 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003544 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003545 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003546 */
3547 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3548 public static final String CATEGORY_APP_CALCULATOR = "android.intent.category.APP_CALCULATOR";
3549
3550 /**
3551 * Used with {@link #ACTION_MAIN} to launch the calendar application.
3552 * The activity should be able to view and manipulate calendar entries.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003553 * <p>NOTE: This should not be used as the primary key of an Intent,
3554 * since it will not result in the app launching with the correct
3555 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003556 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003557 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003558 */
3559 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3560 public static final String CATEGORY_APP_CALENDAR = "android.intent.category.APP_CALENDAR";
3561
3562 /**
3563 * Used with {@link #ACTION_MAIN} to launch the contacts application.
3564 * The activity should be able to view and manipulate address book entries.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003565 * <p>NOTE: This should not be used as the primary key of an Intent,
3566 * since it will not result in the app launching with the correct
3567 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003568 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003569 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003570 */
3571 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3572 public static final String CATEGORY_APP_CONTACTS = "android.intent.category.APP_CONTACTS";
3573
3574 /**
3575 * Used with {@link #ACTION_MAIN} to launch the email application.
3576 * The activity should be able to send and receive email.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003577 * <p>NOTE: This should not be used as the primary key of an Intent,
3578 * since it will not result in the app launching with the correct
3579 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003580 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003581 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003582 */
3583 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3584 public static final String CATEGORY_APP_EMAIL = "android.intent.category.APP_EMAIL";
3585
3586 /**
3587 * Used with {@link #ACTION_MAIN} to launch the gallery application.
3588 * The activity should be able to view and manipulate image and video files
3589 * stored on the device.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003590 * <p>NOTE: This should not be used as the primary key of an Intent,
3591 * since it will not result in the app launching with the correct
3592 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003593 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003594 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003595 */
3596 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3597 public static final String CATEGORY_APP_GALLERY = "android.intent.category.APP_GALLERY";
3598
3599 /**
3600 * Used with {@link #ACTION_MAIN} to launch the maps application.
3601 * The activity should be able to show the user's current location and surroundings.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003602 * <p>NOTE: This should not be used as the primary key of an Intent,
3603 * since it will not result in the app launching with the correct
3604 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003605 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003606 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003607 */
3608 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3609 public static final String CATEGORY_APP_MAPS = "android.intent.category.APP_MAPS";
3610
3611 /**
3612 * Used with {@link #ACTION_MAIN} to launch the messaging application.
3613 * The activity should be able to send and receive text messages.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003614 * <p>NOTE: This should not be used as the primary key of an Intent,
3615 * since it will not result in the app launching with the correct
3616 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003617 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003618 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003619 */
3620 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3621 public static final String CATEGORY_APP_MESSAGING = "android.intent.category.APP_MESSAGING";
3622
3623 /**
3624 * Used with {@link #ACTION_MAIN} to launch the music application.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003625 * The activity should be able to play, browse, or manipulate music files
3626 * stored on the device.
3627 * <p>NOTE: This should not be used as the primary key of an Intent,
3628 * since it will not result in the app launching with the correct
3629 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003630 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003631 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003632 */
3633 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3634 public static final String CATEGORY_APP_MUSIC = "android.intent.category.APP_MUSIC";
3635
3636 // ---------------------------------------------------------------------
3637 // ---------------------------------------------------------------------
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003638 // Standard extra data keys.
3639
3640 /**
3641 * The initial data to place in a newly created record. Use with
3642 * {@link #ACTION_INSERT}. The data here is a Map containing the same
3643 * fields as would be given to the underlying ContentProvider.insert()
3644 * call.
3645 */
3646 public static final String EXTRA_TEMPLATE = "android.intent.extra.TEMPLATE";
3647
3648 /**
3649 * A constant CharSequence that is associated with the Intent, used with
3650 * {@link #ACTION_SEND} to supply the literal data to be sent. Note that
3651 * this may be a styled CharSequence, so you must use
3652 * {@link Bundle#getCharSequence(String) Bundle.getCharSequence()} to
3653 * retrieve it.
3654 */
3655 public static final String EXTRA_TEXT = "android.intent.extra.TEXT";
3656
3657 /**
Dianne Hackbornacb69bb2012-04-13 15:36:06 -07003658 * A constant String that is associated with the Intent, used with
3659 * {@link #ACTION_SEND} to supply an alternative to {@link #EXTRA_TEXT}
3660 * as HTML formatted text. Note that you <em>must</em> also supply
3661 * {@link #EXTRA_TEXT}.
3662 */
3663 public static final String EXTRA_HTML_TEXT = "android.intent.extra.HTML_TEXT";
3664
3665 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003666 * A content: URI holding a stream of data associated with the Intent,
3667 * used with {@link #ACTION_SEND} to supply the data being sent.
3668 */
3669 public static final String EXTRA_STREAM = "android.intent.extra.STREAM";
3670
3671 /**
3672 * A String[] holding e-mail addresses that should be delivered to.
3673 */
3674 public static final String EXTRA_EMAIL = "android.intent.extra.EMAIL";
3675
3676 /**
3677 * A String[] holding e-mail addresses that should be carbon copied.
3678 */
3679 public static final String EXTRA_CC = "android.intent.extra.CC";
3680
3681 /**
3682 * A String[] holding e-mail addresses that should be blind carbon copied.
3683 */
3684 public static final String EXTRA_BCC = "android.intent.extra.BCC";
3685
3686 /**
3687 * A constant string holding the desired subject line of a message.
3688 */
3689 public static final String EXTRA_SUBJECT = "android.intent.extra.SUBJECT";
3690
3691 /**
3692 * An Intent describing the choices you would like shown with
Adam Powell2ed547e2015-04-29 18:45:04 -07003693 * {@link #ACTION_PICK_ACTIVITY} or {@link #ACTION_CHOOSER}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003694 */
3695 public static final String EXTRA_INTENT = "android.intent.extra.INTENT";
3696
3697 /**
Clara Bayarrif7fea162015-10-22 16:09:52 +01003698 * An int representing the user id to be used.
3699 *
3700 * @hide
3701 */
3702 public static final String EXTRA_USER_ID = "android.intent.extra.USER_ID";
3703
3704 /**
Clara Bayarriea9b10e2015-12-04 15:36:26 +00003705 * An int representing the task id to be retrieved. This is used when a launch from recents is
3706 * intercepted by another action such as credentials confirmation to remember which task should
3707 * be resumed when complete.
3708 *
3709 * @hide
3710 */
3711 public static final String EXTRA_TASK_ID = "android.intent.extra.TASK_ID";
3712
3713 /**
Adam Powell2ed547e2015-04-29 18:45:04 -07003714 * An Intent[] describing additional, alternate choices you would like shown with
3715 * {@link #ACTION_CHOOSER}.
3716 *
3717 * <p>An app may be capable of providing several different payload types to complete a
3718 * user's intended action. For example, an app invoking {@link #ACTION_SEND} to share photos
3719 * with another app may use EXTRA_ALTERNATE_INTENTS to have the chooser transparently offer
3720 * several different supported sending mechanisms for sharing, such as the actual "image/*"
3721 * photo data or a hosted link where the photos can be viewed.</p>
3722 *
3723 * <p>The intent present in {@link #EXTRA_INTENT} will be treated as the
3724 * first/primary/preferred intent in the set. Additional intents specified in
3725 * this extra are ordered; by default intents that appear earlier in the array will be
3726 * preferred over intents that appear later in the array as matches for the same
3727 * target component. To alter this preference, a calling app may also supply
3728 * {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER}.</p>
3729 */
3730 public static final String EXTRA_ALTERNATE_INTENTS = "android.intent.extra.ALTERNATE_INTENTS";
3731
3732 /**
3733 * An {@link IntentSender} for an Activity that will be invoked when the user makes a selection
3734 * from the chooser activity presented by {@link #ACTION_CHOOSER}.
3735 *
3736 * <p>An app preparing an action for another app to complete may wish to allow the user to
3737 * disambiguate between several options for completing the action based on the chosen target
3738 * or otherwise refine the action before it is invoked.
3739 * </p>
3740 *
3741 * <p>When sent, this IntentSender may be filled in with the following extras:</p>
3742 * <ul>
3743 * <li>{@link #EXTRA_INTENT} The first intent that matched the user's chosen target</li>
3744 * <li>{@link #EXTRA_ALTERNATE_INTENTS} Any additional intents that also matched the user's
3745 * chosen target beyond the first</li>
3746 * <li>{@link #EXTRA_RESULT_RECEIVER} A {@link ResultReceiver} that the refinement activity
3747 * should fill in and send once the disambiguation is complete</li>
3748 * </ul>
3749 */
3750 public static final String EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER
3751 = "android.intent.extra.CHOOSER_REFINEMENT_INTENT_SENDER";
3752
3753 /**
3754 * A {@link ResultReceiver} used to return data back to the sender.
3755 *
3756 * <p>Used to complete an app-specific
3757 * {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER refinement} for {@link #ACTION_CHOOSER}.</p>
3758 *
3759 * <p>If {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER} is present in the intent
3760 * used to start a {@link #ACTION_CHOOSER} activity this extra will be
3761 * {@link #fillIn(Intent, int) filled in} to that {@link IntentSender} and sent
3762 * when the user selects a target component from the chooser. It is up to the recipient
3763 * to send a result to this ResultReceiver to signal that disambiguation is complete
3764 * and that the chooser should invoke the user's choice.</p>
3765 *
3766 * <p>The disambiguator should provide a Bundle to the ResultReceiver with an intent
3767 * assigned to the key {@link #EXTRA_INTENT}. This supplied intent will be used by the chooser
3768 * to match and fill in the final Intent or ChooserTarget before starting it.
3769 * The supplied intent must {@link #filterEquals(Intent) match} one of the intents from
3770 * {@link #EXTRA_INTENT} or {@link #EXTRA_ALTERNATE_INTENTS} passed to
3771 * {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER} to be accepted.</p>
3772 *
3773 * <p>The result code passed to the ResultReceiver should be
3774 * {@link android.app.Activity#RESULT_OK} if the refinement succeeded and the supplied intent's
3775 * target in the chooser should be started, or {@link android.app.Activity#RESULT_CANCELED} if
3776 * the chooser should finish without starting a target.</p>
3777 */
3778 public static final String EXTRA_RESULT_RECEIVER
3779 = "android.intent.extra.RESULT_RECEIVER";
3780
3781 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003782 * A CharSequence dialog title to provide to the user when used with a
Jim Miller4d64746d2014-08-13 21:08:41 +00003783 * {@link #ACTION_CHOOSER}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003784 */
3785 public static final String EXTRA_TITLE = "android.intent.extra.TITLE";
3786
3787 /**
Dianne Hackborneb034652009-09-07 00:49:58 -07003788 * A Parcelable[] of {@link Intent} or
3789 * {@link android.content.pm.LabeledIntent} objects as set with
3790 * {@link #putExtra(String, Parcelable[])} of additional activities to place
3791 * a the front of the list of choices, when shown to the user with a
3792 * {@link #ACTION_CHOOSER}.
3793 */
3794 public static final String EXTRA_INITIAL_INTENTS = "android.intent.extra.INITIAL_INTENTS";
3795
3796 /**
Todd Kennedy7440f172015-12-09 14:31:22 -08003797 * A {@link IntentSender} to start after ephemeral installation success.
3798 * @hide
3799 */
3800 @SystemApi
3801 public static final String EXTRA_EPHEMERAL_SUCCESS = "android.intent.extra.EPHEMERAL_SUCCESS";
3802
3803 /**
3804 * A {@link IntentSender} to start after ephemeral installation failure.
3805 * @hide
3806 */
3807 @SystemApi
3808 public static final String EXTRA_EPHEMERAL_FAILURE = "android.intent.extra.EPHEMERAL_FAILURE";
3809
3810 /**
Adam Powelle49d9392014-07-17 18:45:19 -07003811 * A Bundle forming a mapping of potential target package names to different extras Bundles
3812 * to add to the default intent extras in {@link #EXTRA_INTENT} when used with
3813 * {@link #ACTION_CHOOSER}. Each key should be a package name. The package need not
3814 * be currently installed on the device.
3815 *
3816 * <p>An application may choose to provide alternate extras for the case where a user
3817 * selects an activity from a predetermined set of target packages. If the activity
3818 * the user selects from the chooser belongs to a package with its package name as
3819 * a key in this bundle, the corresponding extras for that package will be merged with
3820 * the extras already present in the intent at {@link #EXTRA_INTENT}. If a replacement
3821 * extra has the same key as an extra already present in the intent it will overwrite
3822 * the extra from the intent.</p>
3823 *
3824 * <p><em>Examples:</em>
3825 * <ul>
3826 * <li>An application may offer different {@link #EXTRA_TEXT} to an application
3827 * when sharing with it via {@link #ACTION_SEND}, augmenting a link with additional query
3828 * parameters for that target.</li>
3829 * <li>An application may offer additional metadata for known targets of a given intent
3830 * to pass along information only relevant to that target such as account or content
3831 * identifiers already known to that application.</li>
3832 * </ul></p>
3833 */
3834 public static final String EXTRA_REPLACEMENT_EXTRAS =
3835 "android.intent.extra.REPLACEMENT_EXTRAS";
3836
3837 /**
Adam Powell0b3c1122014-10-09 12:50:14 -07003838 * An {@link IntentSender} that will be notified if a user successfully chooses a target
3839 * component to handle an action in an {@link #ACTION_CHOOSER} activity. The IntentSender
3840 * will have the extra {@link #EXTRA_CHOSEN_COMPONENT} appended to it containing the
3841 * {@link ComponentName} of the chosen component.
3842 *
3843 * <p>In some situations this callback may never come, for example if the user abandons
3844 * the chooser, switches to another task or any number of other reasons. Apps should not
3845 * be written assuming that this callback will always occur.</p>
3846 */
3847 public static final String EXTRA_CHOSEN_COMPONENT_INTENT_SENDER =
3848 "android.intent.extra.CHOSEN_COMPONENT_INTENT_SENDER";
3849
3850 /**
3851 * The {@link ComponentName} chosen by the user to complete an action.
3852 *
3853 * @see #EXTRA_CHOSEN_COMPONENT_INTENT_SENDER
3854 */
3855 public static final String EXTRA_CHOSEN_COMPONENT = "android.intent.extra.CHOSEN_COMPONENT";
3856
3857 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003858 * A {@link android.view.KeyEvent} object containing the event that
3859 * triggered the creation of the Intent it is in.
3860 */
3861 public static final String EXTRA_KEY_EVENT = "android.intent.extra.KEY_EVENT";
3862
3863 /**
Mike Lockwoodbad80e02009-07-30 01:21:08 -07003864 * Set to true in {@link #ACTION_REQUEST_SHUTDOWN} to request confirmation from the user
3865 * before shutting down.
3866 *
3867 * {@hide}
3868 */
3869 public static final String EXTRA_KEY_CONFIRM = "android.intent.extra.KEY_CONFIRM";
3870
3871 /**
Yusuke Sato705ffd12015-07-21 15:52:11 -07003872 * Set to true in {@link #ACTION_REQUEST_SHUTDOWN} to indicate that the shutdown is
3873 * requested by the user.
3874 *
3875 * {@hide}
3876 */
3877 public static final String EXTRA_USER_REQUESTED_SHUTDOWN =
3878 "android.intent.extra.USER_REQUESTED_SHUTDOWN";
3879
3880 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09003881 * 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 -07003882 * {@link android.content.Intent#ACTION_PACKAGE_CHANGED} intents to override the default action
3883 * of restarting the application.
3884 */
3885 public static final String EXTRA_DONT_KILL_APP = "android.intent.extra.DONT_KILL_APP";
3886
3887 /**
3888 * A String holding the phone number originally entered in
3889 * {@link android.content.Intent#ACTION_NEW_OUTGOING_CALL}, or the actual
3890 * number to call in a {@link android.content.Intent#ACTION_CALL}.
3891 */
3892 public static final String EXTRA_PHONE_NUMBER = "android.intent.extra.PHONE_NUMBER";
Bernd Holzheyaea4b672010-03-31 09:46:13 +02003893
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003894 /**
3895 * Used as an int extra field in {@link android.content.Intent#ACTION_UID_REMOVED}
3896 * intents to supply the uid the package had been assigned. Also an optional
3897 * extra in {@link android.content.Intent#ACTION_PACKAGE_REMOVED} or
3898 * {@link android.content.Intent#ACTION_PACKAGE_CHANGED} for the same
3899 * purpose.
3900 */
3901 public static final String EXTRA_UID = "android.intent.extra.UID";
3902
3903 /**
Dianne Hackborn21f1bd12010-02-19 17:02:21 -08003904 * @hide String array of package names.
3905 */
Soonil Nagarkar0e8fd092015-02-10 10:37:36 -08003906 @SystemApi
Dianne Hackborn21f1bd12010-02-19 17:02:21 -08003907 public static final String EXTRA_PACKAGES = "android.intent.extra.PACKAGES";
3908
3909 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003910 * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED}
3911 * intents to indicate whether this represents a full uninstall (removing
3912 * both the code and its data) or a partial uninstall (leaving its data,
3913 * implying that this is an update).
3914 */
3915 public static final String EXTRA_DATA_REMOVED = "android.intent.extra.DATA_REMOVED";
The Android Open Source Project10592532009-03-18 17:39:46 -07003916
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003917 /**
Dianne Hackbornc72fc672012-09-20 13:12:03 -07003918 * @hide
3919 * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED}
3920 * intents to indicate that at this point the package has been removed for
3921 * all users on the device.
3922 */
3923 public static final String EXTRA_REMOVED_FOR_ALL_USERS
3924 = "android.intent.extra.REMOVED_FOR_ALL_USERS";
3925
3926 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003927 * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED}
3928 * intents to indicate that this is a replacement of the package, so this
3929 * broadcast will immediately be followed by an add broadcast for a
3930 * different version of the same package.
3931 */
3932 public static final String EXTRA_REPLACING = "android.intent.extra.REPLACING";
The Android Open Source Project10592532009-03-18 17:39:46 -07003933
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003934 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003935 * Used as an int extra field in {@link android.app.AlarmManager} intents
3936 * to tell the application being invoked how many pending alarms are being
3937 * delievered with the intent. For one-shot alarms this will always be 1.
3938 * For recurring alarms, this might be greater than 1 if the device was
3939 * asleep or powered off at the time an earlier alarm would have been
3940 * delivered.
3941 */
3942 public static final String EXTRA_ALARM_COUNT = "android.intent.extra.ALARM_COUNT";
Romain Guy4969af72009-06-17 10:53:19 -07003943
Jacek Surazski86b6c532009-05-13 14:38:28 +02003944 /**
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05003945 * Used as an int extra field in {@link android.content.Intent#ACTION_DOCK_EVENT}
3946 * intents to request the dock state. Possible values are
Mike Lockwood725fcbf2009-08-24 13:09:20 -07003947 * {@link android.content.Intent#EXTRA_DOCK_STATE_UNDOCKED},
3948 * {@link android.content.Intent#EXTRA_DOCK_STATE_DESK}, or
Praveen Bharathi21e941b2010-10-06 15:23:14 -05003949 * {@link android.content.Intent#EXTRA_DOCK_STATE_CAR}, or
3950 * {@link android.content.Intent#EXTRA_DOCK_STATE_LE_DESK}, or
3951 * {@link android.content.Intent#EXTRA_DOCK_STATE_HE_DESK}.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05003952 */
3953 public static final String EXTRA_DOCK_STATE = "android.intent.extra.DOCK_STATE";
3954
3955 /**
3956 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
3957 * to represent that the phone is not in any dock.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05003958 */
3959 public static final int EXTRA_DOCK_STATE_UNDOCKED = 0;
3960
3961 /**
3962 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
3963 * to represent that the phone is in a desk dock.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05003964 */
3965 public static final int EXTRA_DOCK_STATE_DESK = 1;
3966
3967 /**
3968 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
3969 * to represent that the phone is in a car dock.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05003970 */
3971 public static final int EXTRA_DOCK_STATE_CAR = 2;
3972
3973 /**
Praveen Bharathi21e941b2010-10-06 15:23:14 -05003974 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
3975 * to represent that the phone is in a analog (low end) dock.
3976 */
3977 public static final int EXTRA_DOCK_STATE_LE_DESK = 3;
3978
3979 /**
3980 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
3981 * to represent that the phone is in a digital (high end) dock.
3982 */
3983 public static final int EXTRA_DOCK_STATE_HE_DESK = 4;
3984
3985 /**
Dianne Hackborn9bfb7072009-09-22 11:37:40 -07003986 * Boolean that can be supplied as meta-data with a dock activity, to
3987 * indicate that the dock should take over the home key when it is active.
3988 */
3989 public static final String METADATA_DOCK_HOME = "android.dock_home";
Tom Taylord4a47292009-12-21 13:59:18 -08003990
Dianne Hackborn9bfb7072009-09-22 11:37:40 -07003991 /**
Jacek Surazski86b6c532009-05-13 14:38:28 +02003992 * Used as a parcelable extra field in {@link #ACTION_APP_ERROR}, containing
3993 * the bug report.
Jacek Surazski86b6c532009-05-13 14:38:28 +02003994 */
3995 public static final String EXTRA_BUG_REPORT = "android.intent.extra.BUG_REPORT";
3996
3997 /**
Wei Huang97ecc9c2009-05-11 17:44:20 -07003998 * Used in the extra field in the remote intent. It's astring token passed with the
3999 * remote intent.
4000 */
4001 public static final String EXTRA_REMOTE_INTENT_TOKEN =
4002 "android.intent.extra.remote_intent_token";
4003
Suchi Amalapurapu0214e942009-09-02 11:03:18 -07004004 /**
Dianne Hackborn1d62ea92009-11-17 12:49:50 -08004005 * @deprecated See {@link #EXTRA_CHANGED_COMPONENT_NAME_LIST}; this field
Dianne Hackborn86a72da2009-11-11 20:12:41 -08004006 * will contain only the first name in the list.
Suchi Amalapurapu0214e942009-09-02 11:03:18 -07004007 */
Dianne Hackborn1d62ea92009-11-17 12:49:50 -08004008 @Deprecated public static final String EXTRA_CHANGED_COMPONENT_NAME =
Suchi Amalapurapu0214e942009-09-02 11:03:18 -07004009 "android.intent.extra.changed_component_name";
4010
Dianne Hackborndd9b82c2009-09-03 00:18:47 -07004011 /**
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08004012 * This field is part of {@link android.content.Intent#ACTION_PACKAGE_CHANGED},
Dianne Hackbornfd7aded2013-01-22 17:10:23 -08004013 * and contains a string array of all of the components that have changed. If
4014 * the state of the overall package has changed, then it will contain an entry
4015 * with the package name itself.
Dianne Hackborn86a72da2009-11-11 20:12:41 -08004016 */
4017 public static final String EXTRA_CHANGED_COMPONENT_NAME_LIST =
4018 "android.intent.extra.changed_component_name_list";
4019
4020 /**
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08004021 * This field is part of
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08004022 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_AVAILABLE},
Andrei Stingaceanu69d5ebc2016-01-14 12:59:03 +00004023 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE},
4024 * {@link android.content.Intent#ACTION_PACKAGES_SUSPENDED},
4025 * {@link android.content.Intent#ACTION_PACKAGES_UNSUSPENDED}
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08004026 * and contains a string array of all of the components that have changed.
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08004027 */
4028 public static final String EXTRA_CHANGED_PACKAGE_LIST =
4029 "android.intent.extra.changed_package_list";
4030
4031 /**
4032 * This field is part of
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08004033 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_AVAILABLE},
4034 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE}
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08004035 * and contains an integer array of uids of all of the components
4036 * that have changed.
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08004037 */
4038 public static final String EXTRA_CHANGED_UID_LIST =
4039 "android.intent.extra.changed_uid_list";
4040
4041 /**
Dianne Hackborndd9b82c2009-09-03 00:18:47 -07004042 * @hide
4043 * Magic extra system code can use when binding, to give a label for
4044 * who it is that has bound to a service. This is an integer giving
4045 * a framework string resource that can be displayed to the user.
4046 */
4047 public static final String EXTRA_CLIENT_LABEL =
4048 "android.intent.extra.client_label";
4049
4050 /**
4051 * @hide
4052 * Magic extra system code can use when binding, to give a PendingIntent object
4053 * that can be launched for the user to disable the system's use of this
4054 * service.
4055 */
4056 public static final String EXTRA_CLIENT_INTENT =
4057 "android.intent.extra.client_intent";
4058
Dianne Hackbornc4d0e6f2011-01-25 14:55:06 -08004059 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004060 * Extra used to indicate that an intent should only return data that is on
4061 * the local device. This is a boolean extra; the default is false. If true,
4062 * an implementation should only allow the user to select data that is
4063 * already on the device, not requiring it be downloaded from a remote
4064 * service when opened.
4065 *
4066 * @see #ACTION_GET_CONTENT
4067 * @see #ACTION_OPEN_DOCUMENT
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07004068 * @see #ACTION_OPEN_DOCUMENT_TREE
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004069 * @see #ACTION_CREATE_DOCUMENT
Dianne Hackbornc4d0e6f2011-01-25 14:55:06 -08004070 */
4071 public static final String EXTRA_LOCAL_ONLY =
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004072 "android.intent.extra.LOCAL_ONLY";
Daniel Lehmanna5b58df2011-10-12 16:24:22 -07004073
Amith Yamasani13593602012-03-22 16:16:17 -07004074 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004075 * Extra used to indicate that an intent can allow the user to select and
4076 * return multiple items. This is a boolean extra; the default is false. If
4077 * true, an implementation is allowed to present the user with a UI where
4078 * they can pick multiple items that are all returned to the caller. When
4079 * this happens, they should be returned as the {@link #getClipData()} part
4080 * of the result Intent.
4081 *
4082 * @see #ACTION_GET_CONTENT
4083 * @see #ACTION_OPEN_DOCUMENT
Dianne Hackbornfdb3f092013-01-28 15:10:48 -08004084 */
4085 public static final String EXTRA_ALLOW_MULTIPLE =
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004086 "android.intent.extra.ALLOW_MULTIPLE";
Dianne Hackbornfdb3f092013-01-28 15:10:48 -08004087
4088 /**
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01004089 * The integer userHandle carried with broadcast intents related to addition, removal and
4090 * switching of users and managed profiles - {@link #ACTION_USER_ADDED},
4091 * {@link #ACTION_USER_REMOVED} and {@link #ACTION_USER_SWITCHED}.
4092 *
Amith Yamasani13593602012-03-22 16:16:17 -07004093 * @hide
4094 */
Amith Yamasani2a003292012-08-14 18:25:45 -07004095 public static final String EXTRA_USER_HANDLE =
4096 "android.intent.extra.user_handle";
Jean-Michel Trivi3114ce32012-06-11 15:03:52 -07004097
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08004098 /**
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01004099 * The UserHandle carried with broadcasts intents related to addition and removal of managed
4100 * profiles - {@link #ACTION_MANAGED_PROFILE_ADDED} and {@link #ACTION_MANAGED_PROFILE_REMOVED}.
4101 */
4102 public static final String EXTRA_USER =
Alexandra Gherghina3315f6b2014-09-05 15:48:06 +01004103 "android.intent.extra.USER";
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01004104
4105 /**
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08004106 * Extra used in the response from a BroadcastReceiver that handles
Amith Yamasani7e99bc02013-04-16 18:24:51 -07004107 * {@link #ACTION_GET_RESTRICTION_ENTRIES}. The type of the extra is
4108 * <code>ArrayList&lt;RestrictionEntry&gt;</code>.
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08004109 */
Amith Yamasani7e99bc02013-04-16 18:24:51 -07004110 public static final String EXTRA_RESTRICTIONS_LIST = "android.intent.extra.restrictions_list";
4111
4112 /**
4113 * Extra sent in the intent to the BroadcastReceiver that handles
4114 * {@link #ACTION_GET_RESTRICTION_ENTRIES}. The type of the extra is a Bundle containing
4115 * the restrictions as key/value pairs.
4116 */
4117 public static final String EXTRA_RESTRICTIONS_BUNDLE =
4118 "android.intent.extra.restrictions_bundle";
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08004119
Amith Yamasani86118ba2013-03-28 14:33:16 -07004120 /**
4121 * Extra used in the response from a BroadcastReceiver that handles
4122 * {@link #ACTION_GET_RESTRICTION_ENTRIES}.
4123 */
4124 public static final String EXTRA_RESTRICTIONS_INTENT =
4125 "android.intent.extra.restrictions_intent";
4126
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07004127 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004128 * Extra used to communicate a set of acceptable MIME types. The type of the
4129 * extra is {@code String[]}. Values may be a combination of concrete MIME
4130 * types (such as "image/png") and/or partial MIME types (such as
4131 * "audio/*").
4132 *
4133 * @see #ACTION_GET_CONTENT
4134 * @see #ACTION_OPEN_DOCUMENT
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07004135 */
4136 public static final String EXTRA_MIME_TYPES = "android.intent.extra.MIME_TYPES";
4137
Dianne Hackborn57a7f592013-07-22 18:21:32 -07004138 /**
4139 * Optional extra for {@link #ACTION_SHUTDOWN} that allows the sender to qualify that
4140 * this shutdown is only for the user space of the system, not a complete shutdown.
Dianne Hackbornd318e0b2013-09-03 14:34:12 -07004141 * When this is true, hardware devices can use this information to determine that
4142 * they shouldn't do a complete shutdown of their device since this is not a
4143 * complete shutdown down to the kernel, but only user space restarting.
4144 * The default if not supplied is false.
Dianne Hackborn57a7f592013-07-22 18:21:32 -07004145 */
4146 public static final String EXTRA_SHUTDOWN_USERSPACE_ONLY
4147 = "android.intent.extra.SHUTDOWN_USERSPACE_ONLY";
4148
Narayan Kamathccb2a0862013-12-19 14:49:36 +00004149 /**
4150 * Optional boolean extra for {@link #ACTION_TIME_CHANGED} that indicates the
4151 * user has set their time format preferences to the 24 hour format.
4152 *
4153 * @hide for internal use only.
4154 */
4155 public static final String EXTRA_TIME_PREF_24_HOUR_FORMAT =
4156 "android.intent.extra.TIME_PREF_24_HOUR_FORMAT";
4157
Jeff Sharkey004a4b22014-09-24 11:45:24 -07004158 /** {@hide} */
4159 public static final String EXTRA_REASON = "android.intent.extra.REASON";
4160
Rubin Xue8490f12015-06-25 12:17:48 +01004161 /** {@hide} */
4162 public static final String EXTRA_WIPE_EXTERNAL_STORAGE = "android.intent.extra.WIPE_EXTERNAL_STORAGE";
4163
Santos Cordon15a13782015-03-31 18:32:31 -07004164 /**
4165 * Optional {@link android.app.PendingIntent} extra used to deliver the result of the SIM
4166 * activation request.
4167 * TODO: Add information about the structure and response data used with the pending intent.
4168 * @hide
4169 */
4170 public static final String EXTRA_SIM_ACTIVATION_RESPONSE =
4171 "android.intent.extra.SIM_ACTIVATION_RESPONSE";
4172
Tomasz Mikolajewski319fb492016-01-20 12:24:01 +09004173 /**
4174 * Optional index with semantics depending on the intent action.
Tomasz Mikolajewskife023132016-03-10 17:42:35 +09004175 *
4176 * <p>The value must be an integer greater or equal to 0.
Tomasz Mikolajewski319fb492016-01-20 12:24:01 +09004177 */
Steve McKay6eaf38632015-08-04 10:11:01 -07004178 public static final String EXTRA_INDEX = "android.intent.extra.INDEX";
4179
Rubin Xu0a29ecd2015-11-04 15:11:48 +00004180 /**
4181 * Optional boolean extra indicating whether quiet mode has been switched on or off.
Rubin Xue95057a2016-04-01 16:49:25 +01004182 * When a profile goes into quiet mode, all apps in the profile are killed and the
4183 * profile user is stopped. Widgets originating from the profile are masked, and app
4184 * launcher icons are grayed out.
Rubin Xu0a29ecd2015-11-04 15:11:48 +00004185 */
4186 public static final String EXTRA_QUIET_MODE = "android.intent.extra.QUIET_MODE";
Dongwon Kang2034a4c2015-12-14 21:57:34 +09004187
4188 /**
Dongwon Kang32cb9ab2016-01-13 18:11:10 -08004189 * Used as an int extra field in {@link #ACTION_MEDIA_RESOURCE_GRANTED}
Dongwon Kang2034a4c2015-12-14 21:57:34 +09004190 * intents to specify the resource type granted. Possible values are
Dongwon Kang32cb9ab2016-01-13 18:11:10 -08004191 * {@link #EXTRA_MEDIA_RESOURCE_TYPE_VIDEO_CODEC} or
4192 * {@link #EXTRA_MEDIA_RESOURCE_TYPE_AUDIO_CODEC}.
Dongwon Kang2034a4c2015-12-14 21:57:34 +09004193 *
4194 * @hide
4195 */
4196 public static final String EXTRA_MEDIA_RESOURCE_TYPE =
4197 "android.intent.extra.MEDIA_RESOURCE_TYPE";
4198
4199 /**
Dongwon Kang32cb9ab2016-01-13 18:11:10 -08004200 * Used as an int value for {@link #EXTRA_MEDIA_RESOURCE_TYPE}
Dongwon Kang2034a4c2015-12-14 21:57:34 +09004201 * to represent that a video codec is allowed to use.
4202 *
4203 * @hide
4204 */
4205 public static final int EXTRA_MEDIA_RESOURCE_TYPE_VIDEO_CODEC = 0;
4206
4207 /**
Dongwon Kang32cb9ab2016-01-13 18:11:10 -08004208 * Used as an int value for {@link #EXTRA_MEDIA_RESOURCE_TYPE}
Dongwon Kang2034a4c2015-12-14 21:57:34 +09004209 * to represent that a audio codec is allowed to use.
4210 *
4211 * @hide
4212 */
4213 public static final int EXTRA_MEDIA_RESOURCE_TYPE_AUDIO_CODEC = 1;
4214
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004215 // ---------------------------------------------------------------------
4216 // ---------------------------------------------------------------------
4217 // Intent flags (see mFlags variable).
4218
Tor Norbyed9273d62013-05-30 15:59:53 -07004219 /** @hide */
Jeff Sharkey846318a2014-04-04 12:12:41 -07004220 @IntDef(flag = true, value = {
4221 FLAG_GRANT_READ_URI_PERMISSION, FLAG_GRANT_WRITE_URI_PERMISSION,
4222 FLAG_GRANT_PERSISTABLE_URI_PERMISSION, FLAG_GRANT_PREFIX_URI_PERMISSION })
Tor Norbyed9273d62013-05-30 15:59:53 -07004223 @Retention(RetentionPolicy.SOURCE)
4224 public @interface GrantUriMode {}
4225
Jeff Sharkey846318a2014-04-04 12:12:41 -07004226 /** @hide */
4227 @IntDef(flag = true, value = {
4228 FLAG_GRANT_READ_URI_PERMISSION, FLAG_GRANT_WRITE_URI_PERMISSION })
4229 @Retention(RetentionPolicy.SOURCE)
4230 public @interface AccessUriMode {}
4231
4232 /**
4233 * Test if given mode flags specify an access mode, which must be at least
4234 * read and/or write.
4235 *
4236 * @hide
4237 */
4238 public static boolean isAccessUriMode(int modeFlags) {
4239 return (modeFlags & (Intent.FLAG_GRANT_READ_URI_PERMISSION
4240 | Intent.FLAG_GRANT_WRITE_URI_PERMISSION)) != 0;
4241 }
4242
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004243 /**
4244 * If set, the recipient of this Intent will be granted permission to
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004245 * perform read operations on the URI in the Intent's data and any URIs
Dianne Hackborn21c241e2012-03-08 13:57:23 -08004246 * specified in its ClipData. When applying to an Intent's ClipData,
4247 * all URIs as well as recursive traversals through data or other ClipData
4248 * in Intent items will be granted; only the grant flags of the top-level
4249 * Intent are used.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004250 */
4251 public static final int FLAG_GRANT_READ_URI_PERMISSION = 0x00000001;
4252 /**
4253 * If set, the recipient of this Intent will be granted permission to
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004254 * perform write operations on the URI in the Intent's data and any URIs
Dianne Hackborn21c241e2012-03-08 13:57:23 -08004255 * specified in its ClipData. When applying to an Intent's ClipData,
4256 * all URIs as well as recursive traversals through data or other ClipData
4257 * in Intent items will be granted; only the grant flags of the top-level
4258 * Intent are used.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004259 */
4260 public static final int FLAG_GRANT_WRITE_URI_PERMISSION = 0x00000002;
4261 /**
4262 * Can be set by the caller to indicate that this Intent is coming from
4263 * a background operation, not from direct user interaction.
4264 */
4265 public static final int FLAG_FROM_BACKGROUND = 0x00000004;
4266 /**
4267 * A flag you can enable for debugging: when set, log messages will be
4268 * printed during the resolution of this intent to show you what has
4269 * been found to create the final resolved list.
4270 */
4271 public static final int FLAG_DEBUG_LOG_RESOLUTION = 0x00000008;
Dianne Hackborne7f97212011-02-24 14:40:20 -08004272 /**
4273 * If set, this intent will not match any components in packages that
4274 * are currently stopped. If this is not set, then the default behavior
4275 * is to include such applications in the result.
4276 */
4277 public static final int FLAG_EXCLUDE_STOPPED_PACKAGES = 0x00000010;
4278 /**
4279 * If set, this intent will always match any components in packages that
4280 * are currently stopped. This is the default behavior when
4281 * {@link #FLAG_EXCLUDE_STOPPED_PACKAGES} is not set. If both of these
4282 * flags are set, this one wins (it allows overriding of exclude for
4283 * places where the framework may automatically set the exclude flag).
4284 */
4285 public static final int FLAG_INCLUDE_STOPPED_PACKAGES = 0x00000020;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004286
4287 /**
Jeff Sharkey328ebf22013-03-21 18:09:39 -07004288 * When combined with {@link #FLAG_GRANT_READ_URI_PERMISSION} and/or
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004289 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, the URI permission grant can be
Jeff Sharkeye66c1772013-09-20 14:30:59 -07004290 * persisted across device reboots until explicitly revoked with
4291 * {@link Context#revokeUriPermission(Uri, int)}. This flag only offers the
4292 * grant for possible persisting; the receiving application must call
4293 * {@link ContentResolver#takePersistableUriPermission(Uri, int)} to
4294 * actually persist.
4295 *
4296 * @see ContentResolver#takePersistableUriPermission(Uri, int)
4297 * @see ContentResolver#releasePersistableUriPermission(Uri, int)
4298 * @see ContentResolver#getPersistedUriPermissions()
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004299 * @see ContentResolver#getOutgoingPersistedUriPermissions()
Jeff Sharkey328ebf22013-03-21 18:09:39 -07004300 */
Jeff Sharkeye66c1772013-09-20 14:30:59 -07004301 public static final int FLAG_GRANT_PERSISTABLE_URI_PERMISSION = 0x00000040;
Jeff Sharkey328ebf22013-03-21 18:09:39 -07004302
4303 /**
Jeff Sharkey846318a2014-04-04 12:12:41 -07004304 * When combined with {@link #FLAG_GRANT_READ_URI_PERMISSION} and/or
4305 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, the URI permission grant
4306 * applies to any URI that is a prefix match against the original granted
4307 * URI. (Without this flag, the URI must match exactly for access to be
4308 * granted.) Another URI is considered a prefix match only when scheme,
4309 * authority, and all path segments defined by the prefix are an exact
4310 * match.
4311 */
4312 public static final int FLAG_GRANT_PREFIX_URI_PERMISSION = 0x00000080;
4313
4314 /**
Jeff Sharkey2a9e3f82015-12-18 10:57:58 -07004315 * Internal flag used to indicate that a system component has done their
Jeff Sharkey2f3e3532015-12-21 14:16:43 -07004316 * homework and verified that they correctly handle packages and components
4317 * that come and go over time. In particular:
4318 * <ul>
4319 * <li>Apps installed on external storage, which will appear to be
4320 * uninstalled while the the device is ejected.
4321 * <li>Apps with encryption unaware components, which will appear to not
4322 * exist while the device is locked.
4323 * </ul>
Jeff Sharkey2a9e3f82015-12-18 10:57:58 -07004324 *
4325 * @hide
4326 */
Jeff Sharkey2f3e3532015-12-21 14:16:43 -07004327 public static final int FLAG_DEBUG_TRIAGED_MISSING = 0x00000100;
Jeff Sharkey2a9e3f82015-12-18 10:57:58 -07004328
4329 /**
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08004330 * If set, the new activity is not kept in the history stack. As soon as
4331 * the user navigates away from it, the activity is finished. This may also
4332 * be set with the {@link android.R.styleable#AndroidManifestActivity_noHistory
4333 * noHistory} attribute.
Ricardo Cervera92f6a742014-04-04 11:17:06 -07004334 *
4335 * <p>If set, {@link android.app.Activity#onActivityResult onActivityResult()}
4336 * is never invoked when the current activity starts a new activity which
4337 * sets a result and finishes.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004338 */
4339 public static final int FLAG_ACTIVITY_NO_HISTORY = 0x40000000;
4340 /**
4341 * If set, the activity will not be launched if it is already running
4342 * at the top of the history stack.
4343 */
4344 public static final int FLAG_ACTIVITY_SINGLE_TOP = 0x20000000;
4345 /**
4346 * If set, this activity will become the start of a new task on this
4347 * history stack. A task (from the activity that started it to the
4348 * next task activity) defines an atomic group of activities that the
4349 * user can move to. Tasks can be moved to the foreground and background;
4350 * all of the activities inside of a particular task always remain in
The Android Open Source Project10592532009-03-18 17:39:46 -07004351 * the same order. See
Scott Main7aee61f2011-02-08 11:25:01 -08004352 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
4353 * Stack</a> for more information about tasks.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004354 *
4355 * <p>This flag is generally used by activities that want
4356 * to present a "launcher" style behavior: they give the user a list of
4357 * separate things that can be done, which otherwise run completely
4358 * independently of the activity launching them.
4359 *
4360 * <p>When using this flag, if a task is already running for the activity
4361 * you are now starting, then a new activity will not be started; instead,
4362 * the current task will simply be brought to the front of the screen with
4363 * the state it was last in. See {@link #FLAG_ACTIVITY_MULTIPLE_TASK} for a flag
4364 * to disable this behavior.
4365 *
4366 * <p>This flag can not be used when the caller is requesting a result from
4367 * the activity being launched.
4368 */
4369 public static final int FLAG_ACTIVITY_NEW_TASK = 0x10000000;
4370 /**
Craig Mautnerd00f4742014-03-12 14:17:26 -07004371 * This flag is used to create a new task and launch an activity into it.
4372 * This flag is always paired with either {@link #FLAG_ACTIVITY_NEW_DOCUMENT}
4373 * or {@link #FLAG_ACTIVITY_NEW_TASK}. In both cases these flags alone would
4374 * search through existing tasks for ones matching this Intent. Only if no such
4375 * task is found would a new task be created. When paired with
4376 * FLAG_ACTIVITY_MULTIPLE_TASK both of these behaviors are modified to skip
4377 * the search for a matching task and unconditionally start a new task.
4378 *
4379 * <strong>When used with {@link #FLAG_ACTIVITY_NEW_TASK} do not use this
4380 * flag unless you are implementing your own
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004381 * top-level application launcher.</strong> Used in conjunction with
4382 * {@link #FLAG_ACTIVITY_NEW_TASK} to disable the
4383 * behavior of bringing an existing task to the foreground. When set,
4384 * a new task is <em>always</em> started to host the Activity for the
4385 * Intent, regardless of whether there is already an existing task running
4386 * the same thing.
4387 *
4388 * <p><strong>Because the default system does not include graphical task management,
4389 * you should not use this flag unless you provide some way for a user to
4390 * return back to the tasks you have launched.</strong>
The Android Open Source Project10592532009-03-18 17:39:46 -07004391 *
Craig Mautnerd00f4742014-03-12 14:17:26 -07004392 * See {@link #FLAG_ACTIVITY_NEW_DOCUMENT} for details of this flag's use for
4393 * creating new document tasks.
4394 *
4395 * <p>This flag is ignored if one of {@link #FLAG_ACTIVITY_NEW_TASK} or
Paul Soulos628cb742014-09-19 11:00:52 -07004396 * {@link #FLAG_ACTIVITY_NEW_DOCUMENT} is not also set.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004397 *
Scott Main7aee61f2011-02-08 11:25:01 -08004398 * <p>See
4399 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
4400 * Stack</a> for more information about tasks.
Craig Mautnerd00f4742014-03-12 14:17:26 -07004401 *
4402 * @see #FLAG_ACTIVITY_NEW_DOCUMENT
4403 * @see #FLAG_ACTIVITY_NEW_TASK
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004404 */
4405 public static final int FLAG_ACTIVITY_MULTIPLE_TASK = 0x08000000;
4406 /**
4407 * If set, and the activity being launched is already running in the
4408 * current task, then instead of launching a new instance of that activity,
4409 * all of the other activities on top of it will be closed and this Intent
4410 * will be delivered to the (now on top) old activity as a new Intent.
4411 *
4412 * <p>For example, consider a task consisting of the activities: A, B, C, D.
4413 * If D calls startActivity() with an Intent that resolves to the component
4414 * of activity B, then C and D will be finished and B receive the given
4415 * Intent, resulting in the stack now being: A, B.
4416 *
Dianne Hackbornaa52f9a2009-08-25 16:01:15 -07004417 * <p>The currently running instance of activity B in the above example will
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004418 * either receive the new intent you are starting here in its
4419 * onNewIntent() method, or be itself finished and restarted with the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004420 * new intent. If it has declared its launch mode to be "multiple" (the
Dianne Hackbornaa52f9a2009-08-25 16:01:15 -07004421 * default) and you have not set {@link #FLAG_ACTIVITY_SINGLE_TOP} in
4422 * the same intent, then it will be finished and re-created; for all other
4423 * launch modes or if {@link #FLAG_ACTIVITY_SINGLE_TOP} is set then this
4424 * Intent will be delivered to the current instance's onNewIntent().
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004425 *
4426 * <p>This launch mode can also be used to good effect in conjunction with
4427 * {@link #FLAG_ACTIVITY_NEW_TASK}: if used to start the root activity
4428 * of a task, it will bring any currently running instance of that task
4429 * to the foreground, and then clear it to its root state. This is
4430 * especially useful, for example, when launching an activity from the
4431 * notification manager.
4432 *
Scott Main7aee61f2011-02-08 11:25:01 -08004433 * <p>See
4434 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
4435 * Stack</a> for more information about tasks.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004436 */
4437 public static final int FLAG_ACTIVITY_CLEAR_TOP = 0x04000000;
4438 /**
4439 * If set and this intent is being used to launch a new activity from an
4440 * existing one, then the reply target of the existing activity will be
4441 * transfered to the new activity. This way the new activity can call
4442 * {@link android.app.Activity#setResult} and have that result sent back to
4443 * the reply target of the original activity.
4444 */
4445 public static final int FLAG_ACTIVITY_FORWARD_RESULT = 0x02000000;
4446 /**
4447 * If set and this intent is being used to launch a new activity from an
4448 * existing one, the current activity will not be counted as the top
4449 * activity for deciding whether the new intent should be delivered to
4450 * the top instead of starting a new one. The previous activity will
4451 * be used as the top, with the assumption being that the current activity
4452 * will finish itself immediately.
4453 */
4454 public static final int FLAG_ACTIVITY_PREVIOUS_IS_TOP = 0x01000000;
4455 /**
4456 * If set, the new activity is not kept in the list of recently launched
4457 * activities.
4458 */
4459 public static final int FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS = 0x00800000;
4460 /**
4461 * This flag is not normally set by application code, but set for you by
4462 * the system as described in the
4463 * {@link android.R.styleable#AndroidManifestActivity_launchMode
4464 * launchMode} documentation for the singleTask mode.
4465 */
4466 public static final int FLAG_ACTIVITY_BROUGHT_TO_FRONT = 0x00400000;
4467 /**
4468 * If set, and this activity is either being started in a new task or
4469 * bringing to the top an existing task, then it will be launched as
4470 * the front door of the task. This will result in the application of
4471 * any affinities needed to have that task in the proper state (either
4472 * moving activities to or from it), or simply resetting that task to
4473 * its initial state if needed.
4474 */
4475 public static final int FLAG_ACTIVITY_RESET_TASK_IF_NEEDED = 0x00200000;
4476 /**
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08004477 * This flag is not normally set by application code, but set for you by
4478 * the system if this activity is being launched from history
4479 * (longpress home key).
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004480 */
4481 public static final int FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY = 0x00100000;
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08004482 /**
Craig Mautnerf357c0c2014-06-09 09:23:27 -07004483 * @deprecated As of API 21 this performs identically to
4484 * {@link #FLAG_ACTIVITY_NEW_DOCUMENT} which should be used instead of this.
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08004485 */
4486 public static final int FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET = 0x00080000;
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08004487 /**
Craig Mautner026596b2014-05-21 15:35:44 -07004488 * This flag is used to open a document into a new task rooted at the activity launched
4489 * by this Intent. Through the use of this flag, or its equivalent attribute,
4490 * {@link android.R.attr#documentLaunchMode} multiple instances of the same activity
Chet Haase0d1c27a2014-11-03 18:35:16 +00004491 * containing different documents will appear in the recent tasks list.
Craig Mautnerd00f4742014-03-12 14:17:26 -07004492 *
Craig Mautner026596b2014-05-21 15:35:44 -07004493 * <p>The use of the activity attribute form of this,
4494 * {@link android.R.attr#documentLaunchMode}, is
4495 * preferred over the Intent flag described here. The attribute form allows the
4496 * Activity to specify multiple document behavior for all launchers of the Activity
4497 * whereas using this flag requires each Intent that launches the Activity to specify it.
Craig Mautnerd00f4742014-03-12 14:17:26 -07004498 *
Dianne Hackborn13420f22014-07-18 15:43:56 -07004499 * <p>Note that the default semantics of this flag w.r.t. whether the recents entry for
4500 * it is kept after the activity is finished is different than the use of
4501 * {@link #FLAG_ACTIVITY_NEW_TASK} and {@link android.R.attr#documentLaunchMode} -- if
4502 * this flag is being used to create a new recents entry, then by default that entry
4503 * will be removed once the activity is finished. You can modify this behavior with
4504 * {@link #FLAG_ACTIVITY_RETAIN_IN_RECENTS}.
4505 *
Craig Mautner026596b2014-05-21 15:35:44 -07004506 * <p>FLAG_ACTIVITY_NEW_DOCUMENT may be used in conjunction with {@link
4507 * #FLAG_ACTIVITY_MULTIPLE_TASK}. When used alone it is the
4508 * equivalent of the Activity manifest specifying {@link
4509 * android.R.attr#documentLaunchMode}="intoExisting". When used with
4510 * FLAG_ACTIVITY_MULTIPLE_TASK it is the equivalent of the Activity manifest specifying
4511 * {@link android.R.attr#documentLaunchMode}="always".
Craig Mautnerd00f4742014-03-12 14:17:26 -07004512 *
Craig Mautner026596b2014-05-21 15:35:44 -07004513 * Refer to {@link android.R.attr#documentLaunchMode} for more information.
Craig Mautnerd00f4742014-03-12 14:17:26 -07004514 *
Craig Mautner026596b2014-05-21 15:35:44 -07004515 * @see android.R.attr#documentLaunchMode
Craig Mautnerd00f4742014-03-12 14:17:26 -07004516 * @see #FLAG_ACTIVITY_MULTIPLE_TASK
4517 */
Craig Mautnerf357c0c2014-06-09 09:23:27 -07004518 public static final int FLAG_ACTIVITY_NEW_DOCUMENT = FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET;
Craig Mautnerd00f4742014-03-12 14:17:26 -07004519 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004520 * If set, this flag will prevent the normal {@link android.app.Activity#onUserLeaveHint}
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08004521 * callback from occurring on the current frontmost activity before it is
4522 * paused as the newly-started activity is brought to the front.
The Android Open Source Project10592532009-03-18 17:39:46 -07004523 *
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08004524 * <p>Typically, an activity can rely on that callback to indicate that an
4525 * explicit user action has caused their activity to be moved out of the
4526 * foreground. The callback marks an appropriate point in the activity's
4527 * lifecycle for it to dismiss any notifications that it intends to display
4528 * "until the user has seen them," such as a blinking LED.
The Android Open Source Project10592532009-03-18 17:39:46 -07004529 *
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08004530 * <p>If an activity is ever started via any non-user-driven events such as
4531 * phone-call receipt or an alarm handler, this flag should be passed to {@link
4532 * Context#startActivity Context.startActivity}, ensuring that the pausing
The Android Open Source Project10592532009-03-18 17:39:46 -07004533 * activity does not think the user has acknowledged its notification.
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08004534 */
4535 public static final int FLAG_ACTIVITY_NO_USER_ACTION = 0x00040000;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004536 /**
4537 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
4538 * this flag will cause the launched activity to be brought to the front of its
4539 * task's history stack if it is already running.
The Android Open Source Project10592532009-03-18 17:39:46 -07004540 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004541 * <p>For example, consider a task consisting of four activities: A, B, C, D.
4542 * If D calls startActivity() with an Intent that resolves to the component
4543 * of activity B, then B will be brought to the front of the history stack,
4544 * with this resulting order: A, C, D, B.
The Android Open Source Project10592532009-03-18 17:39:46 -07004545 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004546 * This flag will be ignored if {@link #FLAG_ACTIVITY_CLEAR_TOP} is also
The Android Open Source Project10592532009-03-18 17:39:46 -07004547 * specified.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004548 */
4549 public static final int FLAG_ACTIVITY_REORDER_TO_FRONT = 0X00020000;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004550 /**
Dianne Hackbornbfe319e2009-09-21 00:34:05 -07004551 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
4552 * this flag will prevent the system from applying an activity transition
4553 * animation to go to the next activity state. This doesn't mean an
4554 * animation will never run -- if another activity change happens that doesn't
4555 * specify this flag before the activity started here is displayed, then
Dianne Hackborn621e17d2010-11-22 15:59:56 -08004556 * that transition will be used. This flag can be put to good use
Dianne Hackbornbfe319e2009-09-21 00:34:05 -07004557 * when you are going to do a series of activity operations but the
4558 * animation seen by the user shouldn't be driven by the first activity
4559 * change but rather a later one.
4560 */
4561 public static final int FLAG_ACTIVITY_NO_ANIMATION = 0X00010000;
4562 /**
Dianne Hackborn621e17d2010-11-22 15:59:56 -08004563 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
4564 * this flag will cause any existing task that would be associated with the
4565 * activity to be cleared before the activity is started. That is, the activity
4566 * becomes the new root of an otherwise empty task, and any old activities
4567 * are finished. This can only be used in conjunction with {@link #FLAG_ACTIVITY_NEW_TASK}.
4568 */
4569 public static final int FLAG_ACTIVITY_CLEAR_TASK = 0X00008000;
4570 /**
4571 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
4572 * this flag will cause a newly launching task to be placed on top of the current
4573 * home activity task (if there is one). That is, pressing back from the task
4574 * will always return the user to home even if that was not the last activity they
4575 * saw. This can only be used in conjunction with {@link #FLAG_ACTIVITY_NEW_TASK}.
4576 */
4577 public static final int FLAG_ACTIVITY_TASK_ON_HOME = 0X00004000;
4578 /**
Dianne Hackborn13420f22014-07-18 15:43:56 -07004579 * By default a document created by {@link #FLAG_ACTIVITY_NEW_DOCUMENT} will
4580 * have its entry in recent tasks removed when the user closes it (with back
Jeff Sharkey9f991a22014-08-13 11:37:41 -07004581 * or however else it may finish()). If you would like to instead allow the
Dianne Hackborn13420f22014-07-18 15:43:56 -07004582 * document to be kept in recents so that it can be re-launched, you can use
Jeff Sharkey9f991a22014-08-13 11:37:41 -07004583 * this flag. When set and the task's activity is finished, the recents
4584 * entry will remain in the interface for the user to re-launch it, like a
4585 * recents entry for a top-level application.
4586 * <p>
4587 * The receiving activity can override this request with
4588 * {@link android.R.attr#autoRemoveFromRecents} or by explcitly calling
4589 * {@link android.app.Activity#finishAndRemoveTask()
Dianne Hackborn13420f22014-07-18 15:43:56 -07004590 * Activity.finishAndRemoveTask()}.
Craig Mautner2dac0562014-05-06 09:06:44 -07004591 */
Dianne Hackborn13420f22014-07-18 15:43:56 -07004592 public static final int FLAG_ACTIVITY_RETAIN_IN_RECENTS = 0x00002000;
Craig Mautnera228ae92014-07-09 05:44:55 -07004593
4594 /**
Wale Ogunwale2a25a622016-01-30 11:27:21 -08004595 * This flag is only used in split-screen multi-window mode. The new activity will be displayed
4596 * adjacent to the one launching it. This can only be used in conjunction with
Wale Ogunwale6bdf2572016-03-11 15:22:38 -08004597 * {@link #FLAG_ACTIVITY_NEW_TASK}. Also, setting {@link #FLAG_ACTIVITY_MULTIPLE_TASK} is
4598 * required if you want a new instance of an existing activity to be created.
Filip Gruszczynski80e29f12015-12-14 14:58:30 -08004599 */
Wale Ogunwale2a25a622016-01-30 11:27:21 -08004600 public static final int FLAG_ACTIVITY_LAUNCH_ADJACENT = 0x00001000;
Filip Gruszczynski80e29f12015-12-14 14:58:30 -08004601
4602 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004603 * If set, when sending a broadcast only registered receivers will be
4604 * called -- no BroadcastReceiver components will be launched.
4605 */
4606 public static final int FLAG_RECEIVER_REGISTERED_ONLY = 0x40000000;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004607 /**
Dianne Hackborn1c633fc2009-12-08 19:45:14 -08004608 * If set, when sending a broadcast the new broadcast will replace
4609 * any existing pending broadcast that matches it. Matching is defined
4610 * by {@link Intent#filterEquals(Intent) Intent.filterEquals} returning
4611 * true for the intents of the two broadcasts. When a match is found,
4612 * the new broadcast (and receivers associated with it) will replace the
4613 * existing one in the pending broadcast list, remaining at the same
4614 * position in the list.
Tom Taylord4a47292009-12-21 13:59:18 -08004615 *
Dianne Hackborn1c633fc2009-12-08 19:45:14 -08004616 * <p>This flag is most typically used with sticky broadcasts, which
4617 * only care about delivering the most recent values of the broadcast
4618 * to their receivers.
4619 */
4620 public static final int FLAG_RECEIVER_REPLACE_PENDING = 0x20000000;
4621 /**
Christopher Tatef46723b2012-01-26 14:19:24 -08004622 * If set, when sending a broadcast the recipient is allowed to run at
4623 * foreground priority, with a shorter timeout interval. During normal
4624 * broadcasts the receivers are not automatically hoisted out of the
4625 * background priority class.
4626 */
4627 public static final int FLAG_RECEIVER_FOREGROUND = 0x10000000;
4628 /**
Dianne Hackborn6285a322013-09-18 12:09:47 -07004629 * If this is an ordered broadcast, don't allow receivers to abort the broadcast.
4630 * They can still propagate results through to later receivers, but they can not prevent
4631 * later receivers from seeing the broadcast.
4632 */
4633 public static final int FLAG_RECEIVER_NO_ABORT = 0x08000000;
4634 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004635 * If set, when sending a broadcast <i>before boot has completed</i> only
4636 * registered receivers will be called -- no BroadcastReceiver components
4637 * will be launched. Sticky intent state will be recorded properly even
4638 * if no receivers wind up being called. If {@link #FLAG_RECEIVER_REGISTERED_ONLY}
4639 * is specified in the broadcast intent, this flag is unnecessary.
The Android Open Source Project10592532009-03-18 17:39:46 -07004640 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004641 * <p>This flag is only for use by system sevices as a convenience to
4642 * avoid having to implement a more complex mechanism around detection
4643 * of boot completion.
The Android Open Source Project10592532009-03-18 17:39:46 -07004644 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004645 * @hide
4646 */
Dianne Hackborn6285a322013-09-18 12:09:47 -07004647 public static final int FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT = 0x04000000;
Dianne Hackborn9acc0302009-08-25 00:27:12 -07004648 /**
4649 * Set when this broadcast is for a boot upgrade, a special mode that
4650 * allows the broadcast to be sent before the system is ready and launches
4651 * the app process with no providers running in it.
4652 * @hide
4653 */
Dianne Hackborn6285a322013-09-18 12:09:47 -07004654 public static final int FLAG_RECEIVER_BOOT_UPGRADE = 0x02000000;
Dianne Hackborn6ac42ae2015-12-08 17:22:10 -08004655 /**
4656 * If set, the broadcast will always go to manifest receivers in background (cached
4657 * or not running) apps, regardless of whether that would be done by default. By
4658 * default they will only receive broadcasts if the broadcast has specified an
4659 * explicit component or package name.
4660 * @hide
4661 */
4662 public static final int FLAG_RECEIVER_INCLUDE_BACKGROUND = 0x01000000;
4663 /**
4664 * If set, the broadcast will never go to manifest receivers in background (cached
4665 * or not running) apps, regardless of whether that would be done by default. By
4666 * default they will receive broadcasts if the broadcast has specified an
4667 * explicit component or package name.
4668 * @hide
4669 */
4670 public static final int FLAG_RECEIVER_EXCLUDE_BACKGROUND = 0x00800000;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004671
Dianne Hackbornfa82f222009-09-17 15:14:12 -07004672 /**
4673 * @hide Flags that can't be changed with PendingIntent.
4674 */
Jeff Sharkey846318a2014-04-04 12:12:41 -07004675 public static final int IMMUTABLE_FLAGS = FLAG_GRANT_READ_URI_PERMISSION
4676 | FLAG_GRANT_WRITE_URI_PERMISSION | FLAG_GRANT_PERSISTABLE_URI_PERMISSION
4677 | FLAG_GRANT_PREFIX_URI_PERMISSION;
Tom Taylord4a47292009-12-21 13:59:18 -08004678
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004679 // ---------------------------------------------------------------------
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004680 // ---------------------------------------------------------------------
4681 // toUri() and parseUri() options.
4682
4683 /**
4684 * Flag for use with {@link #toUri} and {@link #parseUri}: the URI string
4685 * always has the "intent:" scheme. This syntax can be used when you want
4686 * to later disambiguate between URIs that are intended to describe an
4687 * Intent vs. all others that should be treated as raw URIs. When used
4688 * with {@link #parseUri}, any other scheme will result in a generic
4689 * VIEW action for that raw URI.
4690 */
4691 public static final int URI_INTENT_SCHEME = 1<<0;
Tom Taylord4a47292009-12-21 13:59:18 -08004692
Dianne Hackborn85d558c2014-11-04 10:31:54 -08004693 /**
4694 * Flag for use with {@link #toUri} and {@link #parseUri}: the URI string
4695 * always has the "android-app:" scheme. This is a variation of
4696 * {@link #URI_INTENT_SCHEME} whose format is simpler for the case of an
4697 * http/https URI being delivered to a specific package name. The format
4698 * is:
4699 *
4700 * <pre class="prettyprint">
Dianne Hackborn0ee10f62015-01-14 16:16:13 -08004701 * android-app://{package_id}[/{scheme}[/{host}[/{path}]]][#Intent;{...}]</pre>
Dianne Hackborn85d558c2014-11-04 10:31:54 -08004702 *
Dianne Hackborn0ee10f62015-01-14 16:16:13 -08004703 * <p>In this scheme, only the <code>package_id</code> is required. If you include a host,
4704 * you must also include a scheme; including a path also requires both a host and a scheme.
4705 * The final #Intent; fragment can be used without a scheme, host, or path.
4706 * Note that this can not be
Dianne Hackborn85d558c2014-11-04 10:31:54 -08004707 * used with intents that have a {@link #setSelector}, since the base intent
4708 * will always have an explicit package name.</p>
4709 *
4710 * <p>Some examples of how this scheme maps to Intent objects:</p>
4711 * <table border="2" width="85%" align="center" frame="hsides" rules="rows">
4712 * <colgroup align="left" />
4713 * <colgroup align="left" />
4714 * <thead>
4715 * <tr><th>URI</th> <th>Intent</th></tr>
4716 * </thead>
4717 *
4718 * <tbody>
4719 * <tr><td><code>android-app://com.example.app</code></td>
4720 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
4721 * <tr><td>Action: </td><td>{@link #ACTION_MAIN}</td></tr>
4722 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
4723 * </table></td>
4724 * </tr>
4725 * <tr><td><code>android-app://com.example.app/http/example.com</code></td>
4726 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
4727 * <tr><td>Action: </td><td>{@link #ACTION_VIEW}</td></tr>
4728 * <tr><td>Data: </td><td><code>http://example.com/</code></td></tr>
4729 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
4730 * </table></td>
4731 * </tr>
4732 * <tr><td><code>android-app://com.example.app/http/example.com/foo?1234</code></td>
4733 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
4734 * <tr><td>Action: </td><td>{@link #ACTION_VIEW}</td></tr>
4735 * <tr><td>Data: </td><td><code>http://example.com/foo?1234</code></td></tr>
4736 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
4737 * </table></td>
4738 * </tr>
4739 * <tr><td><code>android-app://com.example.app/<br />#Intent;action=com.example.MY_ACTION;end</code></td>
4740 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
4741 * <tr><td>Action: </td><td><code>com.example.MY_ACTION</code></td></tr>
4742 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
4743 * </table></td>
4744 * </tr>
4745 * <tr><td><code>android-app://com.example.app/http/example.com/foo?1234<br />#Intent;action=com.example.MY_ACTION;end</code></td>
4746 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
4747 * <tr><td>Action: </td><td><code>com.example.MY_ACTION</code></td></tr>
4748 * <tr><td>Data: </td><td><code>http://example.com/foo?1234</code></td></tr>
4749 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
4750 * </table></td>
4751 * </tr>
4752 * <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>
4753 * <td><table border="" style="margin:0" >
4754 * <tr><td>Action: </td><td><code>com.example.MY_ACTION</code></td></tr>
4755 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
4756 * <tr><td>Extras: </td><td><code>some_int=(int)100<br />some_str=(String)hello</code></td></tr>
4757 * </table></td>
4758 * </tr>
4759 * </tbody>
4760 * </table>
4761 */
4762 public static final int URI_ANDROID_APP_SCHEME = 1<<1;
4763
Dianne Hackborn24b1c232014-11-20 17:17:39 -08004764 /**
4765 * Flag for use with {@link #toUri} and {@link #parseUri}: allow parsing
4766 * of unsafe information. In particular, the flags {@link #FLAG_GRANT_READ_URI_PERMISSION},
4767 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, {@link #FLAG_GRANT_PERSISTABLE_URI_PERMISSION},
4768 * and {@link #FLAG_GRANT_PREFIX_URI_PERMISSION} flags can not be set, so that the
4769 * generated Intent can not cause unexpected data access to happen.
4770 *
4771 * <p>If you do not trust the source of the URI being parsed, you should still do further
4772 * processing to protect yourself from it. In particular, when using it to start an
4773 * activity you should usually add in {@link #CATEGORY_BROWSABLE} to limit the activities
4774 * that can handle it.</p>
4775 */
4776 public static final int URI_ALLOW_UNSAFE = 1<<2;
4777
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004778 // ---------------------------------------------------------------------
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004779
4780 private String mAction;
4781 private Uri mData;
4782 private String mType;
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004783 private String mPackage;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004784 private ComponentName mComponent;
4785 private int mFlags;
Dianne Hackbornadd005c2013-07-17 18:43:12 -07004786 private ArraySet<String> mCategories;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004787 private Bundle mExtras;
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08004788 private Rect mSourceBounds;
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004789 private Intent mSelector;
Dianne Hackborn21c241e2012-03-08 13:57:23 -08004790 private ClipData mClipData;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01004791 private int mContentUserHint = UserHandle.USER_CURRENT;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004792
4793 // ---------------------------------------------------------------------
4794
4795 /**
4796 * Create an empty intent.
4797 */
4798 public Intent() {
4799 }
4800
4801 /**
4802 * Copy constructor.
4803 */
4804 public Intent(Intent o) {
4805 this.mAction = o.mAction;
4806 this.mData = o.mData;
4807 this.mType = o.mType;
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004808 this.mPackage = o.mPackage;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004809 this.mComponent = o.mComponent;
4810 this.mFlags = o.mFlags;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01004811 this.mContentUserHint = o.mContentUserHint;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004812 if (o.mCategories != null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07004813 this.mCategories = new ArraySet<String>(o.mCategories);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004814 }
4815 if (o.mExtras != null) {
4816 this.mExtras = new Bundle(o.mExtras);
4817 }
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08004818 if (o.mSourceBounds != null) {
4819 this.mSourceBounds = new Rect(o.mSourceBounds);
4820 }
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004821 if (o.mSelector != null) {
4822 this.mSelector = new Intent(o.mSelector);
4823 }
Dianne Hackborn21c241e2012-03-08 13:57:23 -08004824 if (o.mClipData != null) {
4825 this.mClipData = new ClipData(o.mClipData);
4826 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004827 }
4828
4829 @Override
4830 public Object clone() {
4831 return new Intent(this);
4832 }
4833
4834 private Intent(Intent o, boolean all) {
4835 this.mAction = o.mAction;
4836 this.mData = o.mData;
4837 this.mType = o.mType;
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004838 this.mPackage = o.mPackage;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004839 this.mComponent = o.mComponent;
4840 if (o.mCategories != null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07004841 this.mCategories = new ArraySet<String>(o.mCategories);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004842 }
4843 }
4844
4845 /**
4846 * Make a clone of only the parts of the Intent that are relevant for
4847 * filter matching: the action, data, type, component, and categories.
4848 */
4849 public Intent cloneFilter() {
4850 return new Intent(this, false);
4851 }
4852
4853 /**
4854 * Create an intent with a given action. All other fields (data, type,
4855 * class) are null. Note that the action <em>must</em> be in a
4856 * namespace because Intents are used globally in the system -- for
4857 * example the system VIEW action is android.intent.action.VIEW; an
4858 * application's custom action would be something like
4859 * com.google.app.myapp.CUSTOM_ACTION.
4860 *
4861 * @param action The Intent action, such as ACTION_VIEW.
4862 */
4863 public Intent(String action) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08004864 setAction(action);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004865 }
4866
4867 /**
4868 * Create an intent with a given action and for a given data url. Note
4869 * that the action <em>must</em> be in a namespace because Intents are
4870 * used globally in the system -- for example the system VIEW action is
4871 * android.intent.action.VIEW; an application's custom action would be
4872 * something like com.google.app.myapp.CUSTOM_ACTION.
4873 *
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07004874 * <p><em>Note: scheme and host name matching in the Android framework is
4875 * case-sensitive, unlike the formal RFC. As a result,
4876 * you should always ensure that you write your Uri with these elements
4877 * using lower case letters, and normalize any Uris you receive from
4878 * outside of Android to ensure the scheme and host is lower case.</em></p>
4879 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004880 * @param action The Intent action, such as ACTION_VIEW.
4881 * @param uri The Intent data URI.
4882 */
4883 public Intent(String action, Uri uri) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08004884 setAction(action);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004885 mData = uri;
4886 }
4887
4888 /**
4889 * Create an intent for a specific component. All other fields (action, data,
4890 * type, class) are null, though they can be modified later with explicit
4891 * calls. This provides a convenient way to create an intent that is
4892 * intended to execute a hard-coded class name, rather than relying on the
4893 * system to find an appropriate class for you; see {@link #setComponent}
4894 * for more information on the repercussions of this.
4895 *
4896 * @param packageContext A Context of the application package implementing
4897 * this class.
4898 * @param cls The component class that is to be used for the intent.
4899 *
4900 * @see #setClass
4901 * @see #setComponent
4902 * @see #Intent(String, android.net.Uri , Context, Class)
4903 */
4904 public Intent(Context packageContext, Class<?> cls) {
4905 mComponent = new ComponentName(packageContext, cls);
4906 }
4907
4908 /**
4909 * Create an intent for a specific component with a specified action and data.
Craig Mautner2dac0562014-05-06 09:06:44 -07004910 * This is equivalent to using {@link #Intent(String, android.net.Uri)} to
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004911 * construct the Intent and then calling {@link #setClass} to set its
4912 * class.
4913 *
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07004914 * <p><em>Note: scheme and host name matching in the Android framework is
4915 * case-sensitive, unlike the formal RFC. As a result,
4916 * you should always ensure that you write your Uri with these elements
4917 * using lower case letters, and normalize any Uris you receive from
4918 * outside of Android to ensure the scheme and host is lower case.</em></p>
4919 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004920 * @param action The Intent action, such as ACTION_VIEW.
4921 * @param uri The Intent data URI.
4922 * @param packageContext A Context of the application package implementing
4923 * this class.
4924 * @param cls The component class that is to be used for the intent.
4925 *
4926 * @see #Intent(String, android.net.Uri)
4927 * @see #Intent(Context, Class)
4928 * @see #setClass
4929 * @see #setComponent
4930 */
4931 public Intent(String action, Uri uri,
4932 Context packageContext, Class<?> cls) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08004933 setAction(action);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004934 mData = uri;
4935 mComponent = new ComponentName(packageContext, cls);
4936 }
4937
4938 /**
Dianne Hackborn30d71892010-12-11 10:37:55 -08004939 * Create an intent to launch the main (root) activity of a task. This
4940 * is the Intent that is started when the application's is launched from
4941 * Home. For anything else that wants to launch an application in the
4942 * same way, it is important that they use an Intent structured the same
4943 * way, and can use this function to ensure this is the case.
4944 *
4945 * <p>The returned Intent has the given Activity component as its explicit
4946 * component, {@link #ACTION_MAIN} as its action, and includes the
4947 * category {@link #CATEGORY_LAUNCHER}. This does <em>not</em> have
4948 * {@link #FLAG_ACTIVITY_NEW_TASK} set, though typically you will want
4949 * to do that through {@link #addFlags(int)} on the returned Intent.
4950 *
4951 * @param mainActivity The main activity component that this Intent will
4952 * launch.
4953 * @return Returns a newly created Intent that can be used to launch the
4954 * activity as a main application entry.
4955 *
4956 * @see #setClass
4957 * @see #setComponent
4958 */
4959 public static Intent makeMainActivity(ComponentName mainActivity) {
4960 Intent intent = new Intent(ACTION_MAIN);
4961 intent.setComponent(mainActivity);
4962 intent.addCategory(CATEGORY_LAUNCHER);
4963 return intent;
4964 }
4965
4966 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004967 * Make an Intent for the main activity of an application, without
4968 * specifying a specific activity to run but giving a selector to find
4969 * the activity. This results in a final Intent that is structured
4970 * the same as when the application is launched from
4971 * Home. For anything else that wants to launch an application in the
4972 * same way, it is important that they use an Intent structured the same
4973 * way, and can use this function to ensure this is the case.
4974 *
4975 * <p>The returned Intent has {@link #ACTION_MAIN} as its action, and includes the
4976 * category {@link #CATEGORY_LAUNCHER}. This does <em>not</em> have
4977 * {@link #FLAG_ACTIVITY_NEW_TASK} set, though typically you will want
4978 * to do that through {@link #addFlags(int)} on the returned Intent.
4979 *
4980 * @param selectorAction The action name of the Intent's selector.
4981 * @param selectorCategory The name of a category to add to the Intent's
4982 * selector.
4983 * @return Returns a newly created Intent that can be used to launch the
4984 * activity as a main application entry.
4985 *
4986 * @see #setSelector(Intent)
4987 */
4988 public static Intent makeMainSelectorActivity(String selectorAction,
4989 String selectorCategory) {
4990 Intent intent = new Intent(ACTION_MAIN);
4991 intent.addCategory(CATEGORY_LAUNCHER);
4992 Intent selector = new Intent();
4993 selector.setAction(selectorAction);
4994 selector.addCategory(selectorCategory);
4995 intent.setSelector(selector);
4996 return intent;
4997 }
4998
4999 /**
Dianne Hackborn30d71892010-12-11 10:37:55 -08005000 * Make an Intent that can be used to re-launch an application's task
5001 * in its base state. This is like {@link #makeMainActivity(ComponentName)},
5002 * but also sets the flags {@link #FLAG_ACTIVITY_NEW_TASK} and
5003 * {@link #FLAG_ACTIVITY_CLEAR_TASK}.
5004 *
5005 * @param mainActivity The activity component that is the root of the
5006 * task; this is the activity that has been published in the application's
5007 * manifest as the main launcher icon.
5008 *
5009 * @return Returns a newly created Intent that can be used to relaunch the
5010 * activity's task in its root state.
5011 */
5012 public static Intent makeRestartActivityTask(ComponentName mainActivity) {
5013 Intent intent = makeMainActivity(mainActivity);
5014 intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK
5015 | Intent.FLAG_ACTIVITY_CLEAR_TASK);
5016 return intent;
5017 }
5018
5019 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005020 * Call {@link #parseUri} with 0 flags.
5021 * @deprecated Use {@link #parseUri} instead.
5022 */
5023 @Deprecated
5024 public static Intent getIntent(String uri) throws URISyntaxException {
5025 return parseUri(uri, 0);
5026 }
Tom Taylord4a47292009-12-21 13:59:18 -08005027
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005028 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005029 * Create an intent from a URI. This URI may encode the action,
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005030 * category, and other intent fields, if it was returned by
Dianne Hackborn7f205432009-07-28 00:13:47 -07005031 * {@link #toUri}. If the Intent was not generate by toUri(), its data
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005032 * will be the entire URI and its action will be ACTION_VIEW.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005033 *
5034 * <p>The URI given here must not be relative -- that is, it must include
5035 * the scheme and full path.
5036 *
5037 * @param uri The URI to turn into an Intent.
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005038 * @param flags Additional processing flags. Either 0,
5039 * {@link #URI_INTENT_SCHEME}, or {@link #URI_ANDROID_APP_SCHEME}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005040 *
5041 * @return Intent The newly created Intent object.
5042 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005043 * @throws URISyntaxException Throws URISyntaxError if the basic URI syntax
5044 * it bad (as parsed by the Uri class) or the Intent data within the
5045 * URI is invalid.
Tom Taylord4a47292009-12-21 13:59:18 -08005046 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005047 * @see #toUri
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005048 */
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005049 public static Intent parseUri(String uri, int flags) throws URISyntaxException {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005050 int i = 0;
5051 try {
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005052 final boolean androidApp = uri.startsWith("android-app:");
5053
5054 // Validate intent scheme if requested.
5055 if ((flags&(URI_INTENT_SCHEME|URI_ANDROID_APP_SCHEME)) != 0) {
5056 if (!uri.startsWith("intent:") && !androidApp) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005057 Intent intent = new Intent(ACTION_VIEW);
5058 try {
5059 intent.setData(Uri.parse(uri));
5060 } catch (IllegalArgumentException e) {
5061 throw new URISyntaxException(uri, e.getMessage());
5062 }
5063 return intent;
5064 }
5065 }
Tom Taylord4a47292009-12-21 13:59:18 -08005066
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005067 i = uri.lastIndexOf("#");
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005068 // simple case
5069 if (i == -1) {
5070 if (!androidApp) {
5071 return new Intent(ACTION_VIEW, Uri.parse(uri));
5072 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005073
5074 // old format Intent URI
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005075 } else if (!uri.startsWith("#Intent;", i)) {
5076 if (!androidApp) {
Dianne Hackborn24b1c232014-11-20 17:17:39 -08005077 return getIntentOld(uri, flags);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005078 } else {
5079 i = -1;
5080 }
5081 }
The Android Open Source Project10592532009-03-18 17:39:46 -07005082
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005083 // new format
5084 Intent intent = new Intent(ACTION_VIEW);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005085 Intent baseIntent = intent;
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005086 boolean explicitAction = false;
5087 boolean inSelector = false;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005088
5089 // fetch data part, if present
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005090 String scheme = null;
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005091 String data;
5092 if (i >= 0) {
5093 data = uri.substring(0, i);
5094 i += 8; // length of "#Intent;"
5095 } else {
5096 data = uri;
5097 }
The Android Open Source Project10592532009-03-18 17:39:46 -07005098
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005099 // loop over contents of Intent, all name=value;
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005100 while (i >= 0 && !uri.startsWith("end", i)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005101 int eq = uri.indexOf('=', i);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005102 if (eq < 0) eq = i-1;
5103 int semi = uri.indexOf(';', i);
5104 String value = eq < semi ? Uri.decode(uri.substring(eq + 1, semi)) : "";
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005105
5106 // action
5107 if (uri.startsWith("action=", i)) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08005108 intent.setAction(value);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005109 if (!inSelector) {
5110 explicitAction = true;
5111 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005112 }
5113
5114 // categories
5115 else if (uri.startsWith("category=", i)) {
5116 intent.addCategory(value);
5117 }
5118
5119 // type
5120 else if (uri.startsWith("type=", i)) {
5121 intent.mType = value;
5122 }
5123
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08005124 // launch flags
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005125 else if (uri.startsWith("launchFlags=", i)) {
5126 intent.mFlags = Integer.decode(value).intValue();
Dianne Hackborn24b1c232014-11-20 17:17:39 -08005127 if ((flags& URI_ALLOW_UNSAFE) == 0) {
5128 intent.mFlags &= ~IMMUTABLE_FLAGS;
5129 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005130 }
5131
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005132 // package
5133 else if (uri.startsWith("package=", i)) {
5134 intent.mPackage = value;
5135 }
5136
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005137 // component
5138 else if (uri.startsWith("component=", i)) {
5139 intent.mComponent = ComponentName.unflattenFromString(value);
5140 }
The Android Open Source Project10592532009-03-18 17:39:46 -07005141
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005142 // scheme
5143 else if (uri.startsWith("scheme=", i)) {
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005144 if (inSelector) {
Dianne Hackborn80b1c562014-12-09 20:22:08 -08005145 intent.mData = Uri.parse(value + ":");
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005146 } else {
5147 scheme = value;
5148 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005149 }
5150
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08005151 // source bounds
5152 else if (uri.startsWith("sourceBounds=", i)) {
5153 intent.mSourceBounds = Rect.unflattenFromString(value);
5154 }
5155
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005156 // selector
5157 else if (semi == (i+3) && uri.startsWith("SEL", i)) {
5158 intent = new Intent();
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005159 inSelector = true;
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005160 }
5161
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005162 // extra
5163 else {
5164 String key = Uri.decode(uri.substring(i + 2, eq));
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005165 // create Bundle if it doesn't already exist
5166 if (intent.mExtras == null) intent.mExtras = new Bundle();
5167 Bundle b = intent.mExtras;
5168 // add EXTRA
5169 if (uri.startsWith("S.", i)) b.putString(key, value);
5170 else if (uri.startsWith("B.", i)) b.putBoolean(key, Boolean.parseBoolean(value));
5171 else if (uri.startsWith("b.", i)) b.putByte(key, Byte.parseByte(value));
5172 else if (uri.startsWith("c.", i)) b.putChar(key, value.charAt(0));
5173 else if (uri.startsWith("d.", i)) b.putDouble(key, Double.parseDouble(value));
5174 else if (uri.startsWith("f.", i)) b.putFloat(key, Float.parseFloat(value));
5175 else if (uri.startsWith("i.", i)) b.putInt(key, Integer.parseInt(value));
5176 else if (uri.startsWith("l.", i)) b.putLong(key, Long.parseLong(value));
5177 else if (uri.startsWith("s.", i)) b.putShort(key, Short.parseShort(value));
5178 else throw new URISyntaxException(uri, "unknown EXTRA type", i);
5179 }
The Android Open Source Project10592532009-03-18 17:39:46 -07005180
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005181 // move to the next item
5182 i = semi + 1;
5183 }
5184
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005185 if (inSelector) {
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005186 // The Intent had a selector; fix it up.
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005187 if (baseIntent.mPackage == null) {
5188 baseIntent.setSelector(intent);
5189 }
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005190 intent = baseIntent;
5191 }
5192
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005193 if (data != null) {
5194 if (data.startsWith("intent:")) {
5195 data = data.substring(7);
5196 if (scheme != null) {
5197 data = scheme + ':' + data;
5198 }
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005199 } else if (data.startsWith("android-app:")) {
5200 if (data.charAt(12) == '/' && data.charAt(13) == '/') {
5201 // Correctly formed android-app, first part is package name.
5202 int end = data.indexOf('/', 14);
5203 if (end < 0) {
5204 // All we have is a package name.
5205 intent.mPackage = data.substring(14);
5206 if (!explicitAction) {
5207 intent.setAction(ACTION_MAIN);
5208 }
5209 data = "";
5210 } else {
5211 // Target the Intent at the given package name always.
5212 String authority = null;
5213 intent.mPackage = data.substring(14, end);
5214 int newEnd;
Dianne Hackborn80b1c562014-12-09 20:22:08 -08005215 if ((end+1) < data.length()) {
5216 if ((newEnd=data.indexOf('/', end+1)) >= 0) {
5217 // Found a scheme, remember it.
5218 scheme = data.substring(end+1, newEnd);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005219 end = newEnd;
Dianne Hackborn80b1c562014-12-09 20:22:08 -08005220 if (end < data.length() && (newEnd=data.indexOf('/', end+1)) >= 0) {
5221 // Found a authority, remember it.
5222 authority = data.substring(end+1, newEnd);
5223 end = newEnd;
5224 }
5225 } else {
5226 // All we have is a scheme.
5227 scheme = data.substring(end+1);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005228 }
5229 }
5230 if (scheme == null) {
5231 // If there was no scheme, then this just targets the package.
5232 if (!explicitAction) {
5233 intent.setAction(ACTION_MAIN);
5234 }
5235 data = "";
5236 } else if (authority == null) {
5237 data = scheme + ":";
5238 } else {
5239 data = scheme + "://" + authority + data.substring(end);
5240 }
5241 }
5242 } else {
5243 data = "";
5244 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005245 }
Tom Taylord4a47292009-12-21 13:59:18 -08005246
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005247 if (data.length() > 0) {
5248 try {
5249 intent.mData = Uri.parse(data);
5250 } catch (IllegalArgumentException e) {
5251 throw new URISyntaxException(uri, e.getMessage());
5252 }
5253 }
5254 }
Tom Taylord4a47292009-12-21 13:59:18 -08005255
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005256 return intent;
The Android Open Source Project10592532009-03-18 17:39:46 -07005257
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005258 } catch (IndexOutOfBoundsException e) {
5259 throw new URISyntaxException(uri, "illegal Intent URI format", i);
5260 }
5261 }
The Android Open Source Project10592532009-03-18 17:39:46 -07005262
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005263 public static Intent getIntentOld(String uri) throws URISyntaxException {
Dianne Hackborn24b1c232014-11-20 17:17:39 -08005264 return getIntentOld(uri, 0);
5265 }
5266
5267 private static Intent getIntentOld(String uri, int flags) throws URISyntaxException {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005268 Intent intent;
5269
5270 int i = uri.lastIndexOf('#');
5271 if (i >= 0) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005272 String action = null;
Dianne Hackborn6cca1592009-09-20 12:40:03 -07005273 final int intentFragmentStart = i;
5274 boolean isIntentFragment = false;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005275
5276 i++;
5277
5278 if (uri.regionMatches(i, "action(", 0, 7)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07005279 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005280 i += 7;
5281 int j = uri.indexOf(')', i);
5282 action = uri.substring(i, j);
5283 i = j + 1;
5284 }
5285
Dianne Hackborn6cca1592009-09-20 12:40:03 -07005286 intent = new Intent(action);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005287
5288 if (uri.regionMatches(i, "categories(", 0, 11)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07005289 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005290 i += 11;
5291 int j = uri.indexOf(')', i);
5292 while (i < j) {
5293 int sep = uri.indexOf('!', i);
Alan Viverette0adf32b2014-09-18 12:53:16 -07005294 if (sep < 0 || sep > j) sep = j;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005295 if (i < sep) {
5296 intent.addCategory(uri.substring(i, sep));
5297 }
5298 i = sep + 1;
5299 }
5300 i = j + 1;
5301 }
5302
5303 if (uri.regionMatches(i, "type(", 0, 5)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07005304 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005305 i += 5;
5306 int j = uri.indexOf(')', i);
5307 intent.mType = uri.substring(i, j);
5308 i = j + 1;
5309 }
5310
5311 if (uri.regionMatches(i, "launchFlags(", 0, 12)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07005312 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005313 i += 12;
5314 int j = uri.indexOf(')', i);
5315 intent.mFlags = Integer.decode(uri.substring(i, j)).intValue();
Dianne Hackborn24b1c232014-11-20 17:17:39 -08005316 if ((flags& URI_ALLOW_UNSAFE) == 0) {
5317 intent.mFlags &= ~IMMUTABLE_FLAGS;
5318 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005319 i = j + 1;
5320 }
5321
5322 if (uri.regionMatches(i, "component(", 0, 10)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07005323 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005324 i += 10;
5325 int j = uri.indexOf(')', i);
5326 int sep = uri.indexOf('!', i);
5327 if (sep >= 0 && sep < j) {
5328 String pkg = uri.substring(i, sep);
5329 String cls = uri.substring(sep + 1, j);
5330 intent.mComponent = new ComponentName(pkg, cls);
5331 }
5332 i = j + 1;
5333 }
5334
5335 if (uri.regionMatches(i, "extras(", 0, 7)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07005336 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005337 i += 7;
The Android Open Source Project10592532009-03-18 17:39:46 -07005338
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005339 final int closeParen = uri.indexOf(')', i);
5340 if (closeParen == -1) throw new URISyntaxException(uri,
5341 "EXTRA missing trailing ')'", i);
5342
5343 while (i < closeParen) {
5344 // fetch the key value
5345 int j = uri.indexOf('=', i);
5346 if (j <= i + 1 || i >= closeParen) {
5347 throw new URISyntaxException(uri, "EXTRA missing '='", i);
5348 }
5349 char type = uri.charAt(i);
5350 i++;
5351 String key = uri.substring(i, j);
5352 i = j + 1;
The Android Open Source Project10592532009-03-18 17:39:46 -07005353
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005354 // get type-value
5355 j = uri.indexOf('!', i);
5356 if (j == -1 || j >= closeParen) j = closeParen;
5357 if (i >= j) throw new URISyntaxException(uri, "EXTRA missing '!'", i);
5358 String value = uri.substring(i, j);
5359 i = j;
5360
5361 // create Bundle if it doesn't already exist
5362 if (intent.mExtras == null) intent.mExtras = new Bundle();
The Android Open Source Project10592532009-03-18 17:39:46 -07005363
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005364 // add item to bundle
5365 try {
5366 switch (type) {
5367 case 'S':
5368 intent.mExtras.putString(key, Uri.decode(value));
5369 break;
5370 case 'B':
5371 intent.mExtras.putBoolean(key, Boolean.parseBoolean(value));
5372 break;
5373 case 'b':
5374 intent.mExtras.putByte(key, Byte.parseByte(value));
5375 break;
5376 case 'c':
5377 intent.mExtras.putChar(key, Uri.decode(value).charAt(0));
5378 break;
5379 case 'd':
5380 intent.mExtras.putDouble(key, Double.parseDouble(value));
5381 break;
5382 case 'f':
5383 intent.mExtras.putFloat(key, Float.parseFloat(value));
5384 break;
5385 case 'i':
5386 intent.mExtras.putInt(key, Integer.parseInt(value));
5387 break;
5388 case 'l':
5389 intent.mExtras.putLong(key, Long.parseLong(value));
5390 break;
5391 case 's':
5392 intent.mExtras.putShort(key, Short.parseShort(value));
5393 break;
5394 default:
5395 throw new URISyntaxException(uri, "EXTRA has unknown type", i);
5396 }
5397 } catch (NumberFormatException e) {
5398 throw new URISyntaxException(uri, "EXTRA value can't be parsed", i);
5399 }
The Android Open Source Project10592532009-03-18 17:39:46 -07005400
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005401 char ch = uri.charAt(i);
5402 if (ch == ')') break;
5403 if (ch != '!') throw new URISyntaxException(uri, "EXTRA missing '!'", i);
5404 i++;
5405 }
5406 }
5407
Dianne Hackborn6cca1592009-09-20 12:40:03 -07005408 if (isIntentFragment) {
5409 intent.mData = Uri.parse(uri.substring(0, intentFragmentStart));
5410 } else {
5411 intent.mData = Uri.parse(uri);
5412 }
Tom Taylord4a47292009-12-21 13:59:18 -08005413
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005414 if (intent.mAction == null) {
5415 // By default, if no action is specified, then use VIEW.
5416 intent.mAction = ACTION_VIEW;
5417 }
5418
5419 } else {
5420 intent = new Intent(ACTION_VIEW, Uri.parse(uri));
5421 }
5422
5423 return intent;
5424 }
5425
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08005426 /** @hide */
5427 public interface CommandOptionHandler {
5428 boolean handleOption(String opt, ShellCommand cmd);
5429 }
5430
5431 /** @hide */
5432 public static Intent parseCommandArgs(ShellCommand cmd, CommandOptionHandler optionHandler)
5433 throws URISyntaxException {
5434 Intent intent = new Intent();
5435 Intent baseIntent = intent;
5436 boolean hasIntentInfo = false;
5437
5438 Uri data = null;
5439 String type = null;
5440
5441 String opt;
5442 while ((opt=cmd.getNextOption()) != null) {
5443 switch (opt) {
5444 case "-a":
5445 intent.setAction(cmd.getNextArgRequired());
5446 if (intent == baseIntent) {
5447 hasIntentInfo = true;
5448 }
5449 break;
5450 case "-d":
5451 data = Uri.parse(cmd.getNextArgRequired());
5452 if (intent == baseIntent) {
5453 hasIntentInfo = true;
5454 }
5455 break;
5456 case "-t":
5457 type = cmd.getNextArgRequired();
5458 if (intent == baseIntent) {
5459 hasIntentInfo = true;
5460 }
5461 break;
5462 case "-c":
5463 intent.addCategory(cmd.getNextArgRequired());
5464 if (intent == baseIntent) {
5465 hasIntentInfo = true;
5466 }
5467 break;
5468 case "-e":
5469 case "--es": {
5470 String key = cmd.getNextArgRequired();
5471 String value = cmd.getNextArgRequired();
5472 intent.putExtra(key, value);
5473 }
5474 break;
5475 case "--esn": {
5476 String key = cmd.getNextArgRequired();
5477 intent.putExtra(key, (String) null);
5478 }
5479 break;
5480 case "--ei": {
5481 String key = cmd.getNextArgRequired();
5482 String value = cmd.getNextArgRequired();
5483 intent.putExtra(key, Integer.decode(value));
5484 }
5485 break;
5486 case "--eu": {
5487 String key = cmd.getNextArgRequired();
5488 String value = cmd.getNextArgRequired();
5489 intent.putExtra(key, Uri.parse(value));
5490 }
5491 break;
5492 case "--ecn": {
5493 String key = cmd.getNextArgRequired();
5494 String value = cmd.getNextArgRequired();
5495 ComponentName cn = ComponentName.unflattenFromString(value);
5496 if (cn == null)
5497 throw new IllegalArgumentException("Bad component name: " + value);
5498 intent.putExtra(key, cn);
5499 }
5500 break;
5501 case "--eia": {
5502 String key = cmd.getNextArgRequired();
5503 String value = cmd.getNextArgRequired();
5504 String[] strings = value.split(",");
5505 int[] list = new int[strings.length];
5506 for (int i = 0; i < strings.length; i++) {
5507 list[i] = Integer.decode(strings[i]);
5508 }
5509 intent.putExtra(key, list);
5510 }
5511 break;
5512 case "--eial": {
5513 String key = cmd.getNextArgRequired();
5514 String value = cmd.getNextArgRequired();
5515 String[] strings = value.split(",");
5516 ArrayList<Integer> list = new ArrayList<>(strings.length);
5517 for (int i = 0; i < strings.length; i++) {
5518 list.add(Integer.decode(strings[i]));
5519 }
5520 intent.putExtra(key, list);
5521 }
5522 break;
5523 case "--el": {
5524 String key = cmd.getNextArgRequired();
5525 String value = cmd.getNextArgRequired();
5526 intent.putExtra(key, Long.valueOf(value));
5527 }
5528 break;
5529 case "--ela": {
5530 String key = cmd.getNextArgRequired();
5531 String value = cmd.getNextArgRequired();
5532 String[] strings = value.split(",");
5533 long[] list = new long[strings.length];
5534 for (int i = 0; i < strings.length; i++) {
5535 list[i] = Long.valueOf(strings[i]);
5536 }
5537 intent.putExtra(key, list);
5538 hasIntentInfo = true;
5539 }
5540 break;
5541 case "--elal": {
5542 String key = cmd.getNextArgRequired();
5543 String value = cmd.getNextArgRequired();
5544 String[] strings = value.split(",");
5545 ArrayList<Long> list = new ArrayList<>(strings.length);
5546 for (int i = 0; i < strings.length; i++) {
5547 list.add(Long.valueOf(strings[i]));
5548 }
5549 intent.putExtra(key, list);
5550 hasIntentInfo = true;
5551 }
5552 break;
5553 case "--ef": {
5554 String key = cmd.getNextArgRequired();
5555 String value = cmd.getNextArgRequired();
5556 intent.putExtra(key, Float.valueOf(value));
5557 hasIntentInfo = true;
5558 }
5559 break;
5560 case "--efa": {
5561 String key = cmd.getNextArgRequired();
5562 String value = cmd.getNextArgRequired();
5563 String[] strings = value.split(",");
5564 float[] list = new float[strings.length];
5565 for (int i = 0; i < strings.length; i++) {
5566 list[i] = Float.valueOf(strings[i]);
5567 }
5568 intent.putExtra(key, list);
5569 hasIntentInfo = true;
5570 }
5571 break;
5572 case "--efal": {
5573 String key = cmd.getNextArgRequired();
5574 String value = cmd.getNextArgRequired();
5575 String[] strings = value.split(",");
5576 ArrayList<Float> list = new ArrayList<>(strings.length);
5577 for (int i = 0; i < strings.length; i++) {
5578 list.add(Float.valueOf(strings[i]));
5579 }
5580 intent.putExtra(key, list);
5581 hasIntentInfo = true;
5582 }
5583 break;
5584 case "--esa": {
5585 String key = cmd.getNextArgRequired();
5586 String value = cmd.getNextArgRequired();
5587 // Split on commas unless they are preceeded by an escape.
5588 // The escape character must be escaped for the string and
5589 // again for the regex, thus four escape characters become one.
5590 String[] strings = value.split("(?<!\\\\),");
5591 intent.putExtra(key, strings);
5592 hasIntentInfo = true;
5593 }
5594 break;
5595 case "--esal": {
5596 String key = cmd.getNextArgRequired();
5597 String value = cmd.getNextArgRequired();
5598 // Split on commas unless they are preceeded by an escape.
5599 // The escape character must be escaped for the string and
5600 // again for the regex, thus four escape characters become one.
5601 String[] strings = value.split("(?<!\\\\),");
5602 ArrayList<String> list = new ArrayList<>(strings.length);
5603 for (int i = 0; i < strings.length; i++) {
5604 list.add(strings[i]);
5605 }
5606 intent.putExtra(key, list);
5607 hasIntentInfo = true;
5608 }
5609 break;
5610 case "--ez": {
5611 String key = cmd.getNextArgRequired();
5612 String value = cmd.getNextArgRequired().toLowerCase();
5613 // Boolean.valueOf() results in false for anything that is not "true", which is
5614 // error-prone in shell commands
5615 boolean arg;
5616 if ("true".equals(value) || "t".equals(value)) {
5617 arg = true;
5618 } else if ("false".equals(value) || "f".equals(value)) {
5619 arg = false;
5620 } else {
5621 try {
5622 arg = Integer.decode(value) != 0;
5623 } catch (NumberFormatException ex) {
5624 throw new IllegalArgumentException("Invalid boolean value: " + value);
5625 }
5626 }
5627
5628 intent.putExtra(key, arg);
5629 }
5630 break;
5631 case "-n": {
5632 String str = cmd.getNextArgRequired();
5633 ComponentName cn = ComponentName.unflattenFromString(str);
5634 if (cn == null)
5635 throw new IllegalArgumentException("Bad component name: " + str);
5636 intent.setComponent(cn);
5637 if (intent == baseIntent) {
5638 hasIntentInfo = true;
5639 }
5640 }
5641 break;
5642 case "-p": {
5643 String str = cmd.getNextArgRequired();
5644 intent.setPackage(str);
5645 if (intent == baseIntent) {
5646 hasIntentInfo = true;
5647 }
5648 }
5649 break;
5650 case "-f":
5651 String str = cmd.getNextArgRequired();
5652 intent.setFlags(Integer.decode(str).intValue());
5653 break;
5654 case "--grant-read-uri-permission":
5655 intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
5656 break;
5657 case "--grant-write-uri-permission":
5658 intent.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
5659 break;
5660 case "--grant-persistable-uri-permission":
5661 intent.addFlags(Intent.FLAG_GRANT_PERSISTABLE_URI_PERMISSION);
5662 break;
5663 case "--grant-prefix-uri-permission":
5664 intent.addFlags(Intent.FLAG_GRANT_PREFIX_URI_PERMISSION);
5665 break;
5666 case "--exclude-stopped-packages":
5667 intent.addFlags(Intent.FLAG_EXCLUDE_STOPPED_PACKAGES);
5668 break;
5669 case "--include-stopped-packages":
5670 intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
5671 break;
5672 case "--debug-log-resolution":
5673 intent.addFlags(Intent.FLAG_DEBUG_LOG_RESOLUTION);
5674 break;
5675 case "--activity-brought-to-front":
5676 intent.addFlags(Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT);
5677 break;
5678 case "--activity-clear-top":
5679 intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
5680 break;
5681 case "--activity-clear-when-task-reset":
5682 intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
5683 break;
5684 case "--activity-exclude-from-recents":
5685 intent.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
5686 break;
5687 case "--activity-launched-from-history":
5688 intent.addFlags(Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY);
5689 break;
5690 case "--activity-multiple-task":
5691 intent.addFlags(Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
5692 break;
5693 case "--activity-no-animation":
5694 intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
5695 break;
5696 case "--activity-no-history":
5697 intent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
5698 break;
5699 case "--activity-no-user-action":
5700 intent.addFlags(Intent.FLAG_ACTIVITY_NO_USER_ACTION);
5701 break;
5702 case "--activity-previous-is-top":
5703 intent.addFlags(Intent.FLAG_ACTIVITY_PREVIOUS_IS_TOP);
5704 break;
5705 case "--activity-reorder-to-front":
5706 intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
5707 break;
5708 case "--activity-reset-task-if-needed":
5709 intent.addFlags(Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
5710 break;
5711 case "--activity-single-top":
5712 intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
5713 break;
5714 case "--activity-clear-task":
5715 intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
5716 break;
5717 case "--activity-task-on-home":
5718 intent.addFlags(Intent.FLAG_ACTIVITY_TASK_ON_HOME);
5719 break;
5720 case "--receiver-registered-only":
5721 intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY);
5722 break;
5723 case "--receiver-replace-pending":
5724 intent.addFlags(Intent.FLAG_RECEIVER_REPLACE_PENDING);
5725 break;
Felipe Leme3cb48cd2016-01-27 08:39:09 -08005726 case "--receiver-foreground":
5727 intent.addFlags(Intent.FLAG_RECEIVER_FOREGROUND);
5728 break;
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08005729 case "--selector":
5730 intent.setDataAndType(data, type);
5731 intent = new Intent();
5732 break;
5733 default:
5734 if (optionHandler != null && optionHandler.handleOption(opt, cmd)) {
5735 // Okay, caller handled this option.
5736 } else {
5737 throw new IllegalArgumentException("Unknown option: " + opt);
5738 }
5739 break;
5740 }
5741 }
5742 intent.setDataAndType(data, type);
5743
5744 final boolean hasSelector = intent != baseIntent;
5745 if (hasSelector) {
5746 // A selector was specified; fix up.
5747 baseIntent.setSelector(intent);
5748 intent = baseIntent;
5749 }
5750
5751 String arg = cmd.getNextArg();
5752 baseIntent = null;
5753 if (arg == null) {
5754 if (hasSelector) {
5755 // If a selector has been specified, and no arguments
5756 // have been supplied for the main Intent, then we can
5757 // assume it is ACTION_MAIN CATEGORY_LAUNCHER; we don't
5758 // need to have a component name specified yet, the
5759 // selector will take care of that.
5760 baseIntent = new Intent(Intent.ACTION_MAIN);
5761 baseIntent.addCategory(Intent.CATEGORY_LAUNCHER);
5762 }
5763 } else if (arg.indexOf(':') >= 0) {
5764 // The argument is a URI. Fully parse it, and use that result
5765 // to fill in any data not specified so far.
5766 baseIntent = Intent.parseUri(arg, Intent.URI_INTENT_SCHEME
5767 | Intent.URI_ANDROID_APP_SCHEME | Intent.URI_ALLOW_UNSAFE);
5768 } else if (arg.indexOf('/') >= 0) {
5769 // The argument is a component name. Build an Intent to launch
5770 // it.
5771 baseIntent = new Intent(Intent.ACTION_MAIN);
5772 baseIntent.addCategory(Intent.CATEGORY_LAUNCHER);
5773 baseIntent.setComponent(ComponentName.unflattenFromString(arg));
5774 } else {
5775 // Assume the argument is a package name.
5776 baseIntent = new Intent(Intent.ACTION_MAIN);
5777 baseIntent.addCategory(Intent.CATEGORY_LAUNCHER);
5778 baseIntent.setPackage(arg);
5779 }
5780 if (baseIntent != null) {
5781 Bundle extras = intent.getExtras();
5782 intent.replaceExtras((Bundle)null);
5783 Bundle uriExtras = baseIntent.getExtras();
5784 baseIntent.replaceExtras((Bundle)null);
5785 if (intent.getAction() != null && baseIntent.getCategories() != null) {
5786 HashSet<String> cats = new HashSet<String>(baseIntent.getCategories());
5787 for (String c : cats) {
5788 baseIntent.removeCategory(c);
5789 }
5790 }
5791 intent.fillIn(baseIntent, Intent.FILL_IN_COMPONENT | Intent.FILL_IN_SELECTOR);
5792 if (extras == null) {
5793 extras = uriExtras;
5794 } else if (uriExtras != null) {
5795 uriExtras.putAll(extras);
5796 extras = uriExtras;
5797 }
5798 intent.replaceExtras(extras);
5799 hasIntentInfo = true;
5800 }
5801
5802 if (!hasIntentInfo) throw new IllegalArgumentException("No intent supplied");
5803 return intent;
5804 }
5805
5806 /** @hide */
5807 public static void printIntentArgsHelp(PrintWriter pw, String prefix) {
5808 final String[] lines = new String[] {
5809 "<INTENT> specifications include these flags and arguments:",
5810 " [-a <ACTION>] [-d <DATA_URI>] [-t <MIME_TYPE>]",
5811 " [-c <CATEGORY> [-c <CATEGORY>] ...]",
5812 " [-e|--es <EXTRA_KEY> <EXTRA_STRING_VALUE> ...]",
5813 " [--esn <EXTRA_KEY> ...]",
5814 " [--ez <EXTRA_KEY> <EXTRA_BOOLEAN_VALUE> ...]",
5815 " [--ei <EXTRA_KEY> <EXTRA_INT_VALUE> ...]",
5816 " [--el <EXTRA_KEY> <EXTRA_LONG_VALUE> ...]",
5817 " [--ef <EXTRA_KEY> <EXTRA_FLOAT_VALUE> ...]",
5818 " [--eu <EXTRA_KEY> <EXTRA_URI_VALUE> ...]",
5819 " [--ecn <EXTRA_KEY> <EXTRA_COMPONENT_NAME_VALUE>]",
5820 " [--eia <EXTRA_KEY> <EXTRA_INT_VALUE>[,<EXTRA_INT_VALUE...]]",
5821 " (mutiple extras passed as Integer[])",
5822 " [--eial <EXTRA_KEY> <EXTRA_INT_VALUE>[,<EXTRA_INT_VALUE...]]",
5823 " (mutiple extras passed as List<Integer>)",
5824 " [--ela <EXTRA_KEY> <EXTRA_LONG_VALUE>[,<EXTRA_LONG_VALUE...]]",
5825 " (mutiple extras passed as Long[])",
5826 " [--elal <EXTRA_KEY> <EXTRA_LONG_VALUE>[,<EXTRA_LONG_VALUE...]]",
5827 " (mutiple extras passed as List<Long>)",
5828 " [--efa <EXTRA_KEY> <EXTRA_FLOAT_VALUE>[,<EXTRA_FLOAT_VALUE...]]",
5829 " (mutiple extras passed as Float[])",
5830 " [--efal <EXTRA_KEY> <EXTRA_FLOAT_VALUE>[,<EXTRA_FLOAT_VALUE...]]",
5831 " (mutiple extras passed as List<Float>)",
5832 " [--esa <EXTRA_KEY> <EXTRA_STRING_VALUE>[,<EXTRA_STRING_VALUE...]]",
5833 " (mutiple extras passed as String[]; to embed a comma into a string,",
5834 " escape it using \"\\,\")",
5835 " [--esal <EXTRA_KEY> <EXTRA_STRING_VALUE>[,<EXTRA_STRING_VALUE...]]",
5836 " (mutiple extras passed as List<String>; to embed a comma into a string,",
5837 " escape it using \"\\,\")",
Felipe Leme3cb48cd2016-01-27 08:39:09 -08005838 " [--f <FLAG>]",
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08005839 " [--grant-read-uri-permission] [--grant-write-uri-permission]",
5840 " [--grant-persistable-uri-permission] [--grant-prefix-uri-permission]",
5841 " [--debug-log-resolution] [--exclude-stopped-packages]",
5842 " [--include-stopped-packages]",
5843 " [--activity-brought-to-front] [--activity-clear-top]",
5844 " [--activity-clear-when-task-reset] [--activity-exclude-from-recents]",
5845 " [--activity-launched-from-history] [--activity-multiple-task]",
5846 " [--activity-no-animation] [--activity-no-history]",
5847 " [--activity-no-user-action] [--activity-previous-is-top]",
5848 " [--activity-reorder-to-front] [--activity-reset-task-if-needed]",
5849 " [--activity-single-top] [--activity-clear-task]",
5850 " [--activity-task-on-home]",
5851 " [--receiver-registered-only] [--receiver-replace-pending]",
Felipe Leme3cb48cd2016-01-27 08:39:09 -08005852 " [--receiver-foreground]",
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08005853 " [--selector]",
5854 " [<URI> | <PACKAGE> | <COMPONENT>]"
5855 };
5856 for (String line : lines) {
5857 pw.print(prefix);
5858 pw.println(line);
5859 }
5860 }
5861
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005862 /**
5863 * Retrieve the general action to be performed, such as
5864 * {@link #ACTION_VIEW}. The action describes the general way the rest of
5865 * the information in the intent should be interpreted -- most importantly,
5866 * what to do with the data returned by {@link #getData}.
5867 *
5868 * @return The action of this intent or null if none is specified.
5869 *
5870 * @see #setAction
5871 */
5872 public String getAction() {
5873 return mAction;
5874 }
5875
5876 /**
5877 * Retrieve data this intent is operating on. This URI specifies the name
5878 * of the data; often it uses the content: scheme, specifying data in a
5879 * content provider. Other schemes may be handled by specific activities,
5880 * such as http: by the web browser.
5881 *
5882 * @return The URI of the data this intent is targeting or null.
5883 *
5884 * @see #getScheme
5885 * @see #setData
5886 */
5887 public Uri getData() {
5888 return mData;
5889 }
5890
5891 /**
5892 * The same as {@link #getData()}, but returns the URI as an encoded
5893 * String.
5894 */
5895 public String getDataString() {
5896 return mData != null ? mData.toString() : null;
5897 }
5898
5899 /**
5900 * Return the scheme portion of the intent's data. If the data is null or
5901 * does not include a scheme, null is returned. Otherwise, the scheme
5902 * prefix without the final ':' is returned, i.e. "http".
5903 *
5904 * <p>This is the same as calling getData().getScheme() (and checking for
5905 * null data).
5906 *
5907 * @return The scheme of this intent.
5908 *
5909 * @see #getData
5910 */
5911 public String getScheme() {
5912 return mData != null ? mData.getScheme() : null;
5913 }
5914
5915 /**
5916 * Retrieve any explicit MIME type included in the intent. This is usually
5917 * null, as the type is determined by the intent data.
5918 *
5919 * @return If a type was manually set, it is returned; else null is
5920 * returned.
5921 *
5922 * @see #resolveType(ContentResolver)
5923 * @see #setType
5924 */
5925 public String getType() {
5926 return mType;
5927 }
5928
5929 /**
5930 * Return the MIME data type of this intent. If the type field is
5931 * explicitly set, that is simply returned. Otherwise, if the data is set,
5932 * the type of that data is returned. If neither fields are set, a null is
5933 * returned.
5934 *
5935 * @return The MIME type of this intent.
5936 *
5937 * @see #getType
5938 * @see #resolveType(ContentResolver)
5939 */
5940 public String resolveType(Context context) {
5941 return resolveType(context.getContentResolver());
5942 }
5943
5944 /**
5945 * Return the MIME data type of this intent. If the type field is
5946 * explicitly set, that is simply returned. Otherwise, if the data is set,
5947 * the type of that data is returned. If neither fields are set, a null is
5948 * returned.
5949 *
5950 * @param resolver A ContentResolver that can be used to determine the MIME
5951 * type of the intent's data.
5952 *
5953 * @return The MIME type of this intent.
5954 *
5955 * @see #getType
5956 * @see #resolveType(Context)
5957 */
5958 public String resolveType(ContentResolver resolver) {
5959 if (mType != null) {
5960 return mType;
5961 }
5962 if (mData != null) {
5963 if ("content".equals(mData.getScheme())) {
5964 return resolver.getType(mData);
5965 }
5966 }
5967 return null;
5968 }
5969
5970 /**
5971 * Return the MIME data type of this intent, only if it will be needed for
5972 * intent resolution. This is not generally useful for application code;
5973 * it is used by the frameworks for communicating with back-end system
5974 * services.
5975 *
5976 * @param resolver A ContentResolver that can be used to determine the MIME
5977 * type of the intent's data.
5978 *
5979 * @return The MIME type of this intent, or null if it is unknown or not
5980 * needed.
5981 */
5982 public String resolveTypeIfNeeded(ContentResolver resolver) {
5983 if (mComponent != null) {
5984 return mType;
5985 }
5986 return resolveType(resolver);
5987 }
5988
5989 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09005990 * Check if a category exists in the intent.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005991 *
5992 * @param category The category to check.
5993 *
5994 * @return boolean True if the intent contains the category, else false.
5995 *
5996 * @see #getCategories
5997 * @see #addCategory
5998 */
5999 public boolean hasCategory(String category) {
6000 return mCategories != null && mCategories.contains(category);
6001 }
6002
6003 /**
6004 * Return the set of all categories in the intent. If there are no categories,
6005 * returns NULL.
6006 *
Dianne Hackbornf5b86712011-12-05 17:42:41 -08006007 * @return The set of categories you can examine. Do not modify!
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006008 *
6009 * @see #hasCategory
6010 * @see #addCategory
6011 */
6012 public Set<String> getCategories() {
6013 return mCategories;
6014 }
6015
6016 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08006017 * Return the specific selector associated with this Intent. If there is
6018 * none, returns null. See {@link #setSelector} for more information.
6019 *
6020 * @see #setSelector
6021 */
6022 public Intent getSelector() {
6023 return mSelector;
6024 }
6025
6026 /**
Dianne Hackborn21c241e2012-03-08 13:57:23 -08006027 * Return the {@link ClipData} associated with this Intent. If there is
6028 * none, returns null. See {@link #setClipData} for more information.
6029 *
John Spurlock125d1332013-11-25 11:58:37 -05006030 * @see #setClipData
Dianne Hackborn21c241e2012-03-08 13:57:23 -08006031 */
6032 public ClipData getClipData() {
6033 return mClipData;
6034 }
6035
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01006036 /** @hide */
6037 public int getContentUserHint() {
6038 return mContentUserHint;
6039 }
6040
Dianne Hackborn21c241e2012-03-08 13:57:23 -08006041 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006042 * Sets the ClassLoader that will be used when unmarshalling
6043 * any Parcelable values from the extras of this Intent.
6044 *
6045 * @param loader a ClassLoader, or null to use the default loader
6046 * at the time of unmarshalling.
6047 */
6048 public void setExtrasClassLoader(ClassLoader loader) {
6049 if (mExtras != null) {
6050 mExtras.setClassLoader(loader);
6051 }
6052 }
6053
6054 /**
6055 * Returns true if an extra value is associated with the given name.
6056 * @param name the extra's name
6057 * @return true if the given extra is present.
6058 */
6059 public boolean hasExtra(String name) {
6060 return mExtras != null && mExtras.containsKey(name);
6061 }
6062
6063 /**
6064 * Returns true if the Intent's extras contain a parcelled file descriptor.
6065 * @return true if the Intent contains a parcelled file descriptor.
6066 */
6067 public boolean hasFileDescriptors() {
6068 return mExtras != null && mExtras.hasFileDescriptors();
6069 }
The Android Open Source Project10592532009-03-18 17:39:46 -07006070
Jeff Sharkeyd136e512016-03-09 22:30:56 -07006071 /** {@hide} */
Dianne Hackborn9ecebbf2011-09-28 23:19:47 -04006072 public void setAllowFds(boolean allowFds) {
6073 if (mExtras != null) {
6074 mExtras.setAllowFds(allowFds);
6075 }
6076 }
6077
Jeff Sharkeyd136e512016-03-09 22:30:56 -07006078 /** {@hide} */
6079 public void setDefusable(boolean defusable) {
6080 if (mExtras != null) {
6081 mExtras.setDefusable(defusable);
6082 }
6083 }
6084
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006085 /**
6086 * Retrieve extended data from the intent.
6087 *
6088 * @param name The name of the desired item.
6089 *
6090 * @return the value of an item that previously added with putExtra()
6091 * or null if none was found.
6092 *
6093 * @deprecated
6094 * @hide
6095 */
6096 @Deprecated
6097 public Object getExtra(String name) {
6098 return getExtra(name, null);
6099 }
6100
6101 /**
6102 * Retrieve extended data from the intent.
6103 *
6104 * @param name The name of the desired item.
6105 * @param defaultValue the value to be returned if no value of the desired
6106 * type is stored with the given name.
6107 *
6108 * @return the value of an item that previously added with putExtra()
6109 * or the default value if none was found.
6110 *
6111 * @see #putExtra(String, boolean)
6112 */
6113 public boolean getBooleanExtra(String name, boolean defaultValue) {
6114 return mExtras == null ? defaultValue :
6115 mExtras.getBoolean(name, defaultValue);
6116 }
6117
6118 /**
6119 * Retrieve extended data from the intent.
6120 *
6121 * @param name The name of the desired item.
6122 * @param defaultValue the value to be returned if no value of the desired
6123 * type is stored with the given name.
6124 *
6125 * @return the value of an item that previously added with putExtra()
6126 * or the default value if none was found.
6127 *
6128 * @see #putExtra(String, byte)
6129 */
6130 public byte getByteExtra(String name, byte defaultValue) {
6131 return mExtras == null ? defaultValue :
6132 mExtras.getByte(name, defaultValue);
6133 }
6134
6135 /**
6136 * Retrieve extended data from the intent.
6137 *
6138 * @param name The name of the desired item.
6139 * @param defaultValue the value to be returned if no value of the desired
6140 * type is stored with the given name.
6141 *
6142 * @return the value of an item that previously added with putExtra()
6143 * or the default value if none was found.
6144 *
6145 * @see #putExtra(String, short)
6146 */
6147 public short getShortExtra(String name, short defaultValue) {
6148 return mExtras == null ? defaultValue :
6149 mExtras.getShort(name, defaultValue);
6150 }
6151
6152 /**
6153 * Retrieve extended data from the intent.
6154 *
6155 * @param name The name of the desired item.
6156 * @param defaultValue the value to be returned if no value of the desired
6157 * type is stored with the given name.
6158 *
6159 * @return the value of an item that previously added with putExtra()
6160 * or the default value if none was found.
6161 *
6162 * @see #putExtra(String, char)
6163 */
6164 public char getCharExtra(String name, char defaultValue) {
6165 return mExtras == null ? defaultValue :
6166 mExtras.getChar(name, defaultValue);
6167 }
6168
6169 /**
6170 * Retrieve extended data from the intent.
6171 *
6172 * @param name The name of the desired item.
6173 * @param defaultValue the value to be returned if no value of the desired
6174 * type is stored with the given name.
6175 *
6176 * @return the value of an item that previously added with putExtra()
6177 * or the default value if none was found.
6178 *
6179 * @see #putExtra(String, int)
6180 */
6181 public int getIntExtra(String name, int defaultValue) {
6182 return mExtras == null ? defaultValue :
6183 mExtras.getInt(name, defaultValue);
6184 }
6185
6186 /**
6187 * Retrieve extended data from the intent.
6188 *
6189 * @param name The name of the desired item.
6190 * @param defaultValue the value to be returned if no value of the desired
6191 * type is stored with the given name.
6192 *
6193 * @return the value of an item that previously added with putExtra()
6194 * or the default value if none was found.
6195 *
6196 * @see #putExtra(String, long)
6197 */
6198 public long getLongExtra(String name, long defaultValue) {
6199 return mExtras == null ? defaultValue :
6200 mExtras.getLong(name, defaultValue);
6201 }
6202
6203 /**
6204 * Retrieve extended data from the intent.
6205 *
6206 * @param name The name of the desired item.
6207 * @param defaultValue the value to be returned if no value of the desired
6208 * type is stored with the given name.
6209 *
6210 * @return the value of an item that previously added with putExtra(),
6211 * or the default value if no such item is present
6212 *
6213 * @see #putExtra(String, float)
6214 */
6215 public float getFloatExtra(String name, float defaultValue) {
6216 return mExtras == null ? defaultValue :
6217 mExtras.getFloat(name, defaultValue);
6218 }
6219
6220 /**
6221 * Retrieve extended data from the intent.
6222 *
6223 * @param name The name of the desired item.
6224 * @param defaultValue the value to be returned if no value of the desired
6225 * type is stored with the given name.
6226 *
6227 * @return the value of an item that previously added with putExtra()
6228 * or the default value if none was found.
6229 *
6230 * @see #putExtra(String, double)
6231 */
6232 public double getDoubleExtra(String name, double defaultValue) {
6233 return mExtras == null ? defaultValue :
6234 mExtras.getDouble(name, defaultValue);
6235 }
6236
6237 /**
6238 * Retrieve extended data from the intent.
6239 *
6240 * @param name The name of the desired item.
6241 *
6242 * @return the value of an item that previously added with putExtra()
6243 * or null if no String value was found.
6244 *
6245 * @see #putExtra(String, String)
6246 */
6247 public String getStringExtra(String name) {
6248 return mExtras == null ? null : mExtras.getString(name);
6249 }
6250
6251 /**
6252 * Retrieve extended data from the intent.
6253 *
6254 * @param name The name of the desired item.
6255 *
6256 * @return the value of an item that previously added with putExtra()
6257 * or null if no CharSequence value was found.
6258 *
6259 * @see #putExtra(String, CharSequence)
6260 */
6261 public CharSequence getCharSequenceExtra(String name) {
6262 return mExtras == null ? null : mExtras.getCharSequence(name);
6263 }
6264
6265 /**
6266 * Retrieve extended data from the intent.
6267 *
6268 * @param name The name of the desired item.
6269 *
6270 * @return the value of an item that previously added with putExtra()
6271 * or null if no Parcelable value was found.
6272 *
6273 * @see #putExtra(String, Parcelable)
6274 */
6275 public <T extends Parcelable> T getParcelableExtra(String name) {
6276 return mExtras == null ? null : mExtras.<T>getParcelable(name);
6277 }
6278
6279 /**
6280 * Retrieve extended data from the intent.
6281 *
6282 * @param name The name of the desired item.
6283 *
6284 * @return the value of an item that previously added with putExtra()
6285 * or null if no Parcelable[] value was found.
6286 *
6287 * @see #putExtra(String, Parcelable[])
6288 */
6289 public Parcelable[] getParcelableArrayExtra(String name) {
6290 return mExtras == null ? null : mExtras.getParcelableArray(name);
6291 }
6292
6293 /**
6294 * Retrieve extended data from the intent.
6295 *
6296 * @param name The name of the desired item.
6297 *
6298 * @return the value of an item that previously added with putExtra()
6299 * or null if no ArrayList<Parcelable> value was found.
6300 *
6301 * @see #putParcelableArrayListExtra(String, ArrayList)
6302 */
6303 public <T extends Parcelable> ArrayList<T> getParcelableArrayListExtra(String name) {
6304 return mExtras == null ? null : mExtras.<T>getParcelableArrayList(name);
6305 }
6306
6307 /**
6308 * Retrieve extended data from the intent.
6309 *
6310 * @param name The name of the desired item.
6311 *
6312 * @return the value of an item that previously added with putExtra()
6313 * or null if no Serializable value was found.
6314 *
6315 * @see #putExtra(String, Serializable)
6316 */
6317 public Serializable getSerializableExtra(String name) {
6318 return mExtras == null ? null : mExtras.getSerializable(name);
6319 }
6320
6321 /**
6322 * Retrieve extended data from the intent.
6323 *
6324 * @param name The name of the desired item.
6325 *
6326 * @return the value of an item that previously added with putExtra()
6327 * or null if no ArrayList<Integer> value was found.
6328 *
6329 * @see #putIntegerArrayListExtra(String, ArrayList)
6330 */
6331 public ArrayList<Integer> getIntegerArrayListExtra(String name) {
6332 return mExtras == null ? null : mExtras.getIntegerArrayList(name);
6333 }
6334
6335 /**
6336 * Retrieve extended data from the intent.
6337 *
6338 * @param name The name of the desired item.
6339 *
6340 * @return the value of an item that previously added with putExtra()
6341 * or null if no ArrayList<String> value was found.
6342 *
6343 * @see #putStringArrayListExtra(String, ArrayList)
6344 */
6345 public ArrayList<String> getStringArrayListExtra(String name) {
6346 return mExtras == null ? null : mExtras.getStringArrayList(name);
6347 }
6348
6349 /**
6350 * Retrieve extended data from the intent.
6351 *
6352 * @param name The name of the desired item.
6353 *
6354 * @return the value of an item that previously added with putExtra()
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00006355 * or null if no ArrayList<CharSequence> value was found.
6356 *
6357 * @see #putCharSequenceArrayListExtra(String, ArrayList)
6358 */
6359 public ArrayList<CharSequence> getCharSequenceArrayListExtra(String name) {
6360 return mExtras == null ? null : mExtras.getCharSequenceArrayList(name);
6361 }
6362
6363 /**
6364 * Retrieve extended data from the intent.
6365 *
6366 * @param name The name of the desired item.
6367 *
6368 * @return the value of an item that previously added with putExtra()
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006369 * or null if no boolean array value was found.
6370 *
6371 * @see #putExtra(String, boolean[])
6372 */
6373 public boolean[] getBooleanArrayExtra(String name) {
6374 return mExtras == null ? null : mExtras.getBooleanArray(name);
6375 }
6376
6377 /**
6378 * Retrieve extended data from the intent.
6379 *
6380 * @param name The name of the desired item.
6381 *
6382 * @return the value of an item that previously added with putExtra()
6383 * or null if no byte array value was found.
6384 *
6385 * @see #putExtra(String, byte[])
6386 */
6387 public byte[] getByteArrayExtra(String name) {
6388 return mExtras == null ? null : mExtras.getByteArray(name);
6389 }
6390
6391 /**
6392 * Retrieve extended data from the intent.
6393 *
6394 * @param name The name of the desired item.
6395 *
6396 * @return the value of an item that previously added with putExtra()
6397 * or null if no short array value was found.
6398 *
6399 * @see #putExtra(String, short[])
6400 */
6401 public short[] getShortArrayExtra(String name) {
6402 return mExtras == null ? null : mExtras.getShortArray(name);
6403 }
6404
6405 /**
6406 * Retrieve extended data from the intent.
6407 *
6408 * @param name The name of the desired item.
6409 *
6410 * @return the value of an item that previously added with putExtra()
6411 * or null if no char array value was found.
6412 *
6413 * @see #putExtra(String, char[])
6414 */
6415 public char[] getCharArrayExtra(String name) {
6416 return mExtras == null ? null : mExtras.getCharArray(name);
6417 }
6418
6419 /**
6420 * Retrieve extended data from the intent.
6421 *
6422 * @param name The name of the desired item.
6423 *
6424 * @return the value of an item that previously added with putExtra()
6425 * or null if no int array value was found.
6426 *
6427 * @see #putExtra(String, int[])
6428 */
6429 public int[] getIntArrayExtra(String name) {
6430 return mExtras == null ? null : mExtras.getIntArray(name);
6431 }
6432
6433 /**
6434 * Retrieve extended data from the intent.
6435 *
6436 * @param name The name of the desired item.
6437 *
6438 * @return the value of an item that previously added with putExtra()
6439 * or null if no long array value was found.
6440 *
6441 * @see #putExtra(String, long[])
6442 */
6443 public long[] getLongArrayExtra(String name) {
6444 return mExtras == null ? null : mExtras.getLongArray(name);
6445 }
6446
6447 /**
6448 * Retrieve extended data from the intent.
6449 *
6450 * @param name The name of the desired item.
6451 *
6452 * @return the value of an item that previously added with putExtra()
6453 * or null if no float array value was found.
6454 *
6455 * @see #putExtra(String, float[])
6456 */
6457 public float[] getFloatArrayExtra(String name) {
6458 return mExtras == null ? null : mExtras.getFloatArray(name);
6459 }
6460
6461 /**
6462 * Retrieve extended data from the intent.
6463 *
6464 * @param name The name of the desired item.
6465 *
6466 * @return the value of an item that previously added with putExtra()
6467 * or null if no double array value was found.
6468 *
6469 * @see #putExtra(String, double[])
6470 */
6471 public double[] getDoubleArrayExtra(String name) {
6472 return mExtras == null ? null : mExtras.getDoubleArray(name);
6473 }
6474
6475 /**
6476 * Retrieve extended data from the intent.
6477 *
6478 * @param name The name of the desired item.
6479 *
6480 * @return the value of an item that previously added with putExtra()
6481 * or null if no String array value was found.
6482 *
6483 * @see #putExtra(String, String[])
6484 */
6485 public String[] getStringArrayExtra(String name) {
6486 return mExtras == null ? null : mExtras.getStringArray(name);
6487 }
6488
6489 /**
6490 * Retrieve extended data from the intent.
6491 *
6492 * @param name The name of the desired item.
6493 *
6494 * @return the value of an item that previously added with putExtra()
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00006495 * or null if no CharSequence array value was found.
6496 *
6497 * @see #putExtra(String, CharSequence[])
6498 */
6499 public CharSequence[] getCharSequenceArrayExtra(String name) {
6500 return mExtras == null ? null : mExtras.getCharSequenceArray(name);
6501 }
6502
6503 /**
6504 * Retrieve extended data from the intent.
6505 *
6506 * @param name The name of the desired item.
6507 *
6508 * @return the value of an item that previously added with putExtra()
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006509 * or null if no Bundle value was found.
6510 *
6511 * @see #putExtra(String, Bundle)
6512 */
6513 public Bundle getBundleExtra(String name) {
6514 return mExtras == null ? null : mExtras.getBundle(name);
6515 }
6516
6517 /**
6518 * Retrieve extended data from the intent.
6519 *
6520 * @param name The name of the desired item.
6521 *
6522 * @return the value of an item that previously added with putExtra()
6523 * or null if no IBinder value was found.
6524 *
6525 * @see #putExtra(String, IBinder)
6526 *
6527 * @deprecated
6528 * @hide
6529 */
6530 @Deprecated
6531 public IBinder getIBinderExtra(String name) {
6532 return mExtras == null ? null : mExtras.getIBinder(name);
6533 }
6534
6535 /**
6536 * Retrieve extended data from the intent.
6537 *
6538 * @param name The name of the desired item.
6539 * @param defaultValue The default value to return in case no item is
6540 * associated with the key 'name'
6541 *
6542 * @return the value of an item that previously added with putExtra()
6543 * or defaultValue if none was found.
6544 *
6545 * @see #putExtra
6546 *
6547 * @deprecated
6548 * @hide
6549 */
6550 @Deprecated
6551 public Object getExtra(String name, Object defaultValue) {
6552 Object result = defaultValue;
6553 if (mExtras != null) {
6554 Object result2 = mExtras.get(name);
6555 if (result2 != null) {
6556 result = result2;
6557 }
6558 }
6559
6560 return result;
6561 }
6562
6563 /**
6564 * Retrieves a map of extended data from the intent.
6565 *
6566 * @return the map of all extras previously added with putExtra(),
6567 * or null if none have been added.
6568 */
6569 public Bundle getExtras() {
6570 return (mExtras != null)
6571 ? new Bundle(mExtras)
6572 : null;
6573 }
6574
6575 /**
Dianne Hackborna83ce1d2015-03-11 15:16:13 -07006576 * Filter extras to only basic types.
6577 * @hide
6578 */
6579 public void removeUnsafeExtras() {
6580 if (mExtras != null) {
6581 mExtras.filterValues();
6582 }
6583 }
6584
6585 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006586 * Retrieve any special flags associated with this intent. You will
6587 * normally just set them with {@link #setFlags} and let the system
6588 * take the appropriate action with them.
6589 *
6590 * @return int The currently set flags.
6591 *
6592 * @see #setFlags
6593 */
6594 public int getFlags() {
6595 return mFlags;
6596 }
6597
Dianne Hackborne7f97212011-02-24 14:40:20 -08006598 /** @hide */
6599 public boolean isExcludingStopped() {
6600 return (mFlags&(FLAG_EXCLUDE_STOPPED_PACKAGES|FLAG_INCLUDE_STOPPED_PACKAGES))
6601 == FLAG_EXCLUDE_STOPPED_PACKAGES;
6602 }
6603
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006604 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006605 * Retrieve the application package name this Intent is limited to. When
6606 * resolving an Intent, if non-null this limits the resolution to only
6607 * components in the given application package.
6608 *
6609 * @return The name of the application package for the Intent.
6610 *
6611 * @see #resolveActivity
6612 * @see #setPackage
6613 */
6614 public String getPackage() {
6615 return mPackage;
6616 }
6617
6618 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006619 * Retrieve the concrete component associated with the intent. When receiving
6620 * an intent, this is the component that was found to best handle it (that is,
6621 * yourself) and will always be non-null; in all other cases it will be
6622 * null unless explicitly set.
6623 *
6624 * @return The name of the application component to handle the intent.
6625 *
6626 * @see #resolveActivity
6627 * @see #setComponent
6628 */
6629 public ComponentName getComponent() {
6630 return mComponent;
6631 }
6632
6633 /**
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08006634 * Get the bounds of the sender of this intent, in screen coordinates. This can be
6635 * used as a hint to the receiver for animations and the like. Null means that there
6636 * is no source bounds.
6637 */
6638 public Rect getSourceBounds() {
6639 return mSourceBounds;
6640 }
6641
6642 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006643 * Return the Activity component that should be used to handle this intent.
6644 * The appropriate component is determined based on the information in the
6645 * intent, evaluated as follows:
6646 *
6647 * <p>If {@link #getComponent} returns an explicit class, that is returned
6648 * without any further consideration.
6649 *
6650 * <p>The activity must handle the {@link Intent#CATEGORY_DEFAULT} Intent
6651 * category to be considered.
6652 *
6653 * <p>If {@link #getAction} is non-NULL, the activity must handle this
6654 * action.
6655 *
6656 * <p>If {@link #resolveType} returns non-NULL, the activity must handle
6657 * this type.
6658 *
6659 * <p>If {@link #addCategory} has added any categories, the activity must
6660 * handle ALL of the categories specified.
6661 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006662 * <p>If {@link #getPackage} is non-NULL, only activity components in
6663 * that application package will be considered.
6664 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006665 * <p>If there are no activities that satisfy all of these conditions, a
6666 * null string is returned.
6667 *
6668 * <p>If multiple activities are found to satisfy the intent, the one with
6669 * the highest priority will be used. If there are multiple activities
6670 * with the same priority, the system will either pick the best activity
6671 * based on user preference, or resolve to a system class that will allow
6672 * the user to pick an activity and forward from there.
6673 *
6674 * <p>This method is implemented simply by calling
6675 * {@link PackageManager#resolveActivity} with the "defaultOnly" parameter
6676 * true.</p>
6677 * <p> This API is called for you as part of starting an activity from an
6678 * intent. You do not normally need to call it yourself.</p>
6679 *
6680 * @param pm The package manager with which to resolve the Intent.
6681 *
6682 * @return Name of the component implementing an activity that can
6683 * display the intent.
6684 *
6685 * @see #setComponent
6686 * @see #getComponent
6687 * @see #resolveActivityInfo
6688 */
6689 public ComponentName resolveActivity(PackageManager pm) {
6690 if (mComponent != null) {
6691 return mComponent;
6692 }
6693
6694 ResolveInfo info = pm.resolveActivity(
6695 this, PackageManager.MATCH_DEFAULT_ONLY);
6696 if (info != null) {
6697 return new ComponentName(
6698 info.activityInfo.applicationInfo.packageName,
6699 info.activityInfo.name);
6700 }
6701
6702 return null;
6703 }
6704
6705 /**
6706 * Resolve the Intent into an {@link ActivityInfo}
6707 * describing the activity that should execute the intent. Resolution
6708 * follows the same rules as described for {@link #resolveActivity}, but
6709 * you get back the completely information about the resolved activity
6710 * instead of just its class name.
6711 *
6712 * @param pm The package manager with which to resolve the Intent.
6713 * @param flags Addition information to retrieve as per
6714 * {@link PackageManager#getActivityInfo(ComponentName, int)
6715 * PackageManager.getActivityInfo()}.
6716 *
6717 * @return PackageManager.ActivityInfo
6718 *
6719 * @see #resolveActivity
6720 */
6721 public ActivityInfo resolveActivityInfo(PackageManager pm, int flags) {
6722 ActivityInfo ai = null;
6723 if (mComponent != null) {
6724 try {
6725 ai = pm.getActivityInfo(mComponent, flags);
6726 } catch (PackageManager.NameNotFoundException e) {
6727 // ignore
6728 }
6729 } else {
6730 ResolveInfo info = pm.resolveActivity(
Dianne Hackborn9bfb7072009-09-22 11:37:40 -07006731 this, PackageManager.MATCH_DEFAULT_ONLY | flags);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006732 if (info != null) {
6733 ai = info.activityInfo;
6734 }
6735 }
6736
6737 return ai;
6738 }
6739
6740 /**
Dianne Hackborn221ea892013-08-04 16:50:16 -07006741 * Special function for use by the system to resolve service
6742 * intents to system apps. Throws an exception if there are
6743 * multiple potential matches to the Intent. Returns null if
6744 * there are no matches.
6745 * @hide
6746 */
6747 public ComponentName resolveSystemService(PackageManager pm, int flags) {
6748 if (mComponent != null) {
6749 return mComponent;
6750 }
6751
6752 List<ResolveInfo> results = pm.queryIntentServices(this, flags);
6753 if (results == null) {
6754 return null;
6755 }
6756 ComponentName comp = null;
6757 for (int i=0; i<results.size(); i++) {
6758 ResolveInfo ri = results.get(i);
6759 if ((ri.serviceInfo.applicationInfo.flags&ApplicationInfo.FLAG_SYSTEM) == 0) {
6760 continue;
6761 }
6762 ComponentName foundComp = new ComponentName(ri.serviceInfo.applicationInfo.packageName,
6763 ri.serviceInfo.name);
6764 if (comp != null) {
6765 throw new IllegalStateException("Multiple system services handle " + this
6766 + ": " + comp + ", " + foundComp);
6767 }
6768 comp = foundComp;
6769 }
6770 return comp;
6771 }
6772
6773 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006774 * Set the general action to be performed.
6775 *
6776 * @param action An action name, such as ACTION_VIEW. Application-specific
6777 * actions should be prefixed with the vendor's package name.
6778 *
6779 * @return Returns the same Intent object, for chaining multiple calls
6780 * into a single statement.
6781 *
6782 * @see #getAction
6783 */
6784 public Intent setAction(String action) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08006785 mAction = action != null ? action.intern() : null;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006786 return this;
6787 }
6788
6789 /**
6790 * Set the data this intent is operating on. This method automatically
Nick Pellyccae4122012-01-09 14:12:58 -08006791 * clears any type that was previously set by {@link #setType} or
6792 * {@link #setTypeAndNormalize}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006793 *
Nick Pellyccae4122012-01-09 14:12:58 -08006794 * <p><em>Note: scheme matching in the Android framework is
6795 * case-sensitive, unlike the formal RFC. As a result,
6796 * you should always write your Uri with a lower case scheme,
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04006797 * or use {@link Uri#normalizeScheme} or
Nick Pellyccae4122012-01-09 14:12:58 -08006798 * {@link #setDataAndNormalize}
6799 * to ensure that the scheme is converted to lower case.</em>
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07006800 *
Nick Pellyccae4122012-01-09 14:12:58 -08006801 * @param data The Uri of the data this intent is now targeting.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006802 *
6803 * @return Returns the same Intent object, for chaining multiple calls
6804 * into a single statement.
6805 *
6806 * @see #getData
Nick Pellyccae4122012-01-09 14:12:58 -08006807 * @see #setDataAndNormalize
Dianne Hackborn221ea892013-08-04 16:50:16 -07006808 * @see android.net.Uri#normalizeScheme()
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006809 */
6810 public Intent setData(Uri data) {
6811 mData = data;
6812 mType = null;
6813 return this;
6814 }
6815
6816 /**
Nick Pellyccae4122012-01-09 14:12:58 -08006817 * Normalize and set the data this intent is operating on.
6818 *
6819 * <p>This method automatically clears any type that was
6820 * previously set (for example, by {@link #setType}).
6821 *
6822 * <p>The data Uri is normalized using
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04006823 * {@link android.net.Uri#normalizeScheme} before it is set,
Nick Pellyccae4122012-01-09 14:12:58 -08006824 * so really this is just a convenience method for
6825 * <pre>
6826 * setData(data.normalize())
6827 * </pre>
6828 *
6829 * @param data The Uri of the data this intent is now targeting.
6830 *
6831 * @return Returns the same Intent object, for chaining multiple calls
6832 * into a single statement.
6833 *
6834 * @see #getData
6835 * @see #setType
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04006836 * @see android.net.Uri#normalizeScheme
Nick Pellyccae4122012-01-09 14:12:58 -08006837 */
6838 public Intent setDataAndNormalize(Uri data) {
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04006839 return setData(data.normalizeScheme());
Nick Pellyccae4122012-01-09 14:12:58 -08006840 }
6841
6842 /**
6843 * Set an explicit MIME data type.
6844 *
6845 * <p>This is used to create intents that only specify a type and not data,
6846 * for example to indicate the type of data to return.
6847 *
6848 * <p>This method automatically clears any data that was
6849 * previously set (for example by {@link #setData}).
Romain Guy4969af72009-06-17 10:53:19 -07006850 *
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07006851 * <p><em>Note: MIME type matching in the Android framework is
6852 * case-sensitive, unlike formal RFC MIME types. As a result,
6853 * you should always write your MIME types with lower case letters,
Nick Pellyccae4122012-01-09 14:12:58 -08006854 * or use {@link #normalizeMimeType} or {@link #setTypeAndNormalize}
6855 * to ensure that it is converted to lower case.</em>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006856 *
6857 * @param type The MIME type of the data being handled by this intent.
6858 *
6859 * @return Returns the same Intent object, for chaining multiple calls
6860 * into a single statement.
6861 *
6862 * @see #getType
Nick Pellyccae4122012-01-09 14:12:58 -08006863 * @see #setTypeAndNormalize
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006864 * @see #setDataAndType
Nick Pellyccae4122012-01-09 14:12:58 -08006865 * @see #normalizeMimeType
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006866 */
6867 public Intent setType(String type) {
6868 mData = null;
6869 mType = type;
6870 return this;
6871 }
6872
6873 /**
Nick Pellyccae4122012-01-09 14:12:58 -08006874 * Normalize and set an explicit MIME data type.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006875 *
Nick Pellyccae4122012-01-09 14:12:58 -08006876 * <p>This is used to create intents that only specify a type and not data,
6877 * for example to indicate the type of data to return.
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07006878 *
Nick Pellyccae4122012-01-09 14:12:58 -08006879 * <p>This method automatically clears any data that was
6880 * previously set (for example by {@link #setData}).
6881 *
6882 * <p>The MIME type is normalized using
6883 * {@link #normalizeMimeType} before it is set,
6884 * so really this is just a convenience method for
6885 * <pre>
6886 * setType(Intent.normalizeMimeType(type))
6887 * </pre>
6888 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006889 * @param type The MIME type of the data being handled by this intent.
6890 *
6891 * @return Returns the same Intent object, for chaining multiple calls
6892 * into a single statement.
6893 *
Nick Pellyccae4122012-01-09 14:12:58 -08006894 * @see #getType
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006895 * @see #setData
Nick Pellyccae4122012-01-09 14:12:58 -08006896 * @see #normalizeMimeType
6897 */
6898 public Intent setTypeAndNormalize(String type) {
6899 return setType(normalizeMimeType(type));
6900 }
6901
6902 /**
6903 * (Usually optional) Set the data for the intent along with an explicit
6904 * MIME data type. This method should very rarely be used -- it allows you
6905 * to override the MIME type that would ordinarily be inferred from the
6906 * data with your own type given here.
6907 *
6908 * <p><em>Note: MIME type and Uri scheme matching in the
6909 * Android framework is case-sensitive, unlike the formal RFC definitions.
6910 * As a result, you should always write these elements with lower case letters,
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04006911 * or use {@link #normalizeMimeType} or {@link android.net.Uri#normalizeScheme} or
Nick Pellyccae4122012-01-09 14:12:58 -08006912 * {@link #setDataAndTypeAndNormalize}
6913 * to ensure that they are converted to lower case.</em>
6914 *
6915 * @param data The Uri of the data this intent is now targeting.
6916 * @param type The MIME type of the data being handled by this intent.
6917 *
6918 * @return Returns the same Intent object, for chaining multiple calls
6919 * into a single statement.
6920 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006921 * @see #setType
Nick Pellyccae4122012-01-09 14:12:58 -08006922 * @see #setData
6923 * @see #normalizeMimeType
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04006924 * @see android.net.Uri#normalizeScheme
Nick Pellyccae4122012-01-09 14:12:58 -08006925 * @see #setDataAndTypeAndNormalize
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006926 */
6927 public Intent setDataAndType(Uri data, String type) {
6928 mData = data;
6929 mType = type;
6930 return this;
6931 }
6932
6933 /**
Nick Pellyccae4122012-01-09 14:12:58 -08006934 * (Usually optional) Normalize and set both the data Uri and an explicit
6935 * MIME data type. This method should very rarely be used -- it allows you
6936 * to override the MIME type that would ordinarily be inferred from the
6937 * data with your own type given here.
6938 *
6939 * <p>The data Uri and the MIME type are normalize using
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04006940 * {@link android.net.Uri#normalizeScheme} and {@link #normalizeMimeType}
Nick Pellyccae4122012-01-09 14:12:58 -08006941 * before they are set, so really this is just a convenience method for
6942 * <pre>
6943 * setDataAndType(data.normalize(), Intent.normalizeMimeType(type))
6944 * </pre>
6945 *
6946 * @param data The Uri of the data this intent is now targeting.
6947 * @param type The MIME type of the data being handled by this intent.
6948 *
6949 * @return Returns the same Intent object, for chaining multiple calls
6950 * into a single statement.
6951 *
6952 * @see #setType
6953 * @see #setData
6954 * @see #setDataAndType
6955 * @see #normalizeMimeType
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04006956 * @see android.net.Uri#normalizeScheme
Nick Pellyccae4122012-01-09 14:12:58 -08006957 */
6958 public Intent setDataAndTypeAndNormalize(Uri data, String type) {
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04006959 return setDataAndType(data.normalizeScheme(), normalizeMimeType(type));
Nick Pellyccae4122012-01-09 14:12:58 -08006960 }
6961
6962 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006963 * Add a new category to the intent. Categories provide additional detail
Ken Wakasaf76a50c2012-03-09 19:56:35 +09006964 * about the action the intent performs. When resolving an intent, only
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006965 * activities that provide <em>all</em> of the requested categories will be
6966 * used.
6967 *
6968 * @param category The desired category. This can be either one of the
6969 * predefined Intent categories, or a custom category in your own
6970 * namespace.
6971 *
6972 * @return Returns the same Intent object, for chaining multiple calls
6973 * into a single statement.
6974 *
6975 * @see #hasCategory
6976 * @see #removeCategory
6977 */
6978 public Intent addCategory(String category) {
6979 if (mCategories == null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07006980 mCategories = new ArraySet<String>();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006981 }
Jeff Brown2c376fc2011-01-28 17:34:01 -08006982 mCategories.add(category.intern());
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006983 return this;
6984 }
6985
6986 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09006987 * Remove a category from an intent.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006988 *
6989 * @param category The category to remove.
6990 *
6991 * @see #addCategory
6992 */
6993 public void removeCategory(String category) {
6994 if (mCategories != null) {
6995 mCategories.remove(category);
6996 if (mCategories.size() == 0) {
6997 mCategories = null;
6998 }
6999 }
7000 }
7001
7002 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08007003 * Set a selector for this Intent. This is a modification to the kinds of
7004 * things the Intent will match. If the selector is set, it will be used
7005 * when trying to find entities that can handle the Intent, instead of the
7006 * main contents of the Intent. This allows you build an Intent containing
7007 * a generic protocol while targeting it more specifically.
7008 *
7009 * <p>An example of where this may be used is with things like
7010 * {@link #CATEGORY_APP_BROWSER}. This category allows you to build an
7011 * Intent that will launch the Browser application. However, the correct
7012 * main entry point of an application is actually {@link #ACTION_MAIN}
7013 * {@link #CATEGORY_LAUNCHER} with {@link #setComponent(ComponentName)}
7014 * used to specify the actual Activity to launch. If you launch the browser
7015 * with something different, undesired behavior may happen if the user has
7016 * previously or later launches it the normal way, since they do not match.
7017 * Instead, you can build an Intent with the MAIN action (but no ComponentName
7018 * yet specified) and set a selector with {@link #ACTION_MAIN} and
7019 * {@link #CATEGORY_APP_BROWSER} to point it specifically to the browser activity.
7020 *
7021 * <p>Setting a selector does not impact the behavior of
7022 * {@link #filterEquals(Intent)} and {@link #filterHashCode()}. This is part of the
7023 * desired behavior of a selector -- it does not impact the base meaning
7024 * of the Intent, just what kinds of things will be matched against it
7025 * when determining who can handle it.</p>
7026 *
7027 * <p>You can not use both a selector and {@link #setPackage(String)} on
7028 * the same base Intent.</p>
7029 *
7030 * @param selector The desired selector Intent; set to null to not use
7031 * a special selector.
7032 */
7033 public void setSelector(Intent selector) {
7034 if (selector == this) {
7035 throw new IllegalArgumentException(
7036 "Intent being set as a selector of itself");
7037 }
7038 if (selector != null && mPackage != null) {
7039 throw new IllegalArgumentException(
7040 "Can't set selector when package name is already set");
7041 }
7042 mSelector = selector;
7043 }
7044
7045 /**
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007046 * Set a {@link ClipData} associated with this Intent. This replaces any
7047 * previously set ClipData.
7048 *
7049 * <p>The ClipData in an intent is not used for Intent matching or other
7050 * such operations. Semantically it is like extras, used to transmit
7051 * additional data with the Intent. The main feature of using this over
7052 * the extras for data is that {@link #FLAG_GRANT_READ_URI_PERMISSION}
7053 * and {@link #FLAG_GRANT_WRITE_URI_PERMISSION} will operate on any URI
7054 * items included in the clip data. This is useful, in particular, if
7055 * you want to transmit an Intent containing multiple <code>content:</code>
7056 * URIs for which the recipient may not have global permission to access the
7057 * content provider.
7058 *
7059 * <p>If the ClipData contains items that are themselves Intents, any
7060 * grant flags in those Intents will be ignored. Only the top-level flags
7061 * of the main Intent are respected, and will be applied to all Uri or
7062 * Intent items in the clip (or sub-items of the clip).
7063 *
7064 * <p>The MIME type, label, and icon in the ClipData object are not
7065 * directly used by Intent. Applications should generally rely on the
7066 * MIME type of the Intent itself, not what it may find in the ClipData.
7067 * A common practice is to construct a ClipData for use with an Intent
John Spurlock33900182014-01-02 11:04:18 -05007068 * with a MIME type of "*&#47;*".
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007069 *
7070 * @param clip The new clip to set. May be null to clear the current clip.
7071 */
7072 public void setClipData(ClipData clip) {
7073 mClipData = clip;
7074 }
7075
7076 /**
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01007077 * This is NOT a secure mechanism to identify the user who sent the intent.
7078 * When the intent is sent to a different user, it is used to fix uris by adding the userId
7079 * who sent the intent.
7080 * @hide
7081 */
Nicolas Prevot107f7b72015-07-01 16:31:48 +01007082 public void prepareToLeaveUser(int userId) {
7083 // If mContentUserHint is not UserHandle.USER_CURRENT, the intent has already left a user.
7084 // We want mContentUserHint to refer to the original user, so don't do anything.
7085 if (mContentUserHint == UserHandle.USER_CURRENT) {
7086 mContentUserHint = userId;
7087 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01007088 }
7089
7090 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007091 * Add extended data to the intent. The name must include a package
7092 * prefix, for example the app com.android.contacts would use names
7093 * like "com.android.contacts.ShowAll".
7094 *
7095 * @param name The name of the extra data, with package prefix.
7096 * @param value The boolean data value.
7097 *
7098 * @return Returns the same Intent object, for chaining multiple calls
7099 * into a single statement.
7100 *
7101 * @see #putExtras
7102 * @see #removeExtra
7103 * @see #getBooleanExtra(String, boolean)
7104 */
7105 public Intent putExtra(String name, boolean value) {
7106 if (mExtras == null) {
7107 mExtras = new Bundle();
7108 }
7109 mExtras.putBoolean(name, value);
7110 return this;
7111 }
7112
7113 /**
7114 * Add extended data to the intent. The name must include a package
7115 * prefix, for example the app com.android.contacts would use names
7116 * like "com.android.contacts.ShowAll".
7117 *
7118 * @param name The name of the extra data, with package prefix.
7119 * @param value The byte data value.
7120 *
7121 * @return Returns the same Intent object, for chaining multiple calls
7122 * into a single statement.
7123 *
7124 * @see #putExtras
7125 * @see #removeExtra
7126 * @see #getByteExtra(String, byte)
7127 */
7128 public Intent putExtra(String name, byte value) {
7129 if (mExtras == null) {
7130 mExtras = new Bundle();
7131 }
7132 mExtras.putByte(name, value);
7133 return this;
7134 }
7135
7136 /**
7137 * Add extended data to the intent. The name must include a package
7138 * prefix, for example the app com.android.contacts would use names
7139 * like "com.android.contacts.ShowAll".
7140 *
7141 * @param name The name of the extra data, with package prefix.
7142 * @param value The char data value.
7143 *
7144 * @return Returns the same Intent object, for chaining multiple calls
7145 * into a single statement.
7146 *
7147 * @see #putExtras
7148 * @see #removeExtra
7149 * @see #getCharExtra(String, char)
7150 */
7151 public Intent putExtra(String name, char value) {
7152 if (mExtras == null) {
7153 mExtras = new Bundle();
7154 }
7155 mExtras.putChar(name, value);
7156 return this;
7157 }
7158
7159 /**
7160 * Add extended data to the intent. The name must include a package
7161 * prefix, for example the app com.android.contacts would use names
7162 * like "com.android.contacts.ShowAll".
7163 *
7164 * @param name The name of the extra data, with package prefix.
7165 * @param value The short data value.
7166 *
7167 * @return Returns the same Intent object, for chaining multiple calls
7168 * into a single statement.
7169 *
7170 * @see #putExtras
7171 * @see #removeExtra
7172 * @see #getShortExtra(String, short)
7173 */
7174 public Intent putExtra(String name, short value) {
7175 if (mExtras == null) {
7176 mExtras = new Bundle();
7177 }
7178 mExtras.putShort(name, value);
7179 return this;
7180 }
7181
7182 /**
7183 * Add extended data to the intent. The name must include a package
7184 * prefix, for example the app com.android.contacts would use names
7185 * like "com.android.contacts.ShowAll".
7186 *
7187 * @param name The name of the extra data, with package prefix.
7188 * @param value The integer data value.
7189 *
7190 * @return Returns the same Intent object, for chaining multiple calls
7191 * into a single statement.
7192 *
7193 * @see #putExtras
7194 * @see #removeExtra
7195 * @see #getIntExtra(String, int)
7196 */
7197 public Intent putExtra(String name, int value) {
7198 if (mExtras == null) {
7199 mExtras = new Bundle();
7200 }
7201 mExtras.putInt(name, value);
7202 return this;
7203 }
7204
7205 /**
7206 * Add extended data to the intent. The name must include a package
7207 * prefix, for example the app com.android.contacts would use names
7208 * like "com.android.contacts.ShowAll".
7209 *
7210 * @param name The name of the extra data, with package prefix.
7211 * @param value The long data value.
7212 *
7213 * @return Returns the same Intent object, for chaining multiple calls
7214 * into a single statement.
7215 *
7216 * @see #putExtras
7217 * @see #removeExtra
7218 * @see #getLongExtra(String, long)
7219 */
7220 public Intent putExtra(String name, long value) {
7221 if (mExtras == null) {
7222 mExtras = new Bundle();
7223 }
7224 mExtras.putLong(name, value);
7225 return this;
7226 }
7227
7228 /**
7229 * Add extended data to the intent. The name must include a package
7230 * prefix, for example the app com.android.contacts would use names
7231 * like "com.android.contacts.ShowAll".
7232 *
7233 * @param name The name of the extra data, with package prefix.
7234 * @param value The float data value.
7235 *
7236 * @return Returns the same Intent object, for chaining multiple calls
7237 * into a single statement.
7238 *
7239 * @see #putExtras
7240 * @see #removeExtra
7241 * @see #getFloatExtra(String, float)
7242 */
7243 public Intent putExtra(String name, float value) {
7244 if (mExtras == null) {
7245 mExtras = new Bundle();
7246 }
7247 mExtras.putFloat(name, value);
7248 return this;
7249 }
7250
7251 /**
7252 * Add extended data to the intent. The name must include a package
7253 * prefix, for example the app com.android.contacts would use names
7254 * like "com.android.contacts.ShowAll".
7255 *
7256 * @param name The name of the extra data, with package prefix.
7257 * @param value The double data value.
7258 *
7259 * @return Returns the same Intent object, for chaining multiple calls
7260 * into a single statement.
7261 *
7262 * @see #putExtras
7263 * @see #removeExtra
7264 * @see #getDoubleExtra(String, double)
7265 */
7266 public Intent putExtra(String name, double value) {
7267 if (mExtras == null) {
7268 mExtras = new Bundle();
7269 }
7270 mExtras.putDouble(name, value);
7271 return this;
7272 }
7273
7274 /**
7275 * Add extended data to the intent. The name must include a package
7276 * prefix, for example the app com.android.contacts would use names
7277 * like "com.android.contacts.ShowAll".
7278 *
7279 * @param name The name of the extra data, with package prefix.
7280 * @param value The String data value.
7281 *
7282 * @return Returns the same Intent object, for chaining multiple calls
7283 * into a single statement.
7284 *
7285 * @see #putExtras
7286 * @see #removeExtra
7287 * @see #getStringExtra(String)
7288 */
7289 public Intent putExtra(String name, String value) {
7290 if (mExtras == null) {
7291 mExtras = new Bundle();
7292 }
7293 mExtras.putString(name, value);
7294 return this;
7295 }
7296
7297 /**
7298 * Add extended data to the intent. The name must include a package
7299 * prefix, for example the app com.android.contacts would use names
7300 * like "com.android.contacts.ShowAll".
7301 *
7302 * @param name The name of the extra data, with package prefix.
7303 * @param value The CharSequence data value.
7304 *
7305 * @return Returns the same Intent object, for chaining multiple calls
7306 * into a single statement.
7307 *
7308 * @see #putExtras
7309 * @see #removeExtra
7310 * @see #getCharSequenceExtra(String)
7311 */
7312 public Intent putExtra(String name, CharSequence value) {
7313 if (mExtras == null) {
7314 mExtras = new Bundle();
7315 }
7316 mExtras.putCharSequence(name, value);
7317 return this;
7318 }
7319
7320 /**
7321 * Add extended data to the intent. The name must include a package
7322 * prefix, for example the app com.android.contacts would use names
7323 * like "com.android.contacts.ShowAll".
7324 *
7325 * @param name The name of the extra data, with package prefix.
7326 * @param value The Parcelable data value.
7327 *
7328 * @return Returns the same Intent object, for chaining multiple calls
7329 * into a single statement.
7330 *
7331 * @see #putExtras
7332 * @see #removeExtra
7333 * @see #getParcelableExtra(String)
7334 */
7335 public Intent putExtra(String name, Parcelable value) {
7336 if (mExtras == null) {
7337 mExtras = new Bundle();
7338 }
7339 mExtras.putParcelable(name, value);
7340 return this;
7341 }
7342
7343 /**
7344 * Add extended data to the intent. The name must include a package
7345 * prefix, for example the app com.android.contacts would use names
7346 * like "com.android.contacts.ShowAll".
7347 *
7348 * @param name The name of the extra data, with package prefix.
7349 * @param value The Parcelable[] data value.
7350 *
7351 * @return Returns the same Intent object, for chaining multiple calls
7352 * into a single statement.
7353 *
7354 * @see #putExtras
7355 * @see #removeExtra
7356 * @see #getParcelableArrayExtra(String)
7357 */
7358 public Intent putExtra(String name, Parcelable[] value) {
7359 if (mExtras == null) {
7360 mExtras = new Bundle();
7361 }
7362 mExtras.putParcelableArray(name, value);
7363 return this;
7364 }
7365
7366 /**
7367 * Add extended data to the intent. The name must include a package
7368 * prefix, for example the app com.android.contacts would use names
7369 * like "com.android.contacts.ShowAll".
7370 *
7371 * @param name The name of the extra data, with package prefix.
7372 * @param value The ArrayList<Parcelable> data value.
7373 *
7374 * @return Returns the same Intent object, for chaining multiple calls
7375 * into a single statement.
7376 *
7377 * @see #putExtras
7378 * @see #removeExtra
7379 * @see #getParcelableArrayListExtra(String)
7380 */
7381 public Intent putParcelableArrayListExtra(String name, ArrayList<? extends Parcelable> value) {
7382 if (mExtras == null) {
7383 mExtras = new Bundle();
7384 }
7385 mExtras.putParcelableArrayList(name, value);
7386 return this;
7387 }
7388
7389 /**
7390 * Add extended data to the intent. The name must include a package
7391 * prefix, for example the app com.android.contacts would use names
7392 * like "com.android.contacts.ShowAll".
7393 *
7394 * @param name The name of the extra data, with package prefix.
7395 * @param value The ArrayList<Integer> data value.
7396 *
7397 * @return Returns the same Intent object, for chaining multiple calls
7398 * into a single statement.
7399 *
7400 * @see #putExtras
7401 * @see #removeExtra
7402 * @see #getIntegerArrayListExtra(String)
7403 */
7404 public Intent putIntegerArrayListExtra(String name, ArrayList<Integer> value) {
7405 if (mExtras == null) {
7406 mExtras = new Bundle();
7407 }
7408 mExtras.putIntegerArrayList(name, value);
7409 return this;
7410 }
7411
7412 /**
7413 * Add extended data to the intent. The name must include a package
7414 * prefix, for example the app com.android.contacts would use names
7415 * like "com.android.contacts.ShowAll".
7416 *
7417 * @param name The name of the extra data, with package prefix.
7418 * @param value The ArrayList<String> data value.
7419 *
7420 * @return Returns the same Intent object, for chaining multiple calls
7421 * into a single statement.
7422 *
7423 * @see #putExtras
7424 * @see #removeExtra
7425 * @see #getStringArrayListExtra(String)
7426 */
7427 public Intent putStringArrayListExtra(String name, ArrayList<String> value) {
7428 if (mExtras == null) {
7429 mExtras = new Bundle();
7430 }
7431 mExtras.putStringArrayList(name, value);
7432 return this;
7433 }
7434
7435 /**
7436 * Add extended data to the intent. The name must include a package
7437 * prefix, for example the app com.android.contacts would use names
7438 * like "com.android.contacts.ShowAll".
7439 *
7440 * @param name The name of the extra data, with package prefix.
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00007441 * @param value The ArrayList<CharSequence> data value.
7442 *
7443 * @return Returns the same Intent object, for chaining multiple calls
7444 * into a single statement.
7445 *
7446 * @see #putExtras
7447 * @see #removeExtra
7448 * @see #getCharSequenceArrayListExtra(String)
7449 */
7450 public Intent putCharSequenceArrayListExtra(String name, ArrayList<CharSequence> value) {
7451 if (mExtras == null) {
7452 mExtras = new Bundle();
7453 }
7454 mExtras.putCharSequenceArrayList(name, value);
7455 return this;
7456 }
7457
7458 /**
7459 * Add extended data to the intent. The name must include a package
7460 * prefix, for example the app com.android.contacts would use names
7461 * like "com.android.contacts.ShowAll".
7462 *
7463 * @param name The name of the extra data, with package prefix.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007464 * @param value The Serializable data value.
7465 *
7466 * @return Returns the same Intent object, for chaining multiple calls
7467 * into a single statement.
7468 *
7469 * @see #putExtras
7470 * @see #removeExtra
7471 * @see #getSerializableExtra(String)
7472 */
7473 public Intent putExtra(String name, Serializable value) {
7474 if (mExtras == null) {
7475 mExtras = new Bundle();
7476 }
7477 mExtras.putSerializable(name, value);
7478 return this;
7479 }
7480
7481 /**
7482 * Add extended data to the intent. The name must include a package
7483 * prefix, for example the app com.android.contacts would use names
7484 * like "com.android.contacts.ShowAll".
7485 *
7486 * @param name The name of the extra data, with package prefix.
7487 * @param value The boolean array data value.
7488 *
7489 * @return Returns the same Intent object, for chaining multiple calls
7490 * into a single statement.
7491 *
7492 * @see #putExtras
7493 * @see #removeExtra
7494 * @see #getBooleanArrayExtra(String)
7495 */
7496 public Intent putExtra(String name, boolean[] value) {
7497 if (mExtras == null) {
7498 mExtras = new Bundle();
7499 }
7500 mExtras.putBooleanArray(name, value);
7501 return this;
7502 }
7503
7504 /**
7505 * Add extended data to the intent. The name must include a package
7506 * prefix, for example the app com.android.contacts would use names
7507 * like "com.android.contacts.ShowAll".
7508 *
7509 * @param name The name of the extra data, with package prefix.
7510 * @param value The byte array data value.
7511 *
7512 * @return Returns the same Intent object, for chaining multiple calls
7513 * into a single statement.
7514 *
7515 * @see #putExtras
7516 * @see #removeExtra
7517 * @see #getByteArrayExtra(String)
7518 */
7519 public Intent putExtra(String name, byte[] value) {
7520 if (mExtras == null) {
7521 mExtras = new Bundle();
7522 }
7523 mExtras.putByteArray(name, value);
7524 return this;
7525 }
7526
7527 /**
7528 * Add extended data to the intent. The name must include a package
7529 * prefix, for example the app com.android.contacts would use names
7530 * like "com.android.contacts.ShowAll".
7531 *
7532 * @param name The name of the extra data, with package prefix.
7533 * @param value The short array data value.
7534 *
7535 * @return Returns the same Intent object, for chaining multiple calls
7536 * into a single statement.
7537 *
7538 * @see #putExtras
7539 * @see #removeExtra
7540 * @see #getShortArrayExtra(String)
7541 */
7542 public Intent putExtra(String name, short[] value) {
7543 if (mExtras == null) {
7544 mExtras = new Bundle();
7545 }
7546 mExtras.putShortArray(name, value);
7547 return this;
7548 }
7549
7550 /**
7551 * Add extended data to the intent. The name must include a package
7552 * prefix, for example the app com.android.contacts would use names
7553 * like "com.android.contacts.ShowAll".
7554 *
7555 * @param name The name of the extra data, with package prefix.
7556 * @param value The char array data value.
7557 *
7558 * @return Returns the same Intent object, for chaining multiple calls
7559 * into a single statement.
7560 *
7561 * @see #putExtras
7562 * @see #removeExtra
7563 * @see #getCharArrayExtra(String)
7564 */
7565 public Intent putExtra(String name, char[] value) {
7566 if (mExtras == null) {
7567 mExtras = new Bundle();
7568 }
7569 mExtras.putCharArray(name, value);
7570 return this;
7571 }
7572
7573 /**
7574 * Add extended data to the intent. The name must include a package
7575 * prefix, for example the app com.android.contacts would use names
7576 * like "com.android.contacts.ShowAll".
7577 *
7578 * @param name The name of the extra data, with package prefix.
7579 * @param value The int array data value.
7580 *
7581 * @return Returns the same Intent object, for chaining multiple calls
7582 * into a single statement.
7583 *
7584 * @see #putExtras
7585 * @see #removeExtra
7586 * @see #getIntArrayExtra(String)
7587 */
7588 public Intent putExtra(String name, int[] value) {
7589 if (mExtras == null) {
7590 mExtras = new Bundle();
7591 }
7592 mExtras.putIntArray(name, value);
7593 return this;
7594 }
7595
7596 /**
7597 * Add extended data to the intent. The name must include a package
7598 * prefix, for example the app com.android.contacts would use names
7599 * like "com.android.contacts.ShowAll".
7600 *
7601 * @param name The name of the extra data, with package prefix.
7602 * @param value The byte array data value.
7603 *
7604 * @return Returns the same Intent object, for chaining multiple calls
7605 * into a single statement.
7606 *
7607 * @see #putExtras
7608 * @see #removeExtra
7609 * @see #getLongArrayExtra(String)
7610 */
7611 public Intent putExtra(String name, long[] value) {
7612 if (mExtras == null) {
7613 mExtras = new Bundle();
7614 }
7615 mExtras.putLongArray(name, value);
7616 return this;
7617 }
7618
7619 /**
7620 * Add extended data to the intent. The name must include a package
7621 * prefix, for example the app com.android.contacts would use names
7622 * like "com.android.contacts.ShowAll".
7623 *
7624 * @param name The name of the extra data, with package prefix.
7625 * @param value The float array data value.
7626 *
7627 * @return Returns the same Intent object, for chaining multiple calls
7628 * into a single statement.
7629 *
7630 * @see #putExtras
7631 * @see #removeExtra
7632 * @see #getFloatArrayExtra(String)
7633 */
7634 public Intent putExtra(String name, float[] value) {
7635 if (mExtras == null) {
7636 mExtras = new Bundle();
7637 }
7638 mExtras.putFloatArray(name, value);
7639 return this;
7640 }
7641
7642 /**
7643 * Add extended data to the intent. The name must include a package
7644 * prefix, for example the app com.android.contacts would use names
7645 * like "com.android.contacts.ShowAll".
7646 *
7647 * @param name The name of the extra data, with package prefix.
7648 * @param value The double array data value.
7649 *
7650 * @return Returns the same Intent object, for chaining multiple calls
7651 * into a single statement.
7652 *
7653 * @see #putExtras
7654 * @see #removeExtra
7655 * @see #getDoubleArrayExtra(String)
7656 */
7657 public Intent putExtra(String name, double[] value) {
7658 if (mExtras == null) {
7659 mExtras = new Bundle();
7660 }
7661 mExtras.putDoubleArray(name, value);
7662 return this;
7663 }
7664
7665 /**
7666 * Add extended data to the intent. The name must include a package
7667 * prefix, for example the app com.android.contacts would use names
7668 * like "com.android.contacts.ShowAll".
7669 *
7670 * @param name The name of the extra data, with package prefix.
7671 * @param value The String array data value.
7672 *
7673 * @return Returns the same Intent object, for chaining multiple calls
7674 * into a single statement.
7675 *
7676 * @see #putExtras
7677 * @see #removeExtra
7678 * @see #getStringArrayExtra(String)
7679 */
7680 public Intent putExtra(String name, String[] value) {
7681 if (mExtras == null) {
7682 mExtras = new Bundle();
7683 }
7684 mExtras.putStringArray(name, value);
7685 return this;
7686 }
7687
7688 /**
7689 * Add extended data to the intent. The name must include a package
7690 * prefix, for example the app com.android.contacts would use names
7691 * like "com.android.contacts.ShowAll".
7692 *
7693 * @param name The name of the extra data, with package prefix.
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00007694 * @param value The CharSequence array data value.
7695 *
7696 * @return Returns the same Intent object, for chaining multiple calls
7697 * into a single statement.
7698 *
7699 * @see #putExtras
7700 * @see #removeExtra
7701 * @see #getCharSequenceArrayExtra(String)
7702 */
7703 public Intent putExtra(String name, CharSequence[] value) {
7704 if (mExtras == null) {
7705 mExtras = new Bundle();
7706 }
7707 mExtras.putCharSequenceArray(name, value);
7708 return this;
7709 }
7710
7711 /**
7712 * Add extended data to the intent. The name must include a package
7713 * prefix, for example the app com.android.contacts would use names
7714 * like "com.android.contacts.ShowAll".
7715 *
7716 * @param name The name of the extra data, with package prefix.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007717 * @param value The Bundle data value.
7718 *
7719 * @return Returns the same Intent object, for chaining multiple calls
7720 * into a single statement.
7721 *
7722 * @see #putExtras
7723 * @see #removeExtra
7724 * @see #getBundleExtra(String)
7725 */
7726 public Intent putExtra(String name, Bundle value) {
7727 if (mExtras == null) {
7728 mExtras = new Bundle();
7729 }
7730 mExtras.putBundle(name, value);
7731 return this;
7732 }
7733
7734 /**
7735 * Add extended data to the intent. The name must include a package
7736 * prefix, for example the app com.android.contacts would use names
7737 * like "com.android.contacts.ShowAll".
7738 *
7739 * @param name The name of the extra data, with package prefix.
7740 * @param value The IBinder data value.
7741 *
7742 * @return Returns the same Intent object, for chaining multiple calls
7743 * into a single statement.
7744 *
7745 * @see #putExtras
7746 * @see #removeExtra
7747 * @see #getIBinderExtra(String)
7748 *
7749 * @deprecated
7750 * @hide
7751 */
7752 @Deprecated
7753 public Intent putExtra(String name, IBinder value) {
7754 if (mExtras == null) {
7755 mExtras = new Bundle();
7756 }
7757 mExtras.putIBinder(name, value);
7758 return this;
7759 }
7760
7761 /**
7762 * Copy all extras in 'src' in to this intent.
7763 *
7764 * @param src Contains the extras to copy.
7765 *
7766 * @see #putExtra
7767 */
7768 public Intent putExtras(Intent src) {
7769 if (src.mExtras != null) {
7770 if (mExtras == null) {
7771 mExtras = new Bundle(src.mExtras);
7772 } else {
7773 mExtras.putAll(src.mExtras);
7774 }
7775 }
7776 return this;
7777 }
7778
7779 /**
7780 * Add a set of extended data to the intent. The keys must include a package
7781 * prefix, for example the app com.android.contacts would use names
7782 * like "com.android.contacts.ShowAll".
7783 *
7784 * @param extras The Bundle of extras to add to this intent.
7785 *
7786 * @see #putExtra
7787 * @see #removeExtra
7788 */
7789 public Intent putExtras(Bundle extras) {
7790 if (mExtras == null) {
7791 mExtras = new Bundle();
7792 }
7793 mExtras.putAll(extras);
7794 return this;
7795 }
7796
7797 /**
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08007798 * Completely replace the extras in the Intent with the extras in the
7799 * given Intent.
The Android Open Source Project10592532009-03-18 17:39:46 -07007800 *
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08007801 * @param src The exact extras contained in this Intent are copied
7802 * into the target intent, replacing any that were previously there.
7803 */
7804 public Intent replaceExtras(Intent src) {
7805 mExtras = src.mExtras != null ? new Bundle(src.mExtras) : null;
7806 return this;
7807 }
The Android Open Source Project10592532009-03-18 17:39:46 -07007808
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08007809 /**
7810 * Completely replace the extras in the Intent with the given Bundle of
7811 * extras.
The Android Open Source Project10592532009-03-18 17:39:46 -07007812 *
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08007813 * @param extras The new set of extras in the Intent, or null to erase
7814 * all extras.
7815 */
7816 public Intent replaceExtras(Bundle extras) {
7817 mExtras = extras != null ? new Bundle(extras) : null;
7818 return this;
7819 }
The Android Open Source Project10592532009-03-18 17:39:46 -07007820
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08007821 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007822 * Remove extended data from the intent.
7823 *
7824 * @see #putExtra
7825 */
7826 public void removeExtra(String name) {
7827 if (mExtras != null) {
7828 mExtras.remove(name);
7829 if (mExtras.size() == 0) {
7830 mExtras = null;
7831 }
7832 }
7833 }
7834
7835 /**
7836 * Set special flags controlling how this intent is handled. Most values
7837 * here depend on the type of component being executed by the Intent,
7838 * specifically the FLAG_ACTIVITY_* flags are all for use with
7839 * {@link Context#startActivity Context.startActivity()} and the
7840 * FLAG_RECEIVER_* flags are all for use with
7841 * {@link Context#sendBroadcast(Intent) Context.sendBroadcast()}.
7842 *
Scott Main7aee61f2011-02-08 11:25:01 -08007843 * <p>See the
7844 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
7845 * Stack</a> documentation for important information on how some of these options impact
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007846 * the behavior of your application.
7847 *
7848 * @param flags The desired flags.
7849 *
7850 * @return Returns the same Intent object, for chaining multiple calls
7851 * into a single statement.
7852 *
7853 * @see #getFlags
7854 * @see #addFlags
7855 *
7856 * @see #FLAG_GRANT_READ_URI_PERMISSION
7857 * @see #FLAG_GRANT_WRITE_URI_PERMISSION
Jeff Sharkey846318a2014-04-04 12:12:41 -07007858 * @see #FLAG_GRANT_PERSISTABLE_URI_PERMISSION
7859 * @see #FLAG_GRANT_PREFIX_URI_PERMISSION
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007860 * @see #FLAG_DEBUG_LOG_RESOLUTION
7861 * @see #FLAG_FROM_BACKGROUND
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007862 * @see #FLAG_ACTIVITY_BROUGHT_TO_FRONT
Dianne Hackborn621e17d2010-11-22 15:59:56 -08007863 * @see #FLAG_ACTIVITY_CLEAR_TASK
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007864 * @see #FLAG_ACTIVITY_CLEAR_TOP
Dianne Hackborn621e17d2010-11-22 15:59:56 -08007865 * @see #FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007866 * @see #FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS
7867 * @see #FLAG_ACTIVITY_FORWARD_RESULT
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08007868 * @see #FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007869 * @see #FLAG_ACTIVITY_MULTIPLE_TASK
Craig Mautnerd00f4742014-03-12 14:17:26 -07007870 * @see #FLAG_ACTIVITY_NEW_DOCUMENT
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007871 * @see #FLAG_ACTIVITY_NEW_TASK
Dianne Hackborn621e17d2010-11-22 15:59:56 -08007872 * @see #FLAG_ACTIVITY_NO_ANIMATION
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007873 * @see #FLAG_ACTIVITY_NO_HISTORY
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08007874 * @see #FLAG_ACTIVITY_NO_USER_ACTION
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08007875 * @see #FLAG_ACTIVITY_PREVIOUS_IS_TOP
7876 * @see #FLAG_ACTIVITY_RESET_TASK_IF_NEEDED
Dianne Hackborn621e17d2010-11-22 15:59:56 -08007877 * @see #FLAG_ACTIVITY_REORDER_TO_FRONT
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007878 * @see #FLAG_ACTIVITY_SINGLE_TOP
Dianne Hackborn621e17d2010-11-22 15:59:56 -08007879 * @see #FLAG_ACTIVITY_TASK_ON_HOME
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007880 * @see #FLAG_RECEIVER_REGISTERED_ONLY
7881 */
7882 public Intent setFlags(int flags) {
7883 mFlags = flags;
7884 return this;
7885 }
7886
7887 /**
7888 * Add additional flags to the intent (or with existing flags
7889 * value).
7890 *
7891 * @param flags The new flags to set.
7892 *
7893 * @return Returns the same Intent object, for chaining multiple calls
7894 * into a single statement.
7895 *
7896 * @see #setFlags
7897 */
7898 public Intent addFlags(int flags) {
7899 mFlags |= flags;
7900 return this;
7901 }
7902
7903 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007904 * (Usually optional) Set an explicit application package name that limits
7905 * the components this Intent will resolve to. If left to the default
7906 * value of null, all components in all applications will considered.
7907 * If non-null, the Intent can only match the components in the given
7908 * application package.
7909 *
7910 * @param packageName The name of the application package to handle the
7911 * intent, or null to allow any application package.
7912 *
7913 * @return Returns the same Intent object, for chaining multiple calls
7914 * into a single statement.
7915 *
7916 * @see #getPackage
7917 * @see #resolveActivity
7918 */
7919 public Intent setPackage(String packageName) {
Dianne Hackbornf5b86712011-12-05 17:42:41 -08007920 if (packageName != null && mSelector != null) {
7921 throw new IllegalArgumentException(
7922 "Can't set package name when selector is already set");
7923 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007924 mPackage = packageName;
7925 return this;
7926 }
7927
7928 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007929 * (Usually optional) Explicitly set the component to handle the intent.
7930 * If left with the default value of null, the system will determine the
7931 * appropriate class to use based on the other fields (action, data,
7932 * type, categories) in the Intent. If this class is defined, the
7933 * specified class will always be used regardless of the other fields. You
7934 * should only set this value when you know you absolutely want a specific
7935 * class to be used; otherwise it is better to let the system find the
7936 * appropriate class so that you will respect the installed applications
7937 * and user preferences.
7938 *
7939 * @param component The name of the application component to handle the
7940 * intent, or null to let the system find one for you.
7941 *
7942 * @return Returns the same Intent object, for chaining multiple calls
7943 * into a single statement.
7944 *
7945 * @see #setClass
7946 * @see #setClassName(Context, String)
7947 * @see #setClassName(String, String)
7948 * @see #getComponent
7949 * @see #resolveActivity
7950 */
7951 public Intent setComponent(ComponentName component) {
7952 mComponent = component;
7953 return this;
7954 }
7955
7956 /**
7957 * Convenience for calling {@link #setComponent} with an
7958 * explicit class name.
7959 *
7960 * @param packageContext A Context of the application package implementing
7961 * this class.
7962 * @param className The name of a class inside of the application package
7963 * that will be used as the component for this Intent.
7964 *
7965 * @return Returns the same Intent object, for chaining multiple calls
7966 * into a single statement.
7967 *
7968 * @see #setComponent
7969 * @see #setClass
7970 */
7971 public Intent setClassName(Context packageContext, String className) {
7972 mComponent = new ComponentName(packageContext, className);
7973 return this;
7974 }
7975
7976 /**
7977 * Convenience for calling {@link #setComponent} with an
7978 * explicit application package name and class name.
7979 *
7980 * @param packageName The name of the package implementing the desired
7981 * component.
7982 * @param className The name of a class inside of the application package
7983 * that will be used as the component for this Intent.
7984 *
7985 * @return Returns the same Intent object, for chaining multiple calls
7986 * into a single statement.
7987 *
7988 * @see #setComponent
7989 * @see #setClass
7990 */
7991 public Intent setClassName(String packageName, String className) {
7992 mComponent = new ComponentName(packageName, className);
7993 return this;
7994 }
7995
7996 /**
7997 * Convenience for calling {@link #setComponent(ComponentName)} with the
7998 * name returned by a {@link Class} object.
7999 *
8000 * @param packageContext A Context of the application package implementing
8001 * this class.
8002 * @param cls The class name to set, equivalent to
8003 * <code>setClassName(context, cls.getName())</code>.
8004 *
8005 * @return Returns the same Intent object, for chaining multiple calls
8006 * into a single statement.
8007 *
8008 * @see #setComponent
8009 */
8010 public Intent setClass(Context packageContext, Class<?> cls) {
8011 mComponent = new ComponentName(packageContext, cls);
8012 return this;
8013 }
8014
8015 /**
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08008016 * Set the bounds of the sender of this intent, in screen coordinates. This can be
8017 * used as a hint to the receiver for animations and the like. Null means that there
8018 * is no source bounds.
8019 */
8020 public void setSourceBounds(Rect r) {
8021 if (r != null) {
8022 mSourceBounds = new Rect(r);
8023 } else {
Daniel Lehmanna5b58df2011-10-12 16:24:22 -07008024 mSourceBounds = null;
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08008025 }
8026 }
8027
Tor Norbyed9273d62013-05-30 15:59:53 -07008028 /** @hide */
8029 @IntDef(flag = true,
8030 value = {
8031 FILL_IN_ACTION,
8032 FILL_IN_DATA,
8033 FILL_IN_CATEGORIES,
8034 FILL_IN_COMPONENT,
8035 FILL_IN_PACKAGE,
8036 FILL_IN_SOURCE_BOUNDS,
8037 FILL_IN_SELECTOR,
8038 FILL_IN_CLIP_DATA
8039 })
8040 @Retention(RetentionPolicy.SOURCE)
8041 public @interface FillInFlags {}
8042
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08008043 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008044 * Use with {@link #fillIn} to allow the current action value to be
8045 * overwritten, even if it is already set.
8046 */
8047 public static final int FILL_IN_ACTION = 1<<0;
8048
8049 /**
8050 * Use with {@link #fillIn} to allow the current data or type value
8051 * overwritten, even if it is already set.
8052 */
8053 public static final int FILL_IN_DATA = 1<<1;
8054
8055 /**
8056 * Use with {@link #fillIn} to allow the current categories to be
8057 * overwritten, even if they are already set.
8058 */
8059 public static final int FILL_IN_CATEGORIES = 1<<2;
8060
8061 /**
8062 * Use with {@link #fillIn} to allow the current component value to be
8063 * overwritten, even if it is already set.
8064 */
8065 public static final int FILL_IN_COMPONENT = 1<<3;
8066
8067 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008068 * Use with {@link #fillIn} to allow the current package value to be
8069 * overwritten, even if it is already set.
8070 */
8071 public static final int FILL_IN_PACKAGE = 1<<4;
8072
8073 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008074 * Use with {@link #fillIn} to allow the current bounds rectangle to be
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08008075 * overwritten, even if it is already set.
8076 */
8077 public static final int FILL_IN_SOURCE_BOUNDS = 1<<5;
8078
8079 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008080 * Use with {@link #fillIn} to allow the current selector to be
8081 * overwritten, even if it is already set.
8082 */
8083 public static final int FILL_IN_SELECTOR = 1<<6;
8084
8085 /**
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008086 * Use with {@link #fillIn} to allow the current ClipData to be
8087 * overwritten, even if it is already set.
8088 */
8089 public static final int FILL_IN_CLIP_DATA = 1<<7;
8090
8091 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008092 * Copy the contents of <var>other</var> in to this object, but only
8093 * where fields are not defined by this object. For purposes of a field
8094 * being defined, the following pieces of data in the Intent are
8095 * considered to be separate fields:
8096 *
8097 * <ul>
8098 * <li> action, as set by {@link #setAction}.
Nick Pellyccae4122012-01-09 14:12:58 -08008099 * <li> data Uri and MIME type, as set by {@link #setData(Uri)},
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008100 * {@link #setType(String)}, or {@link #setDataAndType(Uri, String)}.
8101 * <li> categories, as set by {@link #addCategory}.
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008102 * <li> package, as set by {@link #setPackage}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008103 * <li> component, as set by {@link #setComponent(ComponentName)} or
8104 * related methods.
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008105 * <li> source bounds, as set by {@link #setSourceBounds}.
8106 * <li> selector, as set by {@link #setSelector(Intent)}.
8107 * <li> clip data, as set by {@link #setClipData(ClipData)}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008108 * <li> each top-level name in the associated extras.
8109 * </ul>
8110 *
8111 * <p>In addition, you can use the {@link #FILL_IN_ACTION},
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008112 * {@link #FILL_IN_DATA}, {@link #FILL_IN_CATEGORIES}, {@link #FILL_IN_PACKAGE},
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008113 * {@link #FILL_IN_COMPONENT}, {@link #FILL_IN_SOURCE_BOUNDS},
8114 * {@link #FILL_IN_SELECTOR}, and {@link #FILL_IN_CLIP_DATA} to override
8115 * the restriction where the corresponding field will not be replaced if
8116 * it is already set.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008117 *
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008118 * <p>Note: The component field will only be copied if {@link #FILL_IN_COMPONENT}
8119 * is explicitly specified. The selector will only be copied if
8120 * {@link #FILL_IN_SELECTOR} is explicitly specified.
Brett Chabot3e391752009-07-21 16:07:23 -07008121 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008122 * <p>For example, consider Intent A with {data="foo", categories="bar"}
8123 * and Intent B with {action="gotit", data-type="some/thing",
8124 * categories="one","two"}.
8125 *
8126 * <p>Calling A.fillIn(B, Intent.FILL_IN_DATA) will result in A now
8127 * containing: {action="gotit", data-type="some/thing",
8128 * categories="bar"}.
8129 *
8130 * @param other Another Intent whose values are to be used to fill in
8131 * the current one.
8132 * @param flags Options to control which fields can be filled in.
8133 *
8134 * @return Returns a bit mask of {@link #FILL_IN_ACTION},
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008135 * {@link #FILL_IN_DATA}, {@link #FILL_IN_CATEGORIES}, {@link #FILL_IN_PACKAGE},
Tor Norbyed9273d62013-05-30 15:59:53 -07008136 * {@link #FILL_IN_COMPONENT}, {@link #FILL_IN_SOURCE_BOUNDS},
8137 * {@link #FILL_IN_SELECTOR} and {@link #FILL_IN_CLIP_DATA indicating which fields were
8138 * changed.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008139 */
Tor Norbyed9273d62013-05-30 15:59:53 -07008140 @FillInFlags
8141 public int fillIn(Intent other, @FillInFlags int flags) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008142 int changes = 0;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008143 boolean mayHaveCopiedUris = false;
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008144 if (other.mAction != null
8145 && (mAction == null || (flags&FILL_IN_ACTION) != 0)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008146 mAction = other.mAction;
8147 changes |= FILL_IN_ACTION;
8148 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008149 if ((other.mData != null || other.mType != null)
8150 && ((mData == null && mType == null)
8151 || (flags&FILL_IN_DATA) != 0)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008152 mData = other.mData;
8153 mType = other.mType;
8154 changes |= FILL_IN_DATA;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008155 mayHaveCopiedUris = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008156 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008157 if (other.mCategories != null
8158 && (mCategories == null || (flags&FILL_IN_CATEGORIES) != 0)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008159 if (other.mCategories != null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07008160 mCategories = new ArraySet<String>(other.mCategories);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008161 }
8162 changes |= FILL_IN_CATEGORIES;
8163 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008164 if (other.mPackage != null
8165 && (mPackage == null || (flags&FILL_IN_PACKAGE) != 0)) {
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008166 // Only do this if mSelector is not set.
8167 if (mSelector == null) {
8168 mPackage = other.mPackage;
8169 changes |= FILL_IN_PACKAGE;
8170 }
8171 }
8172 // Selector is special: it can only be set if explicitly allowed,
8173 // for the same reason as the component name.
8174 if (other.mSelector != null && (flags&FILL_IN_SELECTOR) != 0) {
8175 if (mPackage == null) {
8176 mSelector = new Intent(other.mSelector);
8177 mPackage = null;
8178 changes |= FILL_IN_SELECTOR;
8179 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008180 }
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008181 if (other.mClipData != null
8182 && (mClipData == null || (flags&FILL_IN_CLIP_DATA) != 0)) {
8183 mClipData = other.mClipData;
8184 changes |= FILL_IN_CLIP_DATA;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008185 mayHaveCopiedUris = true;
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008186 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008187 // Component is special: it can -only- be set if explicitly allowed,
8188 // since otherwise the sender could force the intent somewhere the
8189 // originator didn't intend.
8190 if (other.mComponent != null && (flags&FILL_IN_COMPONENT) != 0) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008191 mComponent = other.mComponent;
8192 changes |= FILL_IN_COMPONENT;
8193 }
8194 mFlags |= other.mFlags;
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08008195 if (other.mSourceBounds != null
8196 && (mSourceBounds == null || (flags&FILL_IN_SOURCE_BOUNDS) != 0)) {
8197 mSourceBounds = new Rect(other.mSourceBounds);
8198 changes |= FILL_IN_SOURCE_BOUNDS;
8199 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008200 if (mExtras == null) {
8201 if (other.mExtras != null) {
8202 mExtras = new Bundle(other.mExtras);
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008203 mayHaveCopiedUris = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008204 }
8205 } else if (other.mExtras != null) {
8206 try {
8207 Bundle newb = new Bundle(other.mExtras);
8208 newb.putAll(mExtras);
8209 mExtras = newb;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008210 mayHaveCopiedUris = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008211 } catch (RuntimeException e) {
8212 // Modifying the extras can cause us to unparcel the contents
8213 // of the bundle, and if we do this in the system process that
8214 // may fail. We really should handle this (i.e., the Bundle
8215 // impl shouldn't be on top of a plain map), but for now just
8216 // ignore it and keep the original contents. :(
8217 Log.w("Intent", "Failure filling in extras", e);
8218 }
8219 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008220 if (mayHaveCopiedUris && mContentUserHint == UserHandle.USER_CURRENT
8221 && other.mContentUserHint != UserHandle.USER_CURRENT) {
8222 mContentUserHint = other.mContentUserHint;
8223 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008224 return changes;
8225 }
8226
8227 /**
8228 * Wrapper class holding an Intent and implementing comparisons on it for
8229 * the purpose of filtering. The class implements its
8230 * {@link #equals equals()} and {@link #hashCode hashCode()} methods as
8231 * simple calls to {@link Intent#filterEquals(Intent)} filterEquals()} and
8232 * {@link android.content.Intent#filterHashCode()} filterHashCode()}
8233 * on the wrapped Intent.
8234 */
8235 public static final class FilterComparison {
8236 private final Intent mIntent;
8237 private final int mHashCode;
8238
8239 public FilterComparison(Intent intent) {
8240 mIntent = intent;
8241 mHashCode = intent.filterHashCode();
8242 }
8243
8244 /**
8245 * Return the Intent that this FilterComparison represents.
8246 * @return Returns the Intent held by the FilterComparison. Do
8247 * not modify!
8248 */
8249 public Intent getIntent() {
8250 return mIntent;
8251 }
8252
8253 @Override
8254 public boolean equals(Object obj) {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08008255 if (obj instanceof FilterComparison) {
8256 Intent other = ((FilterComparison)obj).mIntent;
8257 return mIntent.filterEquals(other);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008258 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08008259 return false;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008260 }
8261
8262 @Override
8263 public int hashCode() {
8264 return mHashCode;
8265 }
8266 }
8267
8268 /**
8269 * Determine if two intents are the same for the purposes of intent
8270 * resolution (filtering). That is, if their action, data, type,
8271 * class, and categories are the same. This does <em>not</em> compare
8272 * any extra data included in the intents.
8273 *
8274 * @param other The other Intent to compare against.
8275 *
8276 * @return Returns true if action, data, type, class, and categories
8277 * are the same.
8278 */
8279 public boolean filterEquals(Intent other) {
8280 if (other == null) {
8281 return false;
8282 }
Christopher Tate63d9ae12014-06-19 19:07:26 -07008283 if (!Objects.equals(this.mAction, other.mAction)) return false;
8284 if (!Objects.equals(this.mData, other.mData)) return false;
8285 if (!Objects.equals(this.mType, other.mType)) return false;
8286 if (!Objects.equals(this.mPackage, other.mPackage)) return false;
8287 if (!Objects.equals(this.mComponent, other.mComponent)) return false;
8288 if (!Objects.equals(this.mCategories, other.mCategories)) return false;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008289
8290 return true;
8291 }
8292
8293 /**
8294 * Generate hash code that matches semantics of filterEquals().
8295 *
8296 * @return Returns the hash value of the action, data, type, class, and
8297 * categories.
8298 *
8299 * @see #filterEquals
8300 */
8301 public int filterHashCode() {
8302 int code = 0;
8303 if (mAction != null) {
8304 code += mAction.hashCode();
8305 }
8306 if (mData != null) {
8307 code += mData.hashCode();
8308 }
8309 if (mType != null) {
8310 code += mType.hashCode();
8311 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008312 if (mPackage != null) {
8313 code += mPackage.hashCode();
8314 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008315 if (mComponent != null) {
8316 code += mComponent.hashCode();
8317 }
8318 if (mCategories != null) {
8319 code += mCategories.hashCode();
8320 }
8321 return code;
8322 }
8323
8324 @Override
8325 public String toString() {
Dianne Hackborn90c52de2011-09-23 12:57:44 -07008326 StringBuilder b = new StringBuilder(128);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008327
Dianne Hackborn1d442e02009-04-20 18:14:05 -07008328 b.append("Intent { ");
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008329 toShortString(b, true, true, true, false);
Dianne Hackborn1d442e02009-04-20 18:14:05 -07008330 b.append(" }");
8331
8332 return b.toString();
8333 }
8334
8335 /** @hide */
Dianne Hackborn90c52de2011-09-23 12:57:44 -07008336 public String toInsecureString() {
8337 StringBuilder b = new StringBuilder(128);
8338
8339 b.append("Intent { ");
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008340 toShortString(b, false, true, true, false);
Dianne Hackborn90c52de2011-09-23 12:57:44 -07008341 b.append(" }");
8342
Dianne Hackborn1d442e02009-04-20 18:14:05 -07008343 return b.toString();
8344 }
Romain Guy4969af72009-06-17 10:53:19 -07008345
Dianne Hackborn1d442e02009-04-20 18:14:05 -07008346 /** @hide */
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008347 public String toInsecureStringWithClip() {
Dianne Hackborn90c52de2011-09-23 12:57:44 -07008348 StringBuilder b = new StringBuilder(128);
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008349
8350 b.append("Intent { ");
8351 toShortString(b, false, true, true, true);
8352 b.append(" }");
8353
Dianne Hackborn90c52de2011-09-23 12:57:44 -07008354 return b.toString();
8355 }
8356
8357 /** @hide */
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008358 public String toShortString(boolean secure, boolean comp, boolean extras, boolean clip) {
8359 StringBuilder b = new StringBuilder(128);
8360 toShortString(b, secure, comp, extras, clip);
8361 return b.toString();
8362 }
8363
8364 /** @hide */
8365 public void toShortString(StringBuilder b, boolean secure, boolean comp, boolean extras,
8366 boolean clip) {
Dianne Hackborn1d442e02009-04-20 18:14:05 -07008367 boolean first = true;
8368 if (mAction != null) {
8369 b.append("act=").append(mAction);
8370 first = false;
8371 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008372 if (mCategories != null) {
Dianne Hackborn1d442e02009-04-20 18:14:05 -07008373 if (!first) {
8374 b.append(' ');
8375 }
8376 first = false;
8377 b.append("cat=[");
Dianne Hackbornadd005c2013-07-17 18:43:12 -07008378 for (int i=0; i<mCategories.size(); i++) {
8379 if (i > 0) b.append(',');
8380 b.append(mCategories.valueAt(i));
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008381 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07008382 b.append("]");
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008383 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07008384 if (mData != null) {
8385 if (!first) {
8386 b.append(' ');
8387 }
8388 first = false;
Wink Savillea4288072010-10-12 12:36:38 -07008389 b.append("dat=");
Dianne Hackborn90c52de2011-09-23 12:57:44 -07008390 if (secure) {
8391 b.append(mData.toSafeString());
Wink Savillea4288072010-10-12 12:36:38 -07008392 } else {
8393 b.append(mData);
8394 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07008395 }
8396 if (mType != null) {
8397 if (!first) {
8398 b.append(' ');
8399 }
8400 first = false;
8401 b.append("typ=").append(mType);
8402 }
8403 if (mFlags != 0) {
8404 if (!first) {
8405 b.append(' ');
8406 }
8407 first = false;
8408 b.append("flg=0x").append(Integer.toHexString(mFlags));
8409 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008410 if (mPackage != null) {
8411 if (!first) {
8412 b.append(' ');
8413 }
8414 first = false;
8415 b.append("pkg=").append(mPackage);
8416 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07008417 if (comp && mComponent != null) {
8418 if (!first) {
8419 b.append(' ');
8420 }
8421 first = false;
8422 b.append("cmp=").append(mComponent.flattenToShortString());
8423 }
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08008424 if (mSourceBounds != null) {
8425 if (!first) {
8426 b.append(' ');
8427 }
8428 first = false;
8429 b.append("bnds=").append(mSourceBounds.toShortString());
8430 }
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008431 if (mClipData != null) {
8432 if (!first) {
8433 b.append(' ');
8434 }
Dianne Hackbornae498722015-08-14 13:29:47 -07008435 b.append("clip={");
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008436 if (clip) {
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008437 mClipData.toShortString(b);
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008438 } else {
Dianne Hackbornae498722015-08-14 13:29:47 -07008439 if (mClipData.getDescription() != null) {
8440 first = !mClipData.getDescription().toShortStringTypesOnly(b);
8441 } else {
8442 first = true;
8443 }
8444 mClipData.toShortStringShortItems(b, first);
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008445 }
Dianne Hackbornae498722015-08-14 13:29:47 -07008446 first = false;
8447 b.append('}');
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008448 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07008449 if (extras && mExtras != null) {
8450 if (!first) {
8451 b.append(' ');
8452 }
8453 first = false;
8454 b.append("(has extras)");
8455 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008456 if (mContentUserHint != UserHandle.USER_CURRENT) {
8457 if (!first) {
8458 b.append(' ');
8459 }
8460 first = false;
8461 b.append("u=").append(mContentUserHint);
8462 }
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008463 if (mSelector != null) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008464 b.append(" sel=");
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008465 mSelector.toShortString(b, secure, comp, extras, clip);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008466 b.append("}");
8467 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008468 }
8469
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008470 /**
8471 * Call {@link #toUri} with 0 flags.
8472 * @deprecated Use {@link #toUri} instead.
8473 */
8474 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008475 public String toURI() {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008476 return toUri(0);
8477 }
8478
8479 /**
8480 * Convert this Intent into a String holding a URI representation of it.
8481 * The returned URI string has been properly URI encoded, so it can be
8482 * used with {@link Uri#parse Uri.parse(String)}. The URI contains the
8483 * Intent's data as the base URI, with an additional fragment describing
8484 * the action, categories, type, flags, package, component, and extras.
Tom Taylord4a47292009-12-21 13:59:18 -08008485 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008486 * <p>You can convert the returned string back to an Intent with
8487 * {@link #getIntent}.
Tom Taylord4a47292009-12-21 13:59:18 -08008488 *
Dianne Hackborn85d558c2014-11-04 10:31:54 -08008489 * @param flags Additional operating flags. Either 0,
8490 * {@link #URI_INTENT_SCHEME}, or {@link #URI_ANDROID_APP_SCHEME}.
Tom Taylord4a47292009-12-21 13:59:18 -08008491 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008492 * @return Returns a URI encoding URI string describing the entire contents
8493 * of the Intent.
8494 */
8495 public String toUri(int flags) {
Dianne Hackborn1d442e02009-04-20 18:14:05 -07008496 StringBuilder uri = new StringBuilder(128);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08008497 if ((flags&URI_ANDROID_APP_SCHEME) != 0) {
8498 if (mPackage == null) {
8499 throw new IllegalArgumentException(
8500 "Intent must include an explicit package name to build an android-app: "
8501 + this);
8502 }
8503 uri.append("android-app://");
8504 uri.append(mPackage);
8505 String scheme = null;
8506 if (mData != null) {
8507 scheme = mData.getScheme();
8508 if (scheme != null) {
8509 uri.append('/');
8510 uri.append(scheme);
8511 String authority = mData.getEncodedAuthority();
8512 if (authority != null) {
8513 uri.append('/');
8514 uri.append(authority);
8515 String path = mData.getEncodedPath();
8516 if (path != null) {
8517 uri.append(path);
8518 }
8519 String queryParams = mData.getEncodedQuery();
8520 if (queryParams != null) {
8521 uri.append('?');
8522 uri.append(queryParams);
8523 }
8524 String fragment = mData.getEncodedFragment();
8525 if (fragment != null) {
8526 uri.append('#');
8527 uri.append(fragment);
8528 }
8529 }
8530 }
8531 }
8532 toUriFragment(uri, null, scheme == null ? Intent.ACTION_MAIN : Intent.ACTION_VIEW,
8533 mPackage, flags);
8534 return uri.toString();
8535 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008536 String scheme = null;
8537 if (mData != null) {
8538 String data = mData.toString();
8539 if ((flags&URI_INTENT_SCHEME) != 0) {
8540 final int N = data.length();
8541 for (int i=0; i<N; i++) {
8542 char c = data.charAt(i);
8543 if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')
8544 || c == '.' || c == '-') {
8545 continue;
8546 }
8547 if (c == ':' && i > 0) {
8548 // Valid scheme.
8549 scheme = data.substring(0, i);
8550 uri.append("intent:");
8551 data = data.substring(i+1);
8552 break;
8553 }
Tom Taylord4a47292009-12-21 13:59:18 -08008554
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008555 // No scheme.
8556 break;
8557 }
8558 }
8559 uri.append(data);
Tom Taylord4a47292009-12-21 13:59:18 -08008560
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008561 } else if ((flags&URI_INTENT_SCHEME) != 0) {
8562 uri.append("intent:");
8563 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008564
Dianne Hackborn85d558c2014-11-04 10:31:54 -08008565 toUriFragment(uri, scheme, Intent.ACTION_VIEW, null, flags);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008566
Dianne Hackborn85d558c2014-11-04 10:31:54 -08008567 return uri.toString();
8568 }
8569
8570 private void toUriFragment(StringBuilder uri, String scheme, String defAction,
8571 String defPackage, int flags) {
8572 StringBuilder frag = new StringBuilder(128);
8573
8574 toUriInner(frag, scheme, defAction, defPackage, flags);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008575 if (mSelector != null) {
Dianne Hackborn80b1c562014-12-09 20:22:08 -08008576 frag.append("SEL;");
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008577 // Note that for now we are not going to try to handle the
8578 // data part; not clear how to represent this as a URI, and
8579 // not much utility in it.
Dianne Hackborn85d558c2014-11-04 10:31:54 -08008580 mSelector.toUriInner(frag, mSelector.mData != null ? mSelector.mData.getScheme() : null,
8581 null, null, flags);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008582 }
8583
Dianne Hackborn85d558c2014-11-04 10:31:54 -08008584 if (frag.length() > 0) {
8585 uri.append("#Intent;");
8586 uri.append(frag);
8587 uri.append("end");
8588 }
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008589 }
8590
Dianne Hackborn85d558c2014-11-04 10:31:54 -08008591 private void toUriInner(StringBuilder uri, String scheme, String defAction,
8592 String defPackage, int flags) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008593 if (scheme != null) {
8594 uri.append("scheme=").append(scheme).append(';');
8595 }
Dianne Hackborn85d558c2014-11-04 10:31:54 -08008596 if (mAction != null && !mAction.equals(defAction)) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008597 uri.append("action=").append(Uri.encode(mAction)).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008598 }
8599 if (mCategories != null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07008600 for (int i=0; i<mCategories.size(); i++) {
8601 uri.append("category=").append(Uri.encode(mCategories.valueAt(i))).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008602 }
8603 }
8604 if (mType != null) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008605 uri.append("type=").append(Uri.encode(mType, "/")).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008606 }
8607 if (mFlags != 0) {
8608 uri.append("launchFlags=0x").append(Integer.toHexString(mFlags)).append(';');
8609 }
Dianne Hackborn85d558c2014-11-04 10:31:54 -08008610 if (mPackage != null && !mPackage.equals(defPackage)) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008611 uri.append("package=").append(Uri.encode(mPackage)).append(';');
8612 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008613 if (mComponent != null) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008614 uri.append("component=").append(Uri.encode(
8615 mComponent.flattenToShortString(), "/")).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008616 }
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08008617 if (mSourceBounds != null) {
8618 uri.append("sourceBounds=")
8619 .append(Uri.encode(mSourceBounds.flattenToString()))
8620 .append(';');
8621 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008622 if (mExtras != null) {
8623 for (String key : mExtras.keySet()) {
8624 final Object value = mExtras.get(key);
8625 char entryType =
8626 value instanceof String ? 'S' :
8627 value instanceof Boolean ? 'B' :
8628 value instanceof Byte ? 'b' :
8629 value instanceof Character ? 'c' :
8630 value instanceof Double ? 'd' :
8631 value instanceof Float ? 'f' :
8632 value instanceof Integer ? 'i' :
8633 value instanceof Long ? 'l' :
8634 value instanceof Short ? 's' :
8635 '\0';
8636
8637 if (entryType != '\0') {
8638 uri.append(entryType);
8639 uri.append('.');
8640 uri.append(Uri.encode(key));
8641 uri.append('=');
8642 uri.append(Uri.encode(value.toString()));
8643 uri.append(';');
8644 }
8645 }
8646 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008647 }
The Android Open Source Project10592532009-03-18 17:39:46 -07008648
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008649 public int describeContents() {
8650 return (mExtras != null) ? mExtras.describeContents() : 0;
8651 }
8652
8653 public void writeToParcel(Parcel out, int flags) {
8654 out.writeString(mAction);
8655 Uri.writeToParcel(out, mData);
8656 out.writeString(mType);
8657 out.writeInt(mFlags);
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008658 out.writeString(mPackage);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008659 ComponentName.writeToParcel(mComponent, out);
8660
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08008661 if (mSourceBounds != null) {
8662 out.writeInt(1);
8663 mSourceBounds.writeToParcel(out, flags);
8664 } else {
8665 out.writeInt(0);
8666 }
8667
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008668 if (mCategories != null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07008669 final int N = mCategories.size();
8670 out.writeInt(N);
8671 for (int i=0; i<N; i++) {
8672 out.writeString(mCategories.valueAt(i));
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008673 }
8674 } else {
8675 out.writeInt(0);
8676 }
8677
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008678 if (mSelector != null) {
8679 out.writeInt(1);
8680 mSelector.writeToParcel(out, flags);
8681 } else {
8682 out.writeInt(0);
8683 }
8684
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008685 if (mClipData != null) {
8686 out.writeInt(1);
8687 mClipData.writeToParcel(out, flags);
8688 } else {
8689 out.writeInt(0);
8690 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008691 out.writeInt(mContentUserHint);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008692 out.writeBundle(mExtras);
8693 }
8694
8695 public static final Parcelable.Creator<Intent> CREATOR
8696 = new Parcelable.Creator<Intent>() {
8697 public Intent createFromParcel(Parcel in) {
8698 return new Intent(in);
8699 }
8700 public Intent[] newArray(int size) {
8701 return new Intent[size];
8702 }
8703 };
8704
Dianne Hackborneb034652009-09-07 00:49:58 -07008705 /** @hide */
8706 protected Intent(Parcel in) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008707 readFromParcel(in);
8708 }
8709
8710 public void readFromParcel(Parcel in) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08008711 setAction(in.readString());
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008712 mData = Uri.CREATOR.createFromParcel(in);
8713 mType = in.readString();
8714 mFlags = in.readInt();
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008715 mPackage = in.readString();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008716 mComponent = ComponentName.readFromParcel(in);
8717
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08008718 if (in.readInt() != 0) {
8719 mSourceBounds = Rect.CREATOR.createFromParcel(in);
8720 }
8721
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008722 int N = in.readInt();
8723 if (N > 0) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07008724 mCategories = new ArraySet<String>();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008725 int i;
8726 for (i=0; i<N; i++) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08008727 mCategories.add(in.readString().intern());
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008728 }
8729 } else {
8730 mCategories = null;
8731 }
8732
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008733 if (in.readInt() != 0) {
8734 mSelector = new Intent(in);
8735 }
8736
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008737 if (in.readInt() != 0) {
8738 mClipData = new ClipData(in);
8739 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008740 mContentUserHint = in.readInt();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008741 mExtras = in.readBundle();
8742 }
8743
8744 /**
8745 * Parses the "intent" element (and its children) from XML and instantiates
8746 * an Intent object. The given XML parser should be located at the tag
8747 * where parsing should start (often named "intent"), from which the
8748 * basic action, data, type, and package and class name will be
8749 * retrieved. The function will then parse in to any child elements,
8750 * looking for <category android:name="xxx"> tags to add categories and
8751 * <extra android:name="xxx" android:value="yyy"> to attach extra data
8752 * to the intent.
8753 *
8754 * @param resources The Resources to use when inflating resources.
8755 * @param parser The XML parser pointing at an "intent" tag.
8756 * @param attrs The AttributeSet interface for retrieving extended
8757 * attribute data at the current <var>parser</var> location.
8758 * @return An Intent object matching the XML data.
8759 * @throws XmlPullParserException If there was an XML parsing error.
8760 * @throws IOException If there was an I/O error.
8761 */
8762 public static Intent parseIntent(Resources resources, XmlPullParser parser, AttributeSet attrs)
8763 throws XmlPullParserException, IOException {
8764 Intent intent = new Intent();
8765
8766 TypedArray sa = resources.obtainAttributes(attrs,
8767 com.android.internal.R.styleable.Intent);
8768
8769 intent.setAction(sa.getString(com.android.internal.R.styleable.Intent_action));
8770
8771 String data = sa.getString(com.android.internal.R.styleable.Intent_data);
8772 String mimeType = sa.getString(com.android.internal.R.styleable.Intent_mimeType);
8773 intent.setDataAndType(data != null ? Uri.parse(data) : null, mimeType);
8774
8775 String packageName = sa.getString(com.android.internal.R.styleable.Intent_targetPackage);
8776 String className = sa.getString(com.android.internal.R.styleable.Intent_targetClass);
8777 if (packageName != null && className != null) {
8778 intent.setComponent(new ComponentName(packageName, className));
8779 }
8780
8781 sa.recycle();
8782
8783 int outerDepth = parser.getDepth();
8784 int type;
8785 while ((type=parser.next()) != XmlPullParser.END_DOCUMENT
8786 && (type != XmlPullParser.END_TAG || parser.getDepth() > outerDepth)) {
8787 if (type == XmlPullParser.END_TAG || type == XmlPullParser.TEXT) {
8788 continue;
8789 }
8790
8791 String nodeName = parser.getName();
Craig Mautner21d24a22014-04-23 11:45:37 -07008792 if (nodeName.equals(TAG_CATEGORIES)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008793 sa = resources.obtainAttributes(attrs,
8794 com.android.internal.R.styleable.IntentCategory);
8795 String cat = sa.getString(com.android.internal.R.styleable.IntentCategory_name);
8796 sa.recycle();
8797
8798 if (cat != null) {
8799 intent.addCategory(cat);
8800 }
8801 XmlUtils.skipCurrentTag(parser);
8802
Craig Mautner21d24a22014-04-23 11:45:37 -07008803 } else if (nodeName.equals(TAG_EXTRA)) {
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08008804 if (intent.mExtras == null) {
8805 intent.mExtras = new Bundle();
8806 }
Craig Mautner21d24a22014-04-23 11:45:37 -07008807 resources.parseBundleExtra(TAG_EXTRA, attrs, intent.mExtras);
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08008808 XmlUtils.skipCurrentTag(parser);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008809
8810 } else {
8811 XmlUtils.skipCurrentTag(parser);
8812 }
8813 }
8814
8815 return intent;
8816 }
Nick Pellyccae4122012-01-09 14:12:58 -08008817
Craig Mautner21d24a22014-04-23 11:45:37 -07008818 /** @hide */
8819 public void saveToXml(XmlSerializer out) throws IOException {
8820 if (mAction != null) {
8821 out.attribute(null, ATTR_ACTION, mAction);
8822 }
8823 if (mData != null) {
8824 out.attribute(null, ATTR_DATA, mData.toString());
8825 }
8826 if (mType != null) {
8827 out.attribute(null, ATTR_TYPE, mType);
8828 }
8829 if (mComponent != null) {
8830 out.attribute(null, ATTR_COMPONENT, mComponent.flattenToShortString());
8831 }
8832 out.attribute(null, ATTR_FLAGS, Integer.toHexString(getFlags()));
8833
8834 if (mCategories != null) {
8835 out.startTag(null, TAG_CATEGORIES);
8836 for (int categoryNdx = mCategories.size() - 1; categoryNdx >= 0; --categoryNdx) {
8837 out.attribute(null, ATTR_CATEGORY, mCategories.valueAt(categoryNdx));
8838 }
Craig Mautner43e52ed2014-06-16 17:18:52 -07008839 out.endTag(null, TAG_CATEGORIES);
Craig Mautner21d24a22014-04-23 11:45:37 -07008840 }
8841 }
8842
8843 /** @hide */
8844 public static Intent restoreFromXml(XmlPullParser in) throws IOException,
8845 XmlPullParserException {
8846 Intent intent = new Intent();
8847 final int outerDepth = in.getDepth();
8848
8849 int attrCount = in.getAttributeCount();
8850 for (int attrNdx = attrCount - 1; attrNdx >= 0; --attrNdx) {
8851 final String attrName = in.getAttributeName(attrNdx);
8852 final String attrValue = in.getAttributeValue(attrNdx);
8853 if (ATTR_ACTION.equals(attrName)) {
8854 intent.setAction(attrValue);
8855 } else if (ATTR_DATA.equals(attrName)) {
8856 intent.setData(Uri.parse(attrValue));
8857 } else if (ATTR_TYPE.equals(attrName)) {
8858 intent.setType(attrValue);
8859 } else if (ATTR_COMPONENT.equals(attrName)) {
8860 intent.setComponent(ComponentName.unflattenFromString(attrValue));
8861 } else if (ATTR_FLAGS.equals(attrName)) {
8862 intent.setFlags(Integer.valueOf(attrValue, 16));
8863 } else {
8864 Log.e("Intent", "restoreFromXml: unknown attribute=" + attrName);
8865 }
8866 }
8867
8868 int event;
8869 String name;
8870 while (((event = in.next()) != XmlPullParser.END_DOCUMENT) &&
8871 (event != XmlPullParser.END_TAG || in.getDepth() < outerDepth)) {
8872 if (event == XmlPullParser.START_TAG) {
8873 name = in.getName();
8874 if (TAG_CATEGORIES.equals(name)) {
8875 attrCount = in.getAttributeCount();
8876 for (int attrNdx = attrCount - 1; attrNdx >= 0; --attrNdx) {
8877 intent.addCategory(in.getAttributeValue(attrNdx));
8878 }
8879 } else {
8880 Log.w("Intent", "restoreFromXml: unknown name=" + name);
8881 XmlUtils.skipCurrentTag(in);
8882 }
8883 }
8884 }
8885
8886 return intent;
8887 }
8888
Nick Pellyccae4122012-01-09 14:12:58 -08008889 /**
8890 * Normalize a MIME data type.
8891 *
8892 * <p>A normalized MIME type has white-space trimmed,
8893 * content-type parameters removed, and is lower-case.
8894 * This aligns the type with Android best practices for
8895 * intent filtering.
8896 *
8897 * <p>For example, "text/plain; charset=utf-8" becomes "text/plain".
8898 * "text/x-vCard" becomes "text/x-vcard".
8899 *
8900 * <p>All MIME types received from outside Android (such as user input,
8901 * or external sources like Bluetooth, NFC, or the Internet) should
8902 * be normalized before they are used to create an Intent.
8903 *
8904 * @param type MIME data type to normalize
8905 * @return normalized MIME data type, or null if the input was null
John Spurlock125d1332013-11-25 11:58:37 -05008906 * @see #setType
8907 * @see #setTypeAndNormalize
Nick Pellyccae4122012-01-09 14:12:58 -08008908 */
8909 public static String normalizeMimeType(String type) {
8910 if (type == null) {
8911 return null;
8912 }
8913
Elliott Hughescb64d432013-08-02 10:00:44 -07008914 type = type.trim().toLowerCase(Locale.ROOT);
Nick Pellyccae4122012-01-09 14:12:58 -08008915
8916 final int semicolonIndex = type.indexOf(';');
8917 if (semicolonIndex != -1) {
8918 type = type.substring(0, semicolonIndex);
8919 }
8920 return type;
8921 }
Jeff Sharkey678d04f2012-03-23 15:41:58 -07008922
8923 /**
Jeff Sharkeya14acd22013-04-02 18:27:45 -07008924 * Prepare this {@link Intent} to leave an app process.
8925 *
8926 * @hide
8927 */
Jeff Sharkey344744b2016-01-28 19:03:30 -07008928 public void prepareToLeaveProcess(Context context) {
8929 final boolean leavingPackage = (mComponent == null)
8930 || !Objects.equals(mComponent.getPackageName(), context.getPackageName());
8931 prepareToLeaveProcess(leavingPackage);
8932 }
8933
8934 /**
8935 * Prepare this {@link Intent} to leave an app process.
8936 *
8937 * @hide
8938 */
8939 public void prepareToLeaveProcess(boolean leavingPackage) {
Jeff Sharkeya14acd22013-04-02 18:27:45 -07008940 setAllowFds(false);
8941
8942 if (mSelector != null) {
Jeff Sharkey344744b2016-01-28 19:03:30 -07008943 mSelector.prepareToLeaveProcess(leavingPackage);
Jeff Sharkeya14acd22013-04-02 18:27:45 -07008944 }
8945 if (mClipData != null) {
Jeff Sharkey344744b2016-01-28 19:03:30 -07008946 mClipData.prepareToLeaveProcess(leavingPackage);
Jeff Sharkeya14acd22013-04-02 18:27:45 -07008947 }
8948
Jeff Sharkeya8b42782016-01-30 17:58:09 -07008949 if (mAction != null && mData != null && StrictMode.vmFileUriExposureEnabled()
8950 && leavingPackage) {
Jeff Sharkey344744b2016-01-28 19:03:30 -07008951 switch (mAction) {
8952 case ACTION_MEDIA_REMOVED:
8953 case ACTION_MEDIA_UNMOUNTED:
8954 case ACTION_MEDIA_CHECKING:
8955 case ACTION_MEDIA_NOFS:
8956 case ACTION_MEDIA_MOUNTED:
8957 case ACTION_MEDIA_SHARED:
8958 case ACTION_MEDIA_UNSHARED:
8959 case ACTION_MEDIA_BAD_REMOVAL:
8960 case ACTION_MEDIA_UNMOUNTABLE:
8961 case ACTION_MEDIA_EJECT:
8962 case ACTION_MEDIA_SCANNER_STARTED:
8963 case ACTION_MEDIA_SCANNER_FINISHED:
8964 case ACTION_MEDIA_SCANNER_SCAN_FILE:
Jeff Sharkey37355a92016-02-05 16:19:10 -07008965 case ACTION_PACKAGE_NEEDS_VERIFICATION:
8966 case ACTION_PACKAGE_VERIFIED:
Jeff Sharkey344744b2016-01-28 19:03:30 -07008967 // Ignore legacy actions
8968 break;
8969 default:
8970 mData.checkFileUriExposed("Intent.getData()");
Jeff Sharkeya14acd22013-04-02 18:27:45 -07008971 }
8972 }
8973 }
8974
8975 /**
Nicolas Prevotd85fc722014-04-16 19:52:08 +01008976 * @hide
8977 */
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008978 public void prepareToEnterProcess() {
Jeff Sharkeyd136e512016-03-09 22:30:56 -07008979 // We just entered destination process, so we should be able to read all
8980 // parcelables inside.
8981 setDefusable(true);
8982
8983 if (mSelector != null) {
8984 mSelector.prepareToEnterProcess();
8985 }
8986 if (mClipData != null) {
8987 mClipData.prepareToEnterProcess();
8988 }
8989
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008990 if (mContentUserHint != UserHandle.USER_CURRENT) {
Nicolas Prevotc4fc00a2014-10-31 12:01:32 +00008991 if (UserHandle.getAppId(Process.myUid()) != Process.SYSTEM_UID) {
8992 fixUris(mContentUserHint);
8993 mContentUserHint = UserHandle.USER_CURRENT;
8994 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008995 }
8996 }
8997
8998 /**
8999 * @hide
9000 */
9001 public void fixUris(int contentUserHint) {
Nicolas Prevotd85fc722014-04-16 19:52:08 +01009002 Uri data = getData();
9003 if (data != null) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009004 mData = maybeAddUserId(data, contentUserHint);
Nicolas Prevotd85fc722014-04-16 19:52:08 +01009005 }
9006 if (mClipData != null) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009007 mClipData.fixUris(contentUserHint);
Nicolas Prevotd85fc722014-04-16 19:52:08 +01009008 }
9009 String action = getAction();
9010 if (ACTION_SEND.equals(action)) {
9011 final Uri stream = getParcelableExtra(EXTRA_STREAM);
9012 if (stream != null) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009013 putExtra(EXTRA_STREAM, maybeAddUserId(stream, contentUserHint));
Nicolas Prevotd85fc722014-04-16 19:52:08 +01009014 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009015 } else if (ACTION_SEND_MULTIPLE.equals(action)) {
Nicolas Prevotd85fc722014-04-16 19:52:08 +01009016 final ArrayList<Uri> streams = getParcelableArrayListExtra(EXTRA_STREAM);
9017 if (streams != null) {
9018 ArrayList<Uri> newStreams = new ArrayList<Uri>();
9019 for (int i = 0; i < streams.size(); i++) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009020 newStreams.add(maybeAddUserId(streams.get(i), contentUserHint));
Nicolas Prevotd85fc722014-04-16 19:52:08 +01009021 }
9022 putParcelableArrayListExtra(EXTRA_STREAM, newStreams);
9023 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009024 } else if (MediaStore.ACTION_IMAGE_CAPTURE.equals(action)
9025 || MediaStore.ACTION_IMAGE_CAPTURE_SECURE.equals(action)
9026 || MediaStore.ACTION_VIDEO_CAPTURE.equals(action)) {
9027 final Uri output = getParcelableExtra(MediaStore.EXTRA_OUTPUT);
9028 if (output != null) {
9029 putExtra(MediaStore.EXTRA_OUTPUT, maybeAddUserId(output, contentUserHint));
9030 }
Nicolas Prevotd85fc722014-04-16 19:52:08 +01009031 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009032 }
Nicolas Prevotd85fc722014-04-16 19:52:08 +01009033
9034 /**
Jeff Sharkey678d04f2012-03-23 15:41:58 -07009035 * Migrate any {@link #EXTRA_STREAM} in {@link #ACTION_SEND} and
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009036 * {@link #ACTION_SEND_MULTIPLE} to {@link ClipData}. Also inspects nested
9037 * intents in {@link #ACTION_CHOOSER}.
Jeff Sharkey678d04f2012-03-23 15:41:58 -07009038 *
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009039 * @return Whether any contents were migrated.
Jeff Sharkey678d04f2012-03-23 15:41:58 -07009040 * @hide
9041 */
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009042 public boolean migrateExtraStreamToClipData() {
Jeff Sharkey678d04f2012-03-23 15:41:58 -07009043 // Refuse to touch if extras already parcelled
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009044 if (mExtras != null && mExtras.isParcelled()) return false;
Jeff Sharkey678d04f2012-03-23 15:41:58 -07009045
9046 // Bail when someone already gave us ClipData
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009047 if (getClipData() != null) return false;
Jeff Sharkey678d04f2012-03-23 15:41:58 -07009048
9049 final String action = getAction();
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009050 if (ACTION_CHOOSER.equals(action)) {
Jeff Sharkeyc004eef2014-09-23 16:40:50 -07009051 // Inspect contained intents to see if we need to migrate extras. We
9052 // don't promote ClipData to the parent, since ChooserActivity will
9053 // already start the picked item as the caller, and we can't combine
9054 // the flags in a safe way.
9055
9056 boolean migrated = false;
Jeff Sharkey1c297002012-05-18 13:55:47 -07009057 try {
Jeff Sharkeyc004eef2014-09-23 16:40:50 -07009058 final Intent intent = getParcelableExtra(EXTRA_INTENT);
9059 if (intent != null) {
9060 migrated |= intent.migrateExtraStreamToClipData();
Jeff Sharkey1c297002012-05-18 13:55:47 -07009061 }
9062 } catch (ClassCastException e) {
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009063 }
Jeff Sharkeyc004eef2014-09-23 16:40:50 -07009064 try {
9065 final Parcelable[] intents = getParcelableArrayExtra(EXTRA_INITIAL_INTENTS);
9066 if (intents != null) {
9067 for (int i = 0; i < intents.length; i++) {
9068 final Intent intent = (Intent) intents[i];
9069 if (intent != null) {
9070 migrated |= intent.migrateExtraStreamToClipData();
9071 }
9072 }
9073 }
9074 } catch (ClassCastException e) {
9075 }
9076 return migrated;
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009077
9078 } else if (ACTION_SEND.equals(action)) {
Jeff Sharkeyf27ea662012-03-27 10:34:24 -07009079 try {
Jeff Sharkeydd471e62012-05-01 13:07:01 -07009080 final Uri stream = getParcelableExtra(EXTRA_STREAM);
9081 final CharSequence text = getCharSequenceExtra(EXTRA_TEXT);
9082 final String htmlText = getStringExtra(EXTRA_HTML_TEXT);
9083 if (stream != null || text != null || htmlText != null) {
9084 final ClipData clipData = new ClipData(
9085 null, new String[] { getType() },
9086 new ClipData.Item(text, htmlText, null, stream));
9087 setClipData(clipData);
9088 addFlags(FLAG_GRANT_READ_URI_PERMISSION);
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009089 return true;
Jeff Sharkeydd471e62012-05-01 13:07:01 -07009090 }
Jeff Sharkeyf27ea662012-03-27 10:34:24 -07009091 } catch (ClassCastException e) {
Jeff Sharkeyf27ea662012-03-27 10:34:24 -07009092 }
Jeff Sharkey678d04f2012-03-23 15:41:58 -07009093
9094 } else if (ACTION_SEND_MULTIPLE.equals(action)) {
Jeff Sharkeyf27ea662012-03-27 10:34:24 -07009095 try {
Jeff Sharkeydd471e62012-05-01 13:07:01 -07009096 final ArrayList<Uri> streams = getParcelableArrayListExtra(EXTRA_STREAM);
9097 final ArrayList<CharSequence> texts = getCharSequenceArrayListExtra(EXTRA_TEXT);
9098 final ArrayList<String> htmlTexts = getStringArrayListExtra(EXTRA_HTML_TEXT);
9099 int num = -1;
9100 if (streams != null) {
9101 num = streams.size();
9102 }
9103 if (texts != null) {
9104 if (num >= 0 && num != texts.size()) {
9105 // Wha...! F- you.
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009106 return false;
Jeff Sharkeydd471e62012-05-01 13:07:01 -07009107 }
9108 num = texts.size();
9109 }
9110 if (htmlTexts != null) {
9111 if (num >= 0 && num != htmlTexts.size()) {
9112 // Wha...! F- you.
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009113 return false;
Jeff Sharkeydd471e62012-05-01 13:07:01 -07009114 }
9115 num = htmlTexts.size();
9116 }
9117 if (num > 0) {
9118 final ClipData clipData = new ClipData(
9119 null, new String[] { getType() },
9120 makeClipItem(streams, texts, htmlTexts, 0));
9121
9122 for (int i = 1; i < num; i++) {
9123 clipData.addItem(makeClipItem(streams, texts, htmlTexts, i));
9124 }
9125
9126 setClipData(clipData);
9127 addFlags(FLAG_GRANT_READ_URI_PERMISSION);
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009128 return true;
Jeff Sharkeydd471e62012-05-01 13:07:01 -07009129 }
Jeff Sharkeyf27ea662012-03-27 10:34:24 -07009130 } catch (ClassCastException e) {
Jeff Sharkeyf27ea662012-03-27 10:34:24 -07009131 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009132 } else if (MediaStore.ACTION_IMAGE_CAPTURE.equals(action)
9133 || MediaStore.ACTION_IMAGE_CAPTURE_SECURE.equals(action)
9134 || MediaStore.ACTION_VIDEO_CAPTURE.equals(action)) {
9135 final Uri output;
9136 try {
9137 output = getParcelableExtra(MediaStore.EXTRA_OUTPUT);
9138 } catch (ClassCastException e) {
9139 return false;
9140 }
9141 if (output != null) {
9142 setClipData(ClipData.newRawUri("", output));
9143 addFlags(FLAG_GRANT_WRITE_URI_PERMISSION|FLAG_GRANT_READ_URI_PERMISSION);
9144 return true;
9145 }
Jeff Sharkey678d04f2012-03-23 15:41:58 -07009146 }
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009147
9148 return false;
Jeff Sharkey678d04f2012-03-23 15:41:58 -07009149 }
Dianne Hackbornac4243f2012-04-13 17:32:18 -07009150
9151 private static ClipData.Item makeClipItem(ArrayList<Uri> streams, ArrayList<CharSequence> texts,
9152 ArrayList<String> htmlTexts, int which) {
9153 Uri uri = streams != null ? streams.get(which) : null;
9154 CharSequence text = texts != null ? texts.get(which) : null;
9155 String htmlText = htmlTexts != null ? htmlTexts.get(which) : null;
9156 return new ClipData.Item(text, htmlText, null, uri);
9157 }
Craig Mautnerd00f4742014-03-12 14:17:26 -07009158
9159 /** @hide */
9160 public boolean isDocument() {
9161 return (mFlags & FLAG_ACTIVITY_NEW_DOCUMENT) == FLAG_ACTIVITY_NEW_DOCUMENT;
9162 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009163}