blob: 207b70af3f603f7648b97b6a60c414b427672de8 [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 /**
Adam Powell52c39212016-04-07 15:14:18 -07003733 * A {@link ComponentName ComponentName[]} describing components that should be filtered out
3734 * and omitted from a list of components presented to the user.
3735 *
3736 * <p>When used with {@link #ACTION_CHOOSER}, the chooser will omit any of the components
3737 * in this array if it otherwise would have shown them. Useful for omitting specific targets
3738 * from your own package or other apps from your organization if the idea of sending to those
3739 * targets would be redundant with other app functionality. Filtered components will not
3740 * be able to present targets from an associated <code>ChooserTargetService</code>.</p>
3741 */
3742 public static final String EXTRA_EXCLUDE_COMPONENTS
3743 = "android.intent.extra.EXCLUDE_COMPONENTS";
3744
3745 /**
3746 * A {@link android.service.chooser.ChooserTarget ChooserTarget[]} for {@link #ACTION_CHOOSER}
3747 * describing additional high-priority deep-link targets for the chooser to present to the user.
3748 *
3749 * <p>Targets provided in this way will be presented inline with all other targets provided
3750 * by services from other apps. They will be prioritized before other service targets, but
3751 * after those targets provided by sources that the user has manually pinned to the front.</p>
3752 *
3753 * @see #ACTION_CHOOSER
3754 */
3755 public static final String EXTRA_CHOOSER_TARGETS = "android.intent.extra.CHOOSER_TARGETS";
3756
3757 /**
Adam Powell2ed547e2015-04-29 18:45:04 -07003758 * An {@link IntentSender} for an Activity that will be invoked when the user makes a selection
3759 * from the chooser activity presented by {@link #ACTION_CHOOSER}.
3760 *
3761 * <p>An app preparing an action for another app to complete may wish to allow the user to
3762 * disambiguate between several options for completing the action based on the chosen target
3763 * or otherwise refine the action before it is invoked.
3764 * </p>
3765 *
3766 * <p>When sent, this IntentSender may be filled in with the following extras:</p>
3767 * <ul>
3768 * <li>{@link #EXTRA_INTENT} The first intent that matched the user's chosen target</li>
3769 * <li>{@link #EXTRA_ALTERNATE_INTENTS} Any additional intents that also matched the user's
3770 * chosen target beyond the first</li>
3771 * <li>{@link #EXTRA_RESULT_RECEIVER} A {@link ResultReceiver} that the refinement activity
3772 * should fill in and send once the disambiguation is complete</li>
3773 * </ul>
3774 */
3775 public static final String EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER
3776 = "android.intent.extra.CHOOSER_REFINEMENT_INTENT_SENDER";
3777
3778 /**
3779 * A {@link ResultReceiver} used to return data back to the sender.
3780 *
3781 * <p>Used to complete an app-specific
3782 * {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER refinement} for {@link #ACTION_CHOOSER}.</p>
3783 *
3784 * <p>If {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER} is present in the intent
3785 * used to start a {@link #ACTION_CHOOSER} activity this extra will be
3786 * {@link #fillIn(Intent, int) filled in} to that {@link IntentSender} and sent
3787 * when the user selects a target component from the chooser. It is up to the recipient
3788 * to send a result to this ResultReceiver to signal that disambiguation is complete
3789 * and that the chooser should invoke the user's choice.</p>
3790 *
3791 * <p>The disambiguator should provide a Bundle to the ResultReceiver with an intent
3792 * assigned to the key {@link #EXTRA_INTENT}. This supplied intent will be used by the chooser
3793 * to match and fill in the final Intent or ChooserTarget before starting it.
3794 * The supplied intent must {@link #filterEquals(Intent) match} one of the intents from
3795 * {@link #EXTRA_INTENT} or {@link #EXTRA_ALTERNATE_INTENTS} passed to
3796 * {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER} to be accepted.</p>
3797 *
3798 * <p>The result code passed to the ResultReceiver should be
3799 * {@link android.app.Activity#RESULT_OK} if the refinement succeeded and the supplied intent's
3800 * target in the chooser should be started, or {@link android.app.Activity#RESULT_CANCELED} if
3801 * the chooser should finish without starting a target.</p>
3802 */
3803 public static final String EXTRA_RESULT_RECEIVER
3804 = "android.intent.extra.RESULT_RECEIVER";
3805
3806 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003807 * A CharSequence dialog title to provide to the user when used with a
Jim Miller4d64746d2014-08-13 21:08:41 +00003808 * {@link #ACTION_CHOOSER}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003809 */
3810 public static final String EXTRA_TITLE = "android.intent.extra.TITLE";
3811
3812 /**
Dianne Hackborneb034652009-09-07 00:49:58 -07003813 * A Parcelable[] of {@link Intent} or
3814 * {@link android.content.pm.LabeledIntent} objects as set with
3815 * {@link #putExtra(String, Parcelable[])} of additional activities to place
3816 * a the front of the list of choices, when shown to the user with a
3817 * {@link #ACTION_CHOOSER}.
3818 */
3819 public static final String EXTRA_INITIAL_INTENTS = "android.intent.extra.INITIAL_INTENTS";
3820
3821 /**
Todd Kennedy7440f172015-12-09 14:31:22 -08003822 * A {@link IntentSender} to start after ephemeral installation success.
3823 * @hide
3824 */
3825 @SystemApi
3826 public static final String EXTRA_EPHEMERAL_SUCCESS = "android.intent.extra.EPHEMERAL_SUCCESS";
3827
3828 /**
3829 * A {@link IntentSender} to start after ephemeral installation failure.
3830 * @hide
3831 */
3832 @SystemApi
3833 public static final String EXTRA_EPHEMERAL_FAILURE = "android.intent.extra.EPHEMERAL_FAILURE";
3834
3835 /**
Adam Powelle49d9392014-07-17 18:45:19 -07003836 * A Bundle forming a mapping of potential target package names to different extras Bundles
3837 * to add to the default intent extras in {@link #EXTRA_INTENT} when used with
3838 * {@link #ACTION_CHOOSER}. Each key should be a package name. The package need not
3839 * be currently installed on the device.
3840 *
3841 * <p>An application may choose to provide alternate extras for the case where a user
3842 * selects an activity from a predetermined set of target packages. If the activity
3843 * the user selects from the chooser belongs to a package with its package name as
3844 * a key in this bundle, the corresponding extras for that package will be merged with
3845 * the extras already present in the intent at {@link #EXTRA_INTENT}. If a replacement
3846 * extra has the same key as an extra already present in the intent it will overwrite
3847 * the extra from the intent.</p>
3848 *
3849 * <p><em>Examples:</em>
3850 * <ul>
3851 * <li>An application may offer different {@link #EXTRA_TEXT} to an application
3852 * when sharing with it via {@link #ACTION_SEND}, augmenting a link with additional query
3853 * parameters for that target.</li>
3854 * <li>An application may offer additional metadata for known targets of a given intent
3855 * to pass along information only relevant to that target such as account or content
3856 * identifiers already known to that application.</li>
3857 * </ul></p>
3858 */
3859 public static final String EXTRA_REPLACEMENT_EXTRAS =
3860 "android.intent.extra.REPLACEMENT_EXTRAS";
3861
3862 /**
Adam Powell0b3c1122014-10-09 12:50:14 -07003863 * An {@link IntentSender} that will be notified if a user successfully chooses a target
3864 * component to handle an action in an {@link #ACTION_CHOOSER} activity. The IntentSender
3865 * will have the extra {@link #EXTRA_CHOSEN_COMPONENT} appended to it containing the
3866 * {@link ComponentName} of the chosen component.
3867 *
3868 * <p>In some situations this callback may never come, for example if the user abandons
3869 * the chooser, switches to another task or any number of other reasons. Apps should not
3870 * be written assuming that this callback will always occur.</p>
3871 */
3872 public static final String EXTRA_CHOSEN_COMPONENT_INTENT_SENDER =
3873 "android.intent.extra.CHOSEN_COMPONENT_INTENT_SENDER";
3874
3875 /**
3876 * The {@link ComponentName} chosen by the user to complete an action.
3877 *
3878 * @see #EXTRA_CHOSEN_COMPONENT_INTENT_SENDER
3879 */
3880 public static final String EXTRA_CHOSEN_COMPONENT = "android.intent.extra.CHOSEN_COMPONENT";
3881
3882 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003883 * A {@link android.view.KeyEvent} object containing the event that
3884 * triggered the creation of the Intent it is in.
3885 */
3886 public static final String EXTRA_KEY_EVENT = "android.intent.extra.KEY_EVENT";
3887
3888 /**
Mike Lockwoodbad80e02009-07-30 01:21:08 -07003889 * Set to true in {@link #ACTION_REQUEST_SHUTDOWN} to request confirmation from the user
3890 * before shutting down.
3891 *
3892 * {@hide}
3893 */
3894 public static final String EXTRA_KEY_CONFIRM = "android.intent.extra.KEY_CONFIRM";
3895
3896 /**
Yusuke Sato705ffd12015-07-21 15:52:11 -07003897 * Set to true in {@link #ACTION_REQUEST_SHUTDOWN} to indicate that the shutdown is
3898 * requested by the user.
3899 *
3900 * {@hide}
3901 */
3902 public static final String EXTRA_USER_REQUESTED_SHUTDOWN =
3903 "android.intent.extra.USER_REQUESTED_SHUTDOWN";
3904
3905 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09003906 * 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 -07003907 * {@link android.content.Intent#ACTION_PACKAGE_CHANGED} intents to override the default action
3908 * of restarting the application.
3909 */
3910 public static final String EXTRA_DONT_KILL_APP = "android.intent.extra.DONT_KILL_APP";
3911
3912 /**
3913 * A String holding the phone number originally entered in
3914 * {@link android.content.Intent#ACTION_NEW_OUTGOING_CALL}, or the actual
3915 * number to call in a {@link android.content.Intent#ACTION_CALL}.
3916 */
3917 public static final String EXTRA_PHONE_NUMBER = "android.intent.extra.PHONE_NUMBER";
Bernd Holzheyaea4b672010-03-31 09:46:13 +02003918
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003919 /**
3920 * Used as an int extra field in {@link android.content.Intent#ACTION_UID_REMOVED}
3921 * intents to supply the uid the package had been assigned. Also an optional
3922 * extra in {@link android.content.Intent#ACTION_PACKAGE_REMOVED} or
3923 * {@link android.content.Intent#ACTION_PACKAGE_CHANGED} for the same
3924 * purpose.
3925 */
3926 public static final String EXTRA_UID = "android.intent.extra.UID";
3927
3928 /**
Dianne Hackborn21f1bd12010-02-19 17:02:21 -08003929 * @hide String array of package names.
3930 */
Soonil Nagarkar0e8fd092015-02-10 10:37:36 -08003931 @SystemApi
Dianne Hackborn21f1bd12010-02-19 17:02:21 -08003932 public static final String EXTRA_PACKAGES = "android.intent.extra.PACKAGES";
3933
3934 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003935 * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED}
3936 * intents to indicate whether this represents a full uninstall (removing
3937 * both the code and its data) or a partial uninstall (leaving its data,
3938 * implying that this is an update).
3939 */
3940 public static final String EXTRA_DATA_REMOVED = "android.intent.extra.DATA_REMOVED";
The Android Open Source Project10592532009-03-18 17:39:46 -07003941
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003942 /**
Dianne Hackbornc72fc672012-09-20 13:12:03 -07003943 * @hide
3944 * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED}
3945 * intents to indicate that at this point the package has been removed for
3946 * all users on the device.
3947 */
3948 public static final String EXTRA_REMOVED_FOR_ALL_USERS
3949 = "android.intent.extra.REMOVED_FOR_ALL_USERS";
3950
3951 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003952 * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED}
3953 * intents to indicate that this is a replacement of the package, so this
3954 * broadcast will immediately be followed by an add broadcast for a
3955 * different version of the same package.
3956 */
3957 public static final String EXTRA_REPLACING = "android.intent.extra.REPLACING";
The Android Open Source Project10592532009-03-18 17:39:46 -07003958
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003959 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003960 * Used as an int extra field in {@link android.app.AlarmManager} intents
3961 * to tell the application being invoked how many pending alarms are being
3962 * delievered with the intent. For one-shot alarms this will always be 1.
3963 * For recurring alarms, this might be greater than 1 if the device was
3964 * asleep or powered off at the time an earlier alarm would have been
3965 * delivered.
3966 */
3967 public static final String EXTRA_ALARM_COUNT = "android.intent.extra.ALARM_COUNT";
Romain Guy4969af72009-06-17 10:53:19 -07003968
Jacek Surazski86b6c532009-05-13 14:38:28 +02003969 /**
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05003970 * Used as an int extra field in {@link android.content.Intent#ACTION_DOCK_EVENT}
3971 * intents to request the dock state. Possible values are
Mike Lockwood725fcbf2009-08-24 13:09:20 -07003972 * {@link android.content.Intent#EXTRA_DOCK_STATE_UNDOCKED},
3973 * {@link android.content.Intent#EXTRA_DOCK_STATE_DESK}, or
Praveen Bharathi21e941b2010-10-06 15:23:14 -05003974 * {@link android.content.Intent#EXTRA_DOCK_STATE_CAR}, or
3975 * {@link android.content.Intent#EXTRA_DOCK_STATE_LE_DESK}, or
3976 * {@link android.content.Intent#EXTRA_DOCK_STATE_HE_DESK}.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05003977 */
3978 public static final String EXTRA_DOCK_STATE = "android.intent.extra.DOCK_STATE";
3979
3980 /**
3981 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
3982 * to represent that the phone is not in any dock.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05003983 */
3984 public static final int EXTRA_DOCK_STATE_UNDOCKED = 0;
3985
3986 /**
3987 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
3988 * to represent that the phone is in a desk dock.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05003989 */
3990 public static final int EXTRA_DOCK_STATE_DESK = 1;
3991
3992 /**
3993 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
3994 * to represent that the phone is in a car dock.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05003995 */
3996 public static final int EXTRA_DOCK_STATE_CAR = 2;
3997
3998 /**
Praveen Bharathi21e941b2010-10-06 15:23:14 -05003999 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
4000 * to represent that the phone is in a analog (low end) dock.
4001 */
4002 public static final int EXTRA_DOCK_STATE_LE_DESK = 3;
4003
4004 /**
4005 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
4006 * to represent that the phone is in a digital (high end) dock.
4007 */
4008 public static final int EXTRA_DOCK_STATE_HE_DESK = 4;
4009
4010 /**
Dianne Hackborn9bfb7072009-09-22 11:37:40 -07004011 * Boolean that can be supplied as meta-data with a dock activity, to
4012 * indicate that the dock should take over the home key when it is active.
4013 */
4014 public static final String METADATA_DOCK_HOME = "android.dock_home";
Tom Taylord4a47292009-12-21 13:59:18 -08004015
Dianne Hackborn9bfb7072009-09-22 11:37:40 -07004016 /**
Jacek Surazski86b6c532009-05-13 14:38:28 +02004017 * Used as a parcelable extra field in {@link #ACTION_APP_ERROR}, containing
4018 * the bug report.
Jacek Surazski86b6c532009-05-13 14:38:28 +02004019 */
4020 public static final String EXTRA_BUG_REPORT = "android.intent.extra.BUG_REPORT";
4021
4022 /**
Wei Huang97ecc9c2009-05-11 17:44:20 -07004023 * Used in the extra field in the remote intent. It's astring token passed with the
4024 * remote intent.
4025 */
4026 public static final String EXTRA_REMOTE_INTENT_TOKEN =
4027 "android.intent.extra.remote_intent_token";
4028
Suchi Amalapurapu0214e942009-09-02 11:03:18 -07004029 /**
Dianne Hackborn1d62ea92009-11-17 12:49:50 -08004030 * @deprecated See {@link #EXTRA_CHANGED_COMPONENT_NAME_LIST}; this field
Dianne Hackborn86a72da2009-11-11 20:12:41 -08004031 * will contain only the first name in the list.
Suchi Amalapurapu0214e942009-09-02 11:03:18 -07004032 */
Dianne Hackborn1d62ea92009-11-17 12:49:50 -08004033 @Deprecated public static final String EXTRA_CHANGED_COMPONENT_NAME =
Suchi Amalapurapu0214e942009-09-02 11:03:18 -07004034 "android.intent.extra.changed_component_name";
4035
Dianne Hackborndd9b82c2009-09-03 00:18:47 -07004036 /**
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08004037 * This field is part of {@link android.content.Intent#ACTION_PACKAGE_CHANGED},
Dianne Hackbornfd7aded2013-01-22 17:10:23 -08004038 * and contains a string array of all of the components that have changed. If
4039 * the state of the overall package has changed, then it will contain an entry
4040 * with the package name itself.
Dianne Hackborn86a72da2009-11-11 20:12:41 -08004041 */
4042 public static final String EXTRA_CHANGED_COMPONENT_NAME_LIST =
4043 "android.intent.extra.changed_component_name_list";
4044
4045 /**
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08004046 * This field is part of
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08004047 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_AVAILABLE},
Andrei Stingaceanu69d5ebc2016-01-14 12:59:03 +00004048 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE},
4049 * {@link android.content.Intent#ACTION_PACKAGES_SUSPENDED},
4050 * {@link android.content.Intent#ACTION_PACKAGES_UNSUSPENDED}
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08004051 * and contains a string array of all of the components that have changed.
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08004052 */
4053 public static final String EXTRA_CHANGED_PACKAGE_LIST =
4054 "android.intent.extra.changed_package_list";
4055
4056 /**
4057 * This field is part of
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08004058 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_AVAILABLE},
4059 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE}
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08004060 * and contains an integer array of uids of all of the components
4061 * that have changed.
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08004062 */
4063 public static final String EXTRA_CHANGED_UID_LIST =
4064 "android.intent.extra.changed_uid_list";
4065
4066 /**
Dianne Hackborndd9b82c2009-09-03 00:18:47 -07004067 * @hide
4068 * Magic extra system code can use when binding, to give a label for
4069 * who it is that has bound to a service. This is an integer giving
4070 * a framework string resource that can be displayed to the user.
4071 */
4072 public static final String EXTRA_CLIENT_LABEL =
4073 "android.intent.extra.client_label";
4074
4075 /**
4076 * @hide
4077 * Magic extra system code can use when binding, to give a PendingIntent object
4078 * that can be launched for the user to disable the system's use of this
4079 * service.
4080 */
4081 public static final String EXTRA_CLIENT_INTENT =
4082 "android.intent.extra.client_intent";
4083
Dianne Hackbornc4d0e6f2011-01-25 14:55:06 -08004084 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004085 * Extra used to indicate that an intent should only return data that is on
4086 * the local device. This is a boolean extra; the default is false. If true,
4087 * an implementation should only allow the user to select data that is
4088 * already on the device, not requiring it be downloaded from a remote
4089 * service when opened.
4090 *
4091 * @see #ACTION_GET_CONTENT
4092 * @see #ACTION_OPEN_DOCUMENT
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07004093 * @see #ACTION_OPEN_DOCUMENT_TREE
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004094 * @see #ACTION_CREATE_DOCUMENT
Dianne Hackbornc4d0e6f2011-01-25 14:55:06 -08004095 */
4096 public static final String EXTRA_LOCAL_ONLY =
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004097 "android.intent.extra.LOCAL_ONLY";
Daniel Lehmanna5b58df2011-10-12 16:24:22 -07004098
Amith Yamasani13593602012-03-22 16:16:17 -07004099 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004100 * Extra used to indicate that an intent can allow the user to select and
4101 * return multiple items. This is a boolean extra; the default is false. If
4102 * true, an implementation is allowed to present the user with a UI where
4103 * they can pick multiple items that are all returned to the caller. When
4104 * this happens, they should be returned as the {@link #getClipData()} part
4105 * of the result Intent.
4106 *
4107 * @see #ACTION_GET_CONTENT
4108 * @see #ACTION_OPEN_DOCUMENT
Dianne Hackbornfdb3f092013-01-28 15:10:48 -08004109 */
4110 public static final String EXTRA_ALLOW_MULTIPLE =
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004111 "android.intent.extra.ALLOW_MULTIPLE";
Dianne Hackbornfdb3f092013-01-28 15:10:48 -08004112
4113 /**
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01004114 * The integer userHandle carried with broadcast intents related to addition, removal and
4115 * switching of users and managed profiles - {@link #ACTION_USER_ADDED},
4116 * {@link #ACTION_USER_REMOVED} and {@link #ACTION_USER_SWITCHED}.
4117 *
Amith Yamasani13593602012-03-22 16:16:17 -07004118 * @hide
4119 */
Amith Yamasani2a003292012-08-14 18:25:45 -07004120 public static final String EXTRA_USER_HANDLE =
4121 "android.intent.extra.user_handle";
Jean-Michel Trivi3114ce32012-06-11 15:03:52 -07004122
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08004123 /**
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01004124 * The UserHandle carried with broadcasts intents related to addition and removal of managed
4125 * profiles - {@link #ACTION_MANAGED_PROFILE_ADDED} and {@link #ACTION_MANAGED_PROFILE_REMOVED}.
4126 */
4127 public static final String EXTRA_USER =
Alexandra Gherghina3315f6b2014-09-05 15:48:06 +01004128 "android.intent.extra.USER";
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01004129
4130 /**
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08004131 * Extra used in the response from a BroadcastReceiver that handles
Amith Yamasani7e99bc02013-04-16 18:24:51 -07004132 * {@link #ACTION_GET_RESTRICTION_ENTRIES}. The type of the extra is
4133 * <code>ArrayList&lt;RestrictionEntry&gt;</code>.
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08004134 */
Amith Yamasani7e99bc02013-04-16 18:24:51 -07004135 public static final String EXTRA_RESTRICTIONS_LIST = "android.intent.extra.restrictions_list";
4136
4137 /**
4138 * Extra sent in the intent to the BroadcastReceiver that handles
4139 * {@link #ACTION_GET_RESTRICTION_ENTRIES}. The type of the extra is a Bundle containing
4140 * the restrictions as key/value pairs.
4141 */
4142 public static final String EXTRA_RESTRICTIONS_BUNDLE =
4143 "android.intent.extra.restrictions_bundle";
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08004144
Amith Yamasani86118ba2013-03-28 14:33:16 -07004145 /**
4146 * Extra used in the response from a BroadcastReceiver that handles
4147 * {@link #ACTION_GET_RESTRICTION_ENTRIES}.
4148 */
4149 public static final String EXTRA_RESTRICTIONS_INTENT =
4150 "android.intent.extra.restrictions_intent";
4151
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07004152 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004153 * Extra used to communicate a set of acceptable MIME types. The type of the
4154 * extra is {@code String[]}. Values may be a combination of concrete MIME
4155 * types (such as "image/png") and/or partial MIME types (such as
4156 * "audio/*").
4157 *
4158 * @see #ACTION_GET_CONTENT
4159 * @see #ACTION_OPEN_DOCUMENT
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07004160 */
4161 public static final String EXTRA_MIME_TYPES = "android.intent.extra.MIME_TYPES";
4162
Dianne Hackborn57a7f592013-07-22 18:21:32 -07004163 /**
4164 * Optional extra for {@link #ACTION_SHUTDOWN} that allows the sender to qualify that
4165 * this shutdown is only for the user space of the system, not a complete shutdown.
Dianne Hackbornd318e0b2013-09-03 14:34:12 -07004166 * When this is true, hardware devices can use this information to determine that
4167 * they shouldn't do a complete shutdown of their device since this is not a
4168 * complete shutdown down to the kernel, but only user space restarting.
4169 * The default if not supplied is false.
Dianne Hackborn57a7f592013-07-22 18:21:32 -07004170 */
4171 public static final String EXTRA_SHUTDOWN_USERSPACE_ONLY
4172 = "android.intent.extra.SHUTDOWN_USERSPACE_ONLY";
4173
Narayan Kamathccb2a0862013-12-19 14:49:36 +00004174 /**
4175 * Optional boolean extra for {@link #ACTION_TIME_CHANGED} that indicates the
4176 * user has set their time format preferences to the 24 hour format.
4177 *
4178 * @hide for internal use only.
4179 */
4180 public static final String EXTRA_TIME_PREF_24_HOUR_FORMAT =
4181 "android.intent.extra.TIME_PREF_24_HOUR_FORMAT";
4182
Jeff Sharkey004a4b22014-09-24 11:45:24 -07004183 /** {@hide} */
4184 public static final String EXTRA_REASON = "android.intent.extra.REASON";
4185
Rubin Xue8490f12015-06-25 12:17:48 +01004186 /** {@hide} */
4187 public static final String EXTRA_WIPE_EXTERNAL_STORAGE = "android.intent.extra.WIPE_EXTERNAL_STORAGE";
4188
Santos Cordon15a13782015-03-31 18:32:31 -07004189 /**
4190 * Optional {@link android.app.PendingIntent} extra used to deliver the result of the SIM
4191 * activation request.
4192 * TODO: Add information about the structure and response data used with the pending intent.
4193 * @hide
4194 */
4195 public static final String EXTRA_SIM_ACTIVATION_RESPONSE =
4196 "android.intent.extra.SIM_ACTIVATION_RESPONSE";
4197
Tomasz Mikolajewski319fb492016-01-20 12:24:01 +09004198 /**
4199 * Optional index with semantics depending on the intent action.
Tomasz Mikolajewskife023132016-03-10 17:42:35 +09004200 *
4201 * <p>The value must be an integer greater or equal to 0.
Tomasz Mikolajewski319fb492016-01-20 12:24:01 +09004202 */
Steve McKay6eaf38632015-08-04 10:11:01 -07004203 public static final String EXTRA_INDEX = "android.intent.extra.INDEX";
4204
Rubin Xu0a29ecd2015-11-04 15:11:48 +00004205 /**
4206 * Optional boolean extra indicating whether quiet mode has been switched on or off.
Rubin Xue95057a2016-04-01 16:49:25 +01004207 * When a profile goes into quiet mode, all apps in the profile are killed and the
4208 * profile user is stopped. Widgets originating from the profile are masked, and app
4209 * launcher icons are grayed out.
Rubin Xu0a29ecd2015-11-04 15:11:48 +00004210 */
4211 public static final String EXTRA_QUIET_MODE = "android.intent.extra.QUIET_MODE";
Dongwon Kang2034a4c2015-12-14 21:57:34 +09004212
4213 /**
Dongwon Kang32cb9ab2016-01-13 18:11:10 -08004214 * Used as an int extra field in {@link #ACTION_MEDIA_RESOURCE_GRANTED}
Dongwon Kang2034a4c2015-12-14 21:57:34 +09004215 * intents to specify the resource type granted. Possible values are
Dongwon Kang32cb9ab2016-01-13 18:11:10 -08004216 * {@link #EXTRA_MEDIA_RESOURCE_TYPE_VIDEO_CODEC} or
4217 * {@link #EXTRA_MEDIA_RESOURCE_TYPE_AUDIO_CODEC}.
Dongwon Kang2034a4c2015-12-14 21:57:34 +09004218 *
4219 * @hide
4220 */
4221 public static final String EXTRA_MEDIA_RESOURCE_TYPE =
4222 "android.intent.extra.MEDIA_RESOURCE_TYPE";
4223
4224 /**
Dongwon Kang32cb9ab2016-01-13 18:11:10 -08004225 * Used as an int value for {@link #EXTRA_MEDIA_RESOURCE_TYPE}
Dongwon Kang2034a4c2015-12-14 21:57:34 +09004226 * to represent that a video codec is allowed to use.
4227 *
4228 * @hide
4229 */
4230 public static final int EXTRA_MEDIA_RESOURCE_TYPE_VIDEO_CODEC = 0;
4231
4232 /**
Dongwon Kang32cb9ab2016-01-13 18:11:10 -08004233 * Used as an int value for {@link #EXTRA_MEDIA_RESOURCE_TYPE}
Dongwon Kang2034a4c2015-12-14 21:57:34 +09004234 * to represent that a audio codec is allowed to use.
4235 *
4236 * @hide
4237 */
4238 public static final int EXTRA_MEDIA_RESOURCE_TYPE_AUDIO_CODEC = 1;
4239
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004240 // ---------------------------------------------------------------------
4241 // ---------------------------------------------------------------------
4242 // Intent flags (see mFlags variable).
4243
Tor Norbyed9273d62013-05-30 15:59:53 -07004244 /** @hide */
Jeff Sharkey846318a2014-04-04 12:12:41 -07004245 @IntDef(flag = true, value = {
4246 FLAG_GRANT_READ_URI_PERMISSION, FLAG_GRANT_WRITE_URI_PERMISSION,
4247 FLAG_GRANT_PERSISTABLE_URI_PERMISSION, FLAG_GRANT_PREFIX_URI_PERMISSION })
Tor Norbyed9273d62013-05-30 15:59:53 -07004248 @Retention(RetentionPolicy.SOURCE)
4249 public @interface GrantUriMode {}
4250
Jeff Sharkey846318a2014-04-04 12:12:41 -07004251 /** @hide */
4252 @IntDef(flag = true, value = {
4253 FLAG_GRANT_READ_URI_PERMISSION, FLAG_GRANT_WRITE_URI_PERMISSION })
4254 @Retention(RetentionPolicy.SOURCE)
4255 public @interface AccessUriMode {}
4256
4257 /**
4258 * Test if given mode flags specify an access mode, which must be at least
4259 * read and/or write.
4260 *
4261 * @hide
4262 */
4263 public static boolean isAccessUriMode(int modeFlags) {
4264 return (modeFlags & (Intent.FLAG_GRANT_READ_URI_PERMISSION
4265 | Intent.FLAG_GRANT_WRITE_URI_PERMISSION)) != 0;
4266 }
4267
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004268 /**
4269 * If set, the recipient of this Intent will be granted permission to
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004270 * perform read operations on the URI in the Intent's data and any URIs
Dianne Hackborn21c241e2012-03-08 13:57:23 -08004271 * specified in its ClipData. When applying to an Intent's ClipData,
4272 * all URIs as well as recursive traversals through data or other ClipData
4273 * in Intent items will be granted; only the grant flags of the top-level
4274 * Intent are used.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004275 */
4276 public static final int FLAG_GRANT_READ_URI_PERMISSION = 0x00000001;
4277 /**
4278 * If set, the recipient of this Intent will be granted permission to
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004279 * perform write operations on the URI in the Intent's data and any URIs
Dianne Hackborn21c241e2012-03-08 13:57:23 -08004280 * specified in its ClipData. When applying to an Intent's ClipData,
4281 * all URIs as well as recursive traversals through data or other ClipData
4282 * in Intent items will be granted; only the grant flags of the top-level
4283 * Intent are used.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004284 */
4285 public static final int FLAG_GRANT_WRITE_URI_PERMISSION = 0x00000002;
4286 /**
4287 * Can be set by the caller to indicate that this Intent is coming from
4288 * a background operation, not from direct user interaction.
4289 */
4290 public static final int FLAG_FROM_BACKGROUND = 0x00000004;
4291 /**
4292 * A flag you can enable for debugging: when set, log messages will be
4293 * printed during the resolution of this intent to show you what has
4294 * been found to create the final resolved list.
4295 */
4296 public static final int FLAG_DEBUG_LOG_RESOLUTION = 0x00000008;
Dianne Hackborne7f97212011-02-24 14:40:20 -08004297 /**
4298 * If set, this intent will not match any components in packages that
4299 * are currently stopped. If this is not set, then the default behavior
4300 * is to include such applications in the result.
4301 */
4302 public static final int FLAG_EXCLUDE_STOPPED_PACKAGES = 0x00000010;
4303 /**
4304 * If set, this intent will always match any components in packages that
4305 * are currently stopped. This is the default behavior when
4306 * {@link #FLAG_EXCLUDE_STOPPED_PACKAGES} is not set. If both of these
4307 * flags are set, this one wins (it allows overriding of exclude for
4308 * places where the framework may automatically set the exclude flag).
4309 */
4310 public static final int FLAG_INCLUDE_STOPPED_PACKAGES = 0x00000020;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004311
4312 /**
Jeff Sharkey328ebf22013-03-21 18:09:39 -07004313 * When combined with {@link #FLAG_GRANT_READ_URI_PERMISSION} and/or
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004314 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, the URI permission grant can be
Jeff Sharkeye66c1772013-09-20 14:30:59 -07004315 * persisted across device reboots until explicitly revoked with
4316 * {@link Context#revokeUriPermission(Uri, int)}. This flag only offers the
4317 * grant for possible persisting; the receiving application must call
4318 * {@link ContentResolver#takePersistableUriPermission(Uri, int)} to
4319 * actually persist.
4320 *
4321 * @see ContentResolver#takePersistableUriPermission(Uri, int)
4322 * @see ContentResolver#releasePersistableUriPermission(Uri, int)
4323 * @see ContentResolver#getPersistedUriPermissions()
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004324 * @see ContentResolver#getOutgoingPersistedUriPermissions()
Jeff Sharkey328ebf22013-03-21 18:09:39 -07004325 */
Jeff Sharkeye66c1772013-09-20 14:30:59 -07004326 public static final int FLAG_GRANT_PERSISTABLE_URI_PERMISSION = 0x00000040;
Jeff Sharkey328ebf22013-03-21 18:09:39 -07004327
4328 /**
Jeff Sharkey846318a2014-04-04 12:12:41 -07004329 * When combined with {@link #FLAG_GRANT_READ_URI_PERMISSION} and/or
4330 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, the URI permission grant
4331 * applies to any URI that is a prefix match against the original granted
4332 * URI. (Without this flag, the URI must match exactly for access to be
4333 * granted.) Another URI is considered a prefix match only when scheme,
4334 * authority, and all path segments defined by the prefix are an exact
4335 * match.
4336 */
4337 public static final int FLAG_GRANT_PREFIX_URI_PERMISSION = 0x00000080;
4338
4339 /**
Jeff Sharkey2a9e3f82015-12-18 10:57:58 -07004340 * Internal flag used to indicate that a system component has done their
Jeff Sharkey2f3e3532015-12-21 14:16:43 -07004341 * homework and verified that they correctly handle packages and components
4342 * that come and go over time. In particular:
4343 * <ul>
4344 * <li>Apps installed on external storage, which will appear to be
4345 * uninstalled while the the device is ejected.
4346 * <li>Apps with encryption unaware components, which will appear to not
4347 * exist while the device is locked.
4348 * </ul>
Jeff Sharkey2a9e3f82015-12-18 10:57:58 -07004349 *
4350 * @hide
4351 */
Jeff Sharkey2f3e3532015-12-21 14:16:43 -07004352 public static final int FLAG_DEBUG_TRIAGED_MISSING = 0x00000100;
Jeff Sharkey2a9e3f82015-12-18 10:57:58 -07004353
4354 /**
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08004355 * If set, the new activity is not kept in the history stack. As soon as
4356 * the user navigates away from it, the activity is finished. This may also
4357 * be set with the {@link android.R.styleable#AndroidManifestActivity_noHistory
4358 * noHistory} attribute.
Ricardo Cervera92f6a742014-04-04 11:17:06 -07004359 *
4360 * <p>If set, {@link android.app.Activity#onActivityResult onActivityResult()}
4361 * is never invoked when the current activity starts a new activity which
4362 * sets a result and finishes.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004363 */
4364 public static final int FLAG_ACTIVITY_NO_HISTORY = 0x40000000;
4365 /**
4366 * If set, the activity will not be launched if it is already running
4367 * at the top of the history stack.
4368 */
4369 public static final int FLAG_ACTIVITY_SINGLE_TOP = 0x20000000;
4370 /**
4371 * If set, this activity will become the start of a new task on this
4372 * history stack. A task (from the activity that started it to the
4373 * next task activity) defines an atomic group of activities that the
4374 * user can move to. Tasks can be moved to the foreground and background;
4375 * all of the activities inside of a particular task always remain in
The Android Open Source Project10592532009-03-18 17:39:46 -07004376 * the same order. See
Scott Main7aee61f2011-02-08 11:25:01 -08004377 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
4378 * Stack</a> for more information about tasks.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004379 *
4380 * <p>This flag is generally used by activities that want
4381 * to present a "launcher" style behavior: they give the user a list of
4382 * separate things that can be done, which otherwise run completely
4383 * independently of the activity launching them.
4384 *
4385 * <p>When using this flag, if a task is already running for the activity
4386 * you are now starting, then a new activity will not be started; instead,
4387 * the current task will simply be brought to the front of the screen with
4388 * the state it was last in. See {@link #FLAG_ACTIVITY_MULTIPLE_TASK} for a flag
4389 * to disable this behavior.
4390 *
4391 * <p>This flag can not be used when the caller is requesting a result from
4392 * the activity being launched.
4393 */
4394 public static final int FLAG_ACTIVITY_NEW_TASK = 0x10000000;
4395 /**
Craig Mautnerd00f4742014-03-12 14:17:26 -07004396 * This flag is used to create a new task and launch an activity into it.
4397 * This flag is always paired with either {@link #FLAG_ACTIVITY_NEW_DOCUMENT}
4398 * or {@link #FLAG_ACTIVITY_NEW_TASK}. In both cases these flags alone would
4399 * search through existing tasks for ones matching this Intent. Only if no such
4400 * task is found would a new task be created. When paired with
4401 * FLAG_ACTIVITY_MULTIPLE_TASK both of these behaviors are modified to skip
4402 * the search for a matching task and unconditionally start a new task.
4403 *
4404 * <strong>When used with {@link #FLAG_ACTIVITY_NEW_TASK} do not use this
4405 * flag unless you are implementing your own
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004406 * top-level application launcher.</strong> Used in conjunction with
4407 * {@link #FLAG_ACTIVITY_NEW_TASK} to disable the
4408 * behavior of bringing an existing task to the foreground. When set,
4409 * a new task is <em>always</em> started to host the Activity for the
4410 * Intent, regardless of whether there is already an existing task running
4411 * the same thing.
4412 *
4413 * <p><strong>Because the default system does not include graphical task management,
4414 * you should not use this flag unless you provide some way for a user to
4415 * return back to the tasks you have launched.</strong>
The Android Open Source Project10592532009-03-18 17:39:46 -07004416 *
Craig Mautnerd00f4742014-03-12 14:17:26 -07004417 * See {@link #FLAG_ACTIVITY_NEW_DOCUMENT} for details of this flag's use for
4418 * creating new document tasks.
4419 *
4420 * <p>This flag is ignored if one of {@link #FLAG_ACTIVITY_NEW_TASK} or
Paul Soulos628cb742014-09-19 11:00:52 -07004421 * {@link #FLAG_ACTIVITY_NEW_DOCUMENT} is not also set.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004422 *
Scott Main7aee61f2011-02-08 11:25:01 -08004423 * <p>See
4424 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
4425 * Stack</a> for more information about tasks.
Craig Mautnerd00f4742014-03-12 14:17:26 -07004426 *
4427 * @see #FLAG_ACTIVITY_NEW_DOCUMENT
4428 * @see #FLAG_ACTIVITY_NEW_TASK
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004429 */
4430 public static final int FLAG_ACTIVITY_MULTIPLE_TASK = 0x08000000;
4431 /**
4432 * If set, and the activity being launched is already running in the
4433 * current task, then instead of launching a new instance of that activity,
4434 * all of the other activities on top of it will be closed and this Intent
4435 * will be delivered to the (now on top) old activity as a new Intent.
4436 *
4437 * <p>For example, consider a task consisting of the activities: A, B, C, D.
4438 * If D calls startActivity() with an Intent that resolves to the component
4439 * of activity B, then C and D will be finished and B receive the given
4440 * Intent, resulting in the stack now being: A, B.
4441 *
Dianne Hackbornaa52f9a2009-08-25 16:01:15 -07004442 * <p>The currently running instance of activity B in the above example will
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004443 * either receive the new intent you are starting here in its
4444 * onNewIntent() method, or be itself finished and restarted with the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004445 * new intent. If it has declared its launch mode to be "multiple" (the
Dianne Hackbornaa52f9a2009-08-25 16:01:15 -07004446 * default) and you have not set {@link #FLAG_ACTIVITY_SINGLE_TOP} in
4447 * the same intent, then it will be finished and re-created; for all other
4448 * launch modes or if {@link #FLAG_ACTIVITY_SINGLE_TOP} is set then this
4449 * Intent will be delivered to the current instance's onNewIntent().
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004450 *
4451 * <p>This launch mode can also be used to good effect in conjunction with
4452 * {@link #FLAG_ACTIVITY_NEW_TASK}: if used to start the root activity
4453 * of a task, it will bring any currently running instance of that task
4454 * to the foreground, and then clear it to its root state. This is
4455 * especially useful, for example, when launching an activity from the
4456 * notification manager.
4457 *
Scott Main7aee61f2011-02-08 11:25:01 -08004458 * <p>See
4459 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
4460 * Stack</a> for more information about tasks.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004461 */
4462 public static final int FLAG_ACTIVITY_CLEAR_TOP = 0x04000000;
4463 /**
4464 * If set and this intent is being used to launch a new activity from an
4465 * existing one, then the reply target of the existing activity will be
4466 * transfered to the new activity. This way the new activity can call
4467 * {@link android.app.Activity#setResult} and have that result sent back to
4468 * the reply target of the original activity.
4469 */
4470 public static final int FLAG_ACTIVITY_FORWARD_RESULT = 0x02000000;
4471 /**
4472 * If set and this intent is being used to launch a new activity from an
4473 * existing one, the current activity will not be counted as the top
4474 * activity for deciding whether the new intent should be delivered to
4475 * the top instead of starting a new one. The previous activity will
4476 * be used as the top, with the assumption being that the current activity
4477 * will finish itself immediately.
4478 */
4479 public static final int FLAG_ACTIVITY_PREVIOUS_IS_TOP = 0x01000000;
4480 /**
4481 * If set, the new activity is not kept in the list of recently launched
4482 * activities.
4483 */
4484 public static final int FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS = 0x00800000;
4485 /**
4486 * This flag is not normally set by application code, but set for you by
4487 * the system as described in the
4488 * {@link android.R.styleable#AndroidManifestActivity_launchMode
4489 * launchMode} documentation for the singleTask mode.
4490 */
4491 public static final int FLAG_ACTIVITY_BROUGHT_TO_FRONT = 0x00400000;
4492 /**
4493 * If set, and this activity is either being started in a new task or
4494 * bringing to the top an existing task, then it will be launched as
4495 * the front door of the task. This will result in the application of
4496 * any affinities needed to have that task in the proper state (either
4497 * moving activities to or from it), or simply resetting that task to
4498 * its initial state if needed.
4499 */
4500 public static final int FLAG_ACTIVITY_RESET_TASK_IF_NEEDED = 0x00200000;
4501 /**
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08004502 * This flag is not normally set by application code, but set for you by
4503 * the system if this activity is being launched from history
4504 * (longpress home key).
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004505 */
4506 public static final int FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY = 0x00100000;
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08004507 /**
Craig Mautnerf357c0c2014-06-09 09:23:27 -07004508 * @deprecated As of API 21 this performs identically to
4509 * {@link #FLAG_ACTIVITY_NEW_DOCUMENT} which should be used instead of this.
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08004510 */
4511 public static final int FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET = 0x00080000;
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08004512 /**
Craig Mautner026596b2014-05-21 15:35:44 -07004513 * This flag is used to open a document into a new task rooted at the activity launched
4514 * by this Intent. Through the use of this flag, or its equivalent attribute,
4515 * {@link android.R.attr#documentLaunchMode} multiple instances of the same activity
Chet Haase0d1c27a2014-11-03 18:35:16 +00004516 * containing different documents will appear in the recent tasks list.
Craig Mautnerd00f4742014-03-12 14:17:26 -07004517 *
Craig Mautner026596b2014-05-21 15:35:44 -07004518 * <p>The use of the activity attribute form of this,
4519 * {@link android.R.attr#documentLaunchMode}, is
4520 * preferred over the Intent flag described here. The attribute form allows the
4521 * Activity to specify multiple document behavior for all launchers of the Activity
4522 * whereas using this flag requires each Intent that launches the Activity to specify it.
Craig Mautnerd00f4742014-03-12 14:17:26 -07004523 *
Dianne Hackborn13420f22014-07-18 15:43:56 -07004524 * <p>Note that the default semantics of this flag w.r.t. whether the recents entry for
4525 * it is kept after the activity is finished is different than the use of
4526 * {@link #FLAG_ACTIVITY_NEW_TASK} and {@link android.R.attr#documentLaunchMode} -- if
4527 * this flag is being used to create a new recents entry, then by default that entry
4528 * will be removed once the activity is finished. You can modify this behavior with
4529 * {@link #FLAG_ACTIVITY_RETAIN_IN_RECENTS}.
4530 *
Craig Mautner026596b2014-05-21 15:35:44 -07004531 * <p>FLAG_ACTIVITY_NEW_DOCUMENT may be used in conjunction with {@link
4532 * #FLAG_ACTIVITY_MULTIPLE_TASK}. When used alone it is the
4533 * equivalent of the Activity manifest specifying {@link
4534 * android.R.attr#documentLaunchMode}="intoExisting". When used with
4535 * FLAG_ACTIVITY_MULTIPLE_TASK it is the equivalent of the Activity manifest specifying
4536 * {@link android.R.attr#documentLaunchMode}="always".
Craig Mautnerd00f4742014-03-12 14:17:26 -07004537 *
Craig Mautner026596b2014-05-21 15:35:44 -07004538 * Refer to {@link android.R.attr#documentLaunchMode} for more information.
Craig Mautnerd00f4742014-03-12 14:17:26 -07004539 *
Craig Mautner026596b2014-05-21 15:35:44 -07004540 * @see android.R.attr#documentLaunchMode
Craig Mautnerd00f4742014-03-12 14:17:26 -07004541 * @see #FLAG_ACTIVITY_MULTIPLE_TASK
4542 */
Craig Mautnerf357c0c2014-06-09 09:23:27 -07004543 public static final int FLAG_ACTIVITY_NEW_DOCUMENT = FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET;
Craig Mautnerd00f4742014-03-12 14:17:26 -07004544 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004545 * If set, this flag will prevent the normal {@link android.app.Activity#onUserLeaveHint}
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08004546 * callback from occurring on the current frontmost activity before it is
4547 * paused as the newly-started activity is brought to the front.
The Android Open Source Project10592532009-03-18 17:39:46 -07004548 *
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08004549 * <p>Typically, an activity can rely on that callback to indicate that an
4550 * explicit user action has caused their activity to be moved out of the
4551 * foreground. The callback marks an appropriate point in the activity's
4552 * lifecycle for it to dismiss any notifications that it intends to display
4553 * "until the user has seen them," such as a blinking LED.
The Android Open Source Project10592532009-03-18 17:39:46 -07004554 *
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08004555 * <p>If an activity is ever started via any non-user-driven events such as
4556 * phone-call receipt or an alarm handler, this flag should be passed to {@link
4557 * Context#startActivity Context.startActivity}, ensuring that the pausing
The Android Open Source Project10592532009-03-18 17:39:46 -07004558 * activity does not think the user has acknowledged its notification.
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08004559 */
4560 public static final int FLAG_ACTIVITY_NO_USER_ACTION = 0x00040000;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004561 /**
4562 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
4563 * this flag will cause the launched activity to be brought to the front of its
4564 * task's history stack if it is already running.
The Android Open Source Project10592532009-03-18 17:39:46 -07004565 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004566 * <p>For example, consider a task consisting of four activities: A, B, C, D.
4567 * If D calls startActivity() with an Intent that resolves to the component
4568 * of activity B, then B will be brought to the front of the history stack,
4569 * with this resulting order: A, C, D, B.
The Android Open Source Project10592532009-03-18 17:39:46 -07004570 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004571 * This flag will be ignored if {@link #FLAG_ACTIVITY_CLEAR_TOP} is also
The Android Open Source Project10592532009-03-18 17:39:46 -07004572 * specified.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004573 */
4574 public static final int FLAG_ACTIVITY_REORDER_TO_FRONT = 0X00020000;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004575 /**
Dianne Hackbornbfe319e2009-09-21 00:34:05 -07004576 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
4577 * this flag will prevent the system from applying an activity transition
4578 * animation to go to the next activity state. This doesn't mean an
4579 * animation will never run -- if another activity change happens that doesn't
4580 * specify this flag before the activity started here is displayed, then
Dianne Hackborn621e17d2010-11-22 15:59:56 -08004581 * that transition will be used. This flag can be put to good use
Dianne Hackbornbfe319e2009-09-21 00:34:05 -07004582 * when you are going to do a series of activity operations but the
4583 * animation seen by the user shouldn't be driven by the first activity
4584 * change but rather a later one.
4585 */
4586 public static final int FLAG_ACTIVITY_NO_ANIMATION = 0X00010000;
4587 /**
Dianne Hackborn621e17d2010-11-22 15:59:56 -08004588 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
4589 * this flag will cause any existing task that would be associated with the
4590 * activity to be cleared before the activity is started. That is, the activity
4591 * becomes the new root of an otherwise empty task, and any old activities
4592 * are finished. This can only be used in conjunction with {@link #FLAG_ACTIVITY_NEW_TASK}.
4593 */
4594 public static final int FLAG_ACTIVITY_CLEAR_TASK = 0X00008000;
4595 /**
4596 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
4597 * this flag will cause a newly launching task to be placed on top of the current
4598 * home activity task (if there is one). That is, pressing back from the task
4599 * will always return the user to home even if that was not the last activity they
4600 * saw. This can only be used in conjunction with {@link #FLAG_ACTIVITY_NEW_TASK}.
4601 */
4602 public static final int FLAG_ACTIVITY_TASK_ON_HOME = 0X00004000;
4603 /**
Dianne Hackborn13420f22014-07-18 15:43:56 -07004604 * By default a document created by {@link #FLAG_ACTIVITY_NEW_DOCUMENT} will
4605 * have its entry in recent tasks removed when the user closes it (with back
Jeff Sharkey9f991a22014-08-13 11:37:41 -07004606 * or however else it may finish()). If you would like to instead allow the
Dianne Hackborn13420f22014-07-18 15:43:56 -07004607 * document to be kept in recents so that it can be re-launched, you can use
Jeff Sharkey9f991a22014-08-13 11:37:41 -07004608 * this flag. When set and the task's activity is finished, the recents
4609 * entry will remain in the interface for the user to re-launch it, like a
4610 * recents entry for a top-level application.
4611 * <p>
4612 * The receiving activity can override this request with
4613 * {@link android.R.attr#autoRemoveFromRecents} or by explcitly calling
4614 * {@link android.app.Activity#finishAndRemoveTask()
Dianne Hackborn13420f22014-07-18 15:43:56 -07004615 * Activity.finishAndRemoveTask()}.
Craig Mautner2dac0562014-05-06 09:06:44 -07004616 */
Dianne Hackborn13420f22014-07-18 15:43:56 -07004617 public static final int FLAG_ACTIVITY_RETAIN_IN_RECENTS = 0x00002000;
Craig Mautnera228ae92014-07-09 05:44:55 -07004618
4619 /**
Wale Ogunwale2a25a622016-01-30 11:27:21 -08004620 * This flag is only used in split-screen multi-window mode. The new activity will be displayed
4621 * adjacent to the one launching it. This can only be used in conjunction with
Wale Ogunwale6bdf2572016-03-11 15:22:38 -08004622 * {@link #FLAG_ACTIVITY_NEW_TASK}. Also, setting {@link #FLAG_ACTIVITY_MULTIPLE_TASK} is
4623 * required if you want a new instance of an existing activity to be created.
Filip Gruszczynski80e29f12015-12-14 14:58:30 -08004624 */
Wale Ogunwale2a25a622016-01-30 11:27:21 -08004625 public static final int FLAG_ACTIVITY_LAUNCH_ADJACENT = 0x00001000;
Filip Gruszczynski80e29f12015-12-14 14:58:30 -08004626
4627 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004628 * If set, when sending a broadcast only registered receivers will be
4629 * called -- no BroadcastReceiver components will be launched.
4630 */
4631 public static final int FLAG_RECEIVER_REGISTERED_ONLY = 0x40000000;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004632 /**
Dianne Hackborn1c633fc2009-12-08 19:45:14 -08004633 * If set, when sending a broadcast the new broadcast will replace
4634 * any existing pending broadcast that matches it. Matching is defined
4635 * by {@link Intent#filterEquals(Intent) Intent.filterEquals} returning
4636 * true for the intents of the two broadcasts. When a match is found,
4637 * the new broadcast (and receivers associated with it) will replace the
4638 * existing one in the pending broadcast list, remaining at the same
4639 * position in the list.
Tom Taylord4a47292009-12-21 13:59:18 -08004640 *
Dianne Hackborn1c633fc2009-12-08 19:45:14 -08004641 * <p>This flag is most typically used with sticky broadcasts, which
4642 * only care about delivering the most recent values of the broadcast
4643 * to their receivers.
4644 */
4645 public static final int FLAG_RECEIVER_REPLACE_PENDING = 0x20000000;
4646 /**
Christopher Tatef46723b2012-01-26 14:19:24 -08004647 * If set, when sending a broadcast the recipient is allowed to run at
4648 * foreground priority, with a shorter timeout interval. During normal
4649 * broadcasts the receivers are not automatically hoisted out of the
4650 * background priority class.
4651 */
4652 public static final int FLAG_RECEIVER_FOREGROUND = 0x10000000;
4653 /**
Dianne Hackborn6285a322013-09-18 12:09:47 -07004654 * If this is an ordered broadcast, don't allow receivers to abort the broadcast.
4655 * They can still propagate results through to later receivers, but they can not prevent
4656 * later receivers from seeing the broadcast.
4657 */
4658 public static final int FLAG_RECEIVER_NO_ABORT = 0x08000000;
4659 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004660 * If set, when sending a broadcast <i>before boot has completed</i> only
4661 * registered receivers will be called -- no BroadcastReceiver components
4662 * will be launched. Sticky intent state will be recorded properly even
4663 * if no receivers wind up being called. If {@link #FLAG_RECEIVER_REGISTERED_ONLY}
4664 * is specified in the broadcast intent, this flag is unnecessary.
The Android Open Source Project10592532009-03-18 17:39:46 -07004665 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004666 * <p>This flag is only for use by system sevices as a convenience to
4667 * avoid having to implement a more complex mechanism around detection
4668 * of boot completion.
The Android Open Source Project10592532009-03-18 17:39:46 -07004669 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004670 * @hide
4671 */
Dianne Hackborn6285a322013-09-18 12:09:47 -07004672 public static final int FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT = 0x04000000;
Dianne Hackborn9acc0302009-08-25 00:27:12 -07004673 /**
4674 * Set when this broadcast is for a boot upgrade, a special mode that
4675 * allows the broadcast to be sent before the system is ready and launches
4676 * the app process with no providers running in it.
4677 * @hide
4678 */
Dianne Hackborn6285a322013-09-18 12:09:47 -07004679 public static final int FLAG_RECEIVER_BOOT_UPGRADE = 0x02000000;
Dianne Hackborn6ac42ae2015-12-08 17:22:10 -08004680 /**
4681 * If set, the broadcast will always go to manifest receivers in background (cached
4682 * or not running) apps, regardless of whether that would be done by default. By
4683 * default they will only receive broadcasts if the broadcast has specified an
4684 * explicit component or package name.
4685 * @hide
4686 */
4687 public static final int FLAG_RECEIVER_INCLUDE_BACKGROUND = 0x01000000;
4688 /**
4689 * If set, the broadcast will never go to manifest receivers in background (cached
4690 * or not running) apps, regardless of whether that would be done by default. By
4691 * default they will receive broadcasts if the broadcast has specified an
4692 * explicit component or package name.
4693 * @hide
4694 */
4695 public static final int FLAG_RECEIVER_EXCLUDE_BACKGROUND = 0x00800000;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004696
Dianne Hackbornfa82f222009-09-17 15:14:12 -07004697 /**
4698 * @hide Flags that can't be changed with PendingIntent.
4699 */
Jeff Sharkey846318a2014-04-04 12:12:41 -07004700 public static final int IMMUTABLE_FLAGS = FLAG_GRANT_READ_URI_PERMISSION
4701 | FLAG_GRANT_WRITE_URI_PERMISSION | FLAG_GRANT_PERSISTABLE_URI_PERMISSION
4702 | FLAG_GRANT_PREFIX_URI_PERMISSION;
Tom Taylord4a47292009-12-21 13:59:18 -08004703
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004704 // ---------------------------------------------------------------------
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004705 // ---------------------------------------------------------------------
4706 // toUri() and parseUri() options.
4707
4708 /**
4709 * Flag for use with {@link #toUri} and {@link #parseUri}: the URI string
4710 * always has the "intent:" scheme. This syntax can be used when you want
4711 * to later disambiguate between URIs that are intended to describe an
4712 * Intent vs. all others that should be treated as raw URIs. When used
4713 * with {@link #parseUri}, any other scheme will result in a generic
4714 * VIEW action for that raw URI.
4715 */
4716 public static final int URI_INTENT_SCHEME = 1<<0;
Tom Taylord4a47292009-12-21 13:59:18 -08004717
Dianne Hackborn85d558c2014-11-04 10:31:54 -08004718 /**
4719 * Flag for use with {@link #toUri} and {@link #parseUri}: the URI string
4720 * always has the "android-app:" scheme. This is a variation of
4721 * {@link #URI_INTENT_SCHEME} whose format is simpler for the case of an
4722 * http/https URI being delivered to a specific package name. The format
4723 * is:
4724 *
4725 * <pre class="prettyprint">
Dianne Hackborn0ee10f62015-01-14 16:16:13 -08004726 * android-app://{package_id}[/{scheme}[/{host}[/{path}]]][#Intent;{...}]</pre>
Dianne Hackborn85d558c2014-11-04 10:31:54 -08004727 *
Dianne Hackborn0ee10f62015-01-14 16:16:13 -08004728 * <p>In this scheme, only the <code>package_id</code> is required. If you include a host,
4729 * you must also include a scheme; including a path also requires both a host and a scheme.
4730 * The final #Intent; fragment can be used without a scheme, host, or path.
4731 * Note that this can not be
Dianne Hackborn85d558c2014-11-04 10:31:54 -08004732 * used with intents that have a {@link #setSelector}, since the base intent
4733 * will always have an explicit package name.</p>
4734 *
4735 * <p>Some examples of how this scheme maps to Intent objects:</p>
4736 * <table border="2" width="85%" align="center" frame="hsides" rules="rows">
4737 * <colgroup align="left" />
4738 * <colgroup align="left" />
4739 * <thead>
4740 * <tr><th>URI</th> <th>Intent</th></tr>
4741 * </thead>
4742 *
4743 * <tbody>
4744 * <tr><td><code>android-app://com.example.app</code></td>
4745 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
4746 * <tr><td>Action: </td><td>{@link #ACTION_MAIN}</td></tr>
4747 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
4748 * </table></td>
4749 * </tr>
4750 * <tr><td><code>android-app://com.example.app/http/example.com</code></td>
4751 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
4752 * <tr><td>Action: </td><td>{@link #ACTION_VIEW}</td></tr>
4753 * <tr><td>Data: </td><td><code>http://example.com/</code></td></tr>
4754 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
4755 * </table></td>
4756 * </tr>
4757 * <tr><td><code>android-app://com.example.app/http/example.com/foo?1234</code></td>
4758 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
4759 * <tr><td>Action: </td><td>{@link #ACTION_VIEW}</td></tr>
4760 * <tr><td>Data: </td><td><code>http://example.com/foo?1234</code></td></tr>
4761 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
4762 * </table></td>
4763 * </tr>
4764 * <tr><td><code>android-app://com.example.app/<br />#Intent;action=com.example.MY_ACTION;end</code></td>
4765 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
4766 * <tr><td>Action: </td><td><code>com.example.MY_ACTION</code></td></tr>
4767 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
4768 * </table></td>
4769 * </tr>
4770 * <tr><td><code>android-app://com.example.app/http/example.com/foo?1234<br />#Intent;action=com.example.MY_ACTION;end</code></td>
4771 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
4772 * <tr><td>Action: </td><td><code>com.example.MY_ACTION</code></td></tr>
4773 * <tr><td>Data: </td><td><code>http://example.com/foo?1234</code></td></tr>
4774 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
4775 * </table></td>
4776 * </tr>
4777 * <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>
4778 * <td><table border="" style="margin:0" >
4779 * <tr><td>Action: </td><td><code>com.example.MY_ACTION</code></td></tr>
4780 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
4781 * <tr><td>Extras: </td><td><code>some_int=(int)100<br />some_str=(String)hello</code></td></tr>
4782 * </table></td>
4783 * </tr>
4784 * </tbody>
4785 * </table>
4786 */
4787 public static final int URI_ANDROID_APP_SCHEME = 1<<1;
4788
Dianne Hackborn24b1c232014-11-20 17:17:39 -08004789 /**
4790 * Flag for use with {@link #toUri} and {@link #parseUri}: allow parsing
4791 * of unsafe information. In particular, the flags {@link #FLAG_GRANT_READ_URI_PERMISSION},
4792 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, {@link #FLAG_GRANT_PERSISTABLE_URI_PERMISSION},
4793 * and {@link #FLAG_GRANT_PREFIX_URI_PERMISSION} flags can not be set, so that the
4794 * generated Intent can not cause unexpected data access to happen.
4795 *
4796 * <p>If you do not trust the source of the URI being parsed, you should still do further
4797 * processing to protect yourself from it. In particular, when using it to start an
4798 * activity you should usually add in {@link #CATEGORY_BROWSABLE} to limit the activities
4799 * that can handle it.</p>
4800 */
4801 public static final int URI_ALLOW_UNSAFE = 1<<2;
4802
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004803 // ---------------------------------------------------------------------
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004804
4805 private String mAction;
4806 private Uri mData;
4807 private String mType;
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004808 private String mPackage;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004809 private ComponentName mComponent;
4810 private int mFlags;
Dianne Hackbornadd005c2013-07-17 18:43:12 -07004811 private ArraySet<String> mCategories;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004812 private Bundle mExtras;
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08004813 private Rect mSourceBounds;
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004814 private Intent mSelector;
Dianne Hackborn21c241e2012-03-08 13:57:23 -08004815 private ClipData mClipData;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01004816 private int mContentUserHint = UserHandle.USER_CURRENT;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004817
4818 // ---------------------------------------------------------------------
4819
4820 /**
4821 * Create an empty intent.
4822 */
4823 public Intent() {
4824 }
4825
4826 /**
4827 * Copy constructor.
4828 */
4829 public Intent(Intent o) {
4830 this.mAction = o.mAction;
4831 this.mData = o.mData;
4832 this.mType = o.mType;
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004833 this.mPackage = o.mPackage;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004834 this.mComponent = o.mComponent;
4835 this.mFlags = o.mFlags;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01004836 this.mContentUserHint = o.mContentUserHint;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004837 if (o.mCategories != null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07004838 this.mCategories = new ArraySet<String>(o.mCategories);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004839 }
4840 if (o.mExtras != null) {
4841 this.mExtras = new Bundle(o.mExtras);
4842 }
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08004843 if (o.mSourceBounds != null) {
4844 this.mSourceBounds = new Rect(o.mSourceBounds);
4845 }
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004846 if (o.mSelector != null) {
4847 this.mSelector = new Intent(o.mSelector);
4848 }
Dianne Hackborn21c241e2012-03-08 13:57:23 -08004849 if (o.mClipData != null) {
4850 this.mClipData = new ClipData(o.mClipData);
4851 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004852 }
4853
4854 @Override
4855 public Object clone() {
4856 return new Intent(this);
4857 }
4858
4859 private Intent(Intent o, boolean all) {
4860 this.mAction = o.mAction;
4861 this.mData = o.mData;
4862 this.mType = o.mType;
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004863 this.mPackage = o.mPackage;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004864 this.mComponent = o.mComponent;
4865 if (o.mCategories != null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07004866 this.mCategories = new ArraySet<String>(o.mCategories);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004867 }
4868 }
4869
4870 /**
4871 * Make a clone of only the parts of the Intent that are relevant for
4872 * filter matching: the action, data, type, component, and categories.
4873 */
4874 public Intent cloneFilter() {
4875 return new Intent(this, false);
4876 }
4877
4878 /**
4879 * Create an intent with a given action. All other fields (data, type,
4880 * class) are null. Note that the action <em>must</em> be in a
4881 * namespace because Intents are used globally in the system -- for
4882 * example the system VIEW action is android.intent.action.VIEW; an
4883 * application's custom action would be something like
4884 * com.google.app.myapp.CUSTOM_ACTION.
4885 *
4886 * @param action The Intent action, such as ACTION_VIEW.
4887 */
4888 public Intent(String action) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08004889 setAction(action);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004890 }
4891
4892 /**
4893 * Create an intent with a given action and for a given data url. Note
4894 * that the action <em>must</em> be in a namespace because Intents are
4895 * used globally in the system -- for example the system VIEW action is
4896 * android.intent.action.VIEW; an application's custom action would be
4897 * something like com.google.app.myapp.CUSTOM_ACTION.
4898 *
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07004899 * <p><em>Note: scheme and host name matching in the Android framework is
4900 * case-sensitive, unlike the formal RFC. As a result,
4901 * you should always ensure that you write your Uri with these elements
4902 * using lower case letters, and normalize any Uris you receive from
4903 * outside of Android to ensure the scheme and host is lower case.</em></p>
4904 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004905 * @param action The Intent action, such as ACTION_VIEW.
4906 * @param uri The Intent data URI.
4907 */
4908 public Intent(String action, Uri uri) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08004909 setAction(action);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004910 mData = uri;
4911 }
4912
4913 /**
4914 * Create an intent for a specific component. All other fields (action, data,
4915 * type, class) are null, though they can be modified later with explicit
4916 * calls. This provides a convenient way to create an intent that is
4917 * intended to execute a hard-coded class name, rather than relying on the
4918 * system to find an appropriate class for you; see {@link #setComponent}
4919 * for more information on the repercussions of this.
4920 *
4921 * @param packageContext A Context of the application package implementing
4922 * this class.
4923 * @param cls The component class that is to be used for the intent.
4924 *
4925 * @see #setClass
4926 * @see #setComponent
4927 * @see #Intent(String, android.net.Uri , Context, Class)
4928 */
4929 public Intent(Context packageContext, Class<?> cls) {
4930 mComponent = new ComponentName(packageContext, cls);
4931 }
4932
4933 /**
4934 * Create an intent for a specific component with a specified action and data.
Craig Mautner2dac0562014-05-06 09:06:44 -07004935 * This is equivalent to using {@link #Intent(String, android.net.Uri)} to
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004936 * construct the Intent and then calling {@link #setClass} to set its
4937 * class.
4938 *
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07004939 * <p><em>Note: scheme and host name matching in the Android framework is
4940 * case-sensitive, unlike the formal RFC. As a result,
4941 * you should always ensure that you write your Uri with these elements
4942 * using lower case letters, and normalize any Uris you receive from
4943 * outside of Android to ensure the scheme and host is lower case.</em></p>
4944 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004945 * @param action The Intent action, such as ACTION_VIEW.
4946 * @param uri The Intent data URI.
4947 * @param packageContext A Context of the application package implementing
4948 * this class.
4949 * @param cls The component class that is to be used for the intent.
4950 *
4951 * @see #Intent(String, android.net.Uri)
4952 * @see #Intent(Context, Class)
4953 * @see #setClass
4954 * @see #setComponent
4955 */
4956 public Intent(String action, Uri uri,
4957 Context packageContext, Class<?> cls) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08004958 setAction(action);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004959 mData = uri;
4960 mComponent = new ComponentName(packageContext, cls);
4961 }
4962
4963 /**
Dianne Hackborn30d71892010-12-11 10:37:55 -08004964 * Create an intent to launch the main (root) activity of a task. This
4965 * is the Intent that is started when the application's is launched from
4966 * Home. For anything else that wants to launch an application in the
4967 * same way, it is important that they use an Intent structured the same
4968 * way, and can use this function to ensure this is the case.
4969 *
4970 * <p>The returned Intent has the given Activity component as its explicit
4971 * component, {@link #ACTION_MAIN} as its action, and includes the
4972 * category {@link #CATEGORY_LAUNCHER}. This does <em>not</em> have
4973 * {@link #FLAG_ACTIVITY_NEW_TASK} set, though typically you will want
4974 * to do that through {@link #addFlags(int)} on the returned Intent.
4975 *
4976 * @param mainActivity The main activity component that this Intent will
4977 * launch.
4978 * @return Returns a newly created Intent that can be used to launch the
4979 * activity as a main application entry.
4980 *
4981 * @see #setClass
4982 * @see #setComponent
4983 */
4984 public static Intent makeMainActivity(ComponentName mainActivity) {
4985 Intent intent = new Intent(ACTION_MAIN);
4986 intent.setComponent(mainActivity);
4987 intent.addCategory(CATEGORY_LAUNCHER);
4988 return intent;
4989 }
4990
4991 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004992 * Make an Intent for the main activity of an application, without
4993 * specifying a specific activity to run but giving a selector to find
4994 * the activity. This results in a final Intent that is structured
4995 * the same as when the application is launched from
4996 * Home. For anything else that wants to launch an application in the
4997 * same way, it is important that they use an Intent structured the same
4998 * way, and can use this function to ensure this is the case.
4999 *
5000 * <p>The returned Intent has {@link #ACTION_MAIN} as its action, and includes the
5001 * category {@link #CATEGORY_LAUNCHER}. This does <em>not</em> have
5002 * {@link #FLAG_ACTIVITY_NEW_TASK} set, though typically you will want
5003 * to do that through {@link #addFlags(int)} on the returned Intent.
5004 *
5005 * @param selectorAction The action name of the Intent's selector.
5006 * @param selectorCategory The name of a category to add to the Intent's
5007 * selector.
5008 * @return Returns a newly created Intent that can be used to launch the
5009 * activity as a main application entry.
5010 *
5011 * @see #setSelector(Intent)
5012 */
5013 public static Intent makeMainSelectorActivity(String selectorAction,
5014 String selectorCategory) {
5015 Intent intent = new Intent(ACTION_MAIN);
5016 intent.addCategory(CATEGORY_LAUNCHER);
5017 Intent selector = new Intent();
5018 selector.setAction(selectorAction);
5019 selector.addCategory(selectorCategory);
5020 intent.setSelector(selector);
5021 return intent;
5022 }
5023
5024 /**
Dianne Hackborn30d71892010-12-11 10:37:55 -08005025 * Make an Intent that can be used to re-launch an application's task
5026 * in its base state. This is like {@link #makeMainActivity(ComponentName)},
5027 * but also sets the flags {@link #FLAG_ACTIVITY_NEW_TASK} and
5028 * {@link #FLAG_ACTIVITY_CLEAR_TASK}.
5029 *
5030 * @param mainActivity The activity component that is the root of the
5031 * task; this is the activity that has been published in the application's
5032 * manifest as the main launcher icon.
5033 *
5034 * @return Returns a newly created Intent that can be used to relaunch the
5035 * activity's task in its root state.
5036 */
5037 public static Intent makeRestartActivityTask(ComponentName mainActivity) {
5038 Intent intent = makeMainActivity(mainActivity);
5039 intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK
5040 | Intent.FLAG_ACTIVITY_CLEAR_TASK);
5041 return intent;
5042 }
5043
5044 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005045 * Call {@link #parseUri} with 0 flags.
5046 * @deprecated Use {@link #parseUri} instead.
5047 */
5048 @Deprecated
5049 public static Intent getIntent(String uri) throws URISyntaxException {
5050 return parseUri(uri, 0);
5051 }
Tom Taylord4a47292009-12-21 13:59:18 -08005052
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005053 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005054 * Create an intent from a URI. This URI may encode the action,
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005055 * category, and other intent fields, if it was returned by
Dianne Hackborn7f205432009-07-28 00:13:47 -07005056 * {@link #toUri}. If the Intent was not generate by toUri(), its data
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005057 * will be the entire URI and its action will be ACTION_VIEW.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005058 *
5059 * <p>The URI given here must not be relative -- that is, it must include
5060 * the scheme and full path.
5061 *
5062 * @param uri The URI to turn into an Intent.
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005063 * @param flags Additional processing flags. Either 0,
5064 * {@link #URI_INTENT_SCHEME}, or {@link #URI_ANDROID_APP_SCHEME}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005065 *
5066 * @return Intent The newly created Intent object.
5067 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005068 * @throws URISyntaxException Throws URISyntaxError if the basic URI syntax
5069 * it bad (as parsed by the Uri class) or the Intent data within the
5070 * URI is invalid.
Tom Taylord4a47292009-12-21 13:59:18 -08005071 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005072 * @see #toUri
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005073 */
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005074 public static Intent parseUri(String uri, int flags) throws URISyntaxException {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005075 int i = 0;
5076 try {
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005077 final boolean androidApp = uri.startsWith("android-app:");
5078
5079 // Validate intent scheme if requested.
5080 if ((flags&(URI_INTENT_SCHEME|URI_ANDROID_APP_SCHEME)) != 0) {
5081 if (!uri.startsWith("intent:") && !androidApp) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005082 Intent intent = new Intent(ACTION_VIEW);
5083 try {
5084 intent.setData(Uri.parse(uri));
5085 } catch (IllegalArgumentException e) {
5086 throw new URISyntaxException(uri, e.getMessage());
5087 }
5088 return intent;
5089 }
5090 }
Tom Taylord4a47292009-12-21 13:59:18 -08005091
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005092 i = uri.lastIndexOf("#");
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005093 // simple case
5094 if (i == -1) {
5095 if (!androidApp) {
5096 return new Intent(ACTION_VIEW, Uri.parse(uri));
5097 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005098
5099 // old format Intent URI
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005100 } else if (!uri.startsWith("#Intent;", i)) {
5101 if (!androidApp) {
Dianne Hackborn24b1c232014-11-20 17:17:39 -08005102 return getIntentOld(uri, flags);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005103 } else {
5104 i = -1;
5105 }
5106 }
The Android Open Source Project10592532009-03-18 17:39:46 -07005107
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005108 // new format
5109 Intent intent = new Intent(ACTION_VIEW);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005110 Intent baseIntent = intent;
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005111 boolean explicitAction = false;
5112 boolean inSelector = false;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005113
5114 // fetch data part, if present
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005115 String scheme = null;
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005116 String data;
5117 if (i >= 0) {
5118 data = uri.substring(0, i);
5119 i += 8; // length of "#Intent;"
5120 } else {
5121 data = uri;
5122 }
The Android Open Source Project10592532009-03-18 17:39:46 -07005123
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005124 // loop over contents of Intent, all name=value;
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005125 while (i >= 0 && !uri.startsWith("end", i)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005126 int eq = uri.indexOf('=', i);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005127 if (eq < 0) eq = i-1;
5128 int semi = uri.indexOf(';', i);
5129 String value = eq < semi ? Uri.decode(uri.substring(eq + 1, semi)) : "";
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005130
5131 // action
5132 if (uri.startsWith("action=", i)) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08005133 intent.setAction(value);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005134 if (!inSelector) {
5135 explicitAction = true;
5136 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005137 }
5138
5139 // categories
5140 else if (uri.startsWith("category=", i)) {
5141 intent.addCategory(value);
5142 }
5143
5144 // type
5145 else if (uri.startsWith("type=", i)) {
5146 intent.mType = value;
5147 }
5148
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08005149 // launch flags
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005150 else if (uri.startsWith("launchFlags=", i)) {
5151 intent.mFlags = Integer.decode(value).intValue();
Dianne Hackborn24b1c232014-11-20 17:17:39 -08005152 if ((flags& URI_ALLOW_UNSAFE) == 0) {
5153 intent.mFlags &= ~IMMUTABLE_FLAGS;
5154 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005155 }
5156
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005157 // package
5158 else if (uri.startsWith("package=", i)) {
5159 intent.mPackage = value;
5160 }
5161
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005162 // component
5163 else if (uri.startsWith("component=", i)) {
5164 intent.mComponent = ComponentName.unflattenFromString(value);
5165 }
The Android Open Source Project10592532009-03-18 17:39:46 -07005166
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005167 // scheme
5168 else if (uri.startsWith("scheme=", i)) {
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005169 if (inSelector) {
Dianne Hackborn80b1c562014-12-09 20:22:08 -08005170 intent.mData = Uri.parse(value + ":");
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005171 } else {
5172 scheme = value;
5173 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005174 }
5175
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08005176 // source bounds
5177 else if (uri.startsWith("sourceBounds=", i)) {
5178 intent.mSourceBounds = Rect.unflattenFromString(value);
5179 }
5180
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005181 // selector
5182 else if (semi == (i+3) && uri.startsWith("SEL", i)) {
5183 intent = new Intent();
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005184 inSelector = true;
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005185 }
5186
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005187 // extra
5188 else {
5189 String key = Uri.decode(uri.substring(i + 2, eq));
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005190 // create Bundle if it doesn't already exist
5191 if (intent.mExtras == null) intent.mExtras = new Bundle();
5192 Bundle b = intent.mExtras;
5193 // add EXTRA
5194 if (uri.startsWith("S.", i)) b.putString(key, value);
5195 else if (uri.startsWith("B.", i)) b.putBoolean(key, Boolean.parseBoolean(value));
5196 else if (uri.startsWith("b.", i)) b.putByte(key, Byte.parseByte(value));
5197 else if (uri.startsWith("c.", i)) b.putChar(key, value.charAt(0));
5198 else if (uri.startsWith("d.", i)) b.putDouble(key, Double.parseDouble(value));
5199 else if (uri.startsWith("f.", i)) b.putFloat(key, Float.parseFloat(value));
5200 else if (uri.startsWith("i.", i)) b.putInt(key, Integer.parseInt(value));
5201 else if (uri.startsWith("l.", i)) b.putLong(key, Long.parseLong(value));
5202 else if (uri.startsWith("s.", i)) b.putShort(key, Short.parseShort(value));
5203 else throw new URISyntaxException(uri, "unknown EXTRA type", i);
5204 }
The Android Open Source Project10592532009-03-18 17:39:46 -07005205
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005206 // move to the next item
5207 i = semi + 1;
5208 }
5209
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005210 if (inSelector) {
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005211 // The Intent had a selector; fix it up.
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005212 if (baseIntent.mPackage == null) {
5213 baseIntent.setSelector(intent);
5214 }
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005215 intent = baseIntent;
5216 }
5217
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005218 if (data != null) {
5219 if (data.startsWith("intent:")) {
5220 data = data.substring(7);
5221 if (scheme != null) {
5222 data = scheme + ':' + data;
5223 }
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005224 } else if (data.startsWith("android-app:")) {
5225 if (data.charAt(12) == '/' && data.charAt(13) == '/') {
5226 // Correctly formed android-app, first part is package name.
5227 int end = data.indexOf('/', 14);
5228 if (end < 0) {
5229 // All we have is a package name.
5230 intent.mPackage = data.substring(14);
5231 if (!explicitAction) {
5232 intent.setAction(ACTION_MAIN);
5233 }
5234 data = "";
5235 } else {
5236 // Target the Intent at the given package name always.
5237 String authority = null;
5238 intent.mPackage = data.substring(14, end);
5239 int newEnd;
Dianne Hackborn80b1c562014-12-09 20:22:08 -08005240 if ((end+1) < data.length()) {
5241 if ((newEnd=data.indexOf('/', end+1)) >= 0) {
5242 // Found a scheme, remember it.
5243 scheme = data.substring(end+1, newEnd);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005244 end = newEnd;
Dianne Hackborn80b1c562014-12-09 20:22:08 -08005245 if (end < data.length() && (newEnd=data.indexOf('/', end+1)) >= 0) {
5246 // Found a authority, remember it.
5247 authority = data.substring(end+1, newEnd);
5248 end = newEnd;
5249 }
5250 } else {
5251 // All we have is a scheme.
5252 scheme = data.substring(end+1);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005253 }
5254 }
5255 if (scheme == null) {
5256 // If there was no scheme, then this just targets the package.
5257 if (!explicitAction) {
5258 intent.setAction(ACTION_MAIN);
5259 }
5260 data = "";
5261 } else if (authority == null) {
5262 data = scheme + ":";
5263 } else {
5264 data = scheme + "://" + authority + data.substring(end);
5265 }
5266 }
5267 } else {
5268 data = "";
5269 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005270 }
Tom Taylord4a47292009-12-21 13:59:18 -08005271
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005272 if (data.length() > 0) {
5273 try {
5274 intent.mData = Uri.parse(data);
5275 } catch (IllegalArgumentException e) {
5276 throw new URISyntaxException(uri, e.getMessage());
5277 }
5278 }
5279 }
Tom Taylord4a47292009-12-21 13:59:18 -08005280
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005281 return intent;
The Android Open Source Project10592532009-03-18 17:39:46 -07005282
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005283 } catch (IndexOutOfBoundsException e) {
5284 throw new URISyntaxException(uri, "illegal Intent URI format", i);
5285 }
5286 }
The Android Open Source Project10592532009-03-18 17:39:46 -07005287
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005288 public static Intent getIntentOld(String uri) throws URISyntaxException {
Dianne Hackborn24b1c232014-11-20 17:17:39 -08005289 return getIntentOld(uri, 0);
5290 }
5291
5292 private static Intent getIntentOld(String uri, int flags) throws URISyntaxException {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005293 Intent intent;
5294
5295 int i = uri.lastIndexOf('#');
5296 if (i >= 0) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005297 String action = null;
Dianne Hackborn6cca1592009-09-20 12:40:03 -07005298 final int intentFragmentStart = i;
5299 boolean isIntentFragment = false;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005300
5301 i++;
5302
5303 if (uri.regionMatches(i, "action(", 0, 7)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07005304 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005305 i += 7;
5306 int j = uri.indexOf(')', i);
5307 action = uri.substring(i, j);
5308 i = j + 1;
5309 }
5310
Dianne Hackborn6cca1592009-09-20 12:40:03 -07005311 intent = new Intent(action);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005312
5313 if (uri.regionMatches(i, "categories(", 0, 11)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07005314 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005315 i += 11;
5316 int j = uri.indexOf(')', i);
5317 while (i < j) {
5318 int sep = uri.indexOf('!', i);
Alan Viverette0adf32b2014-09-18 12:53:16 -07005319 if (sep < 0 || sep > j) sep = j;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005320 if (i < sep) {
5321 intent.addCategory(uri.substring(i, sep));
5322 }
5323 i = sep + 1;
5324 }
5325 i = j + 1;
5326 }
5327
5328 if (uri.regionMatches(i, "type(", 0, 5)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07005329 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005330 i += 5;
5331 int j = uri.indexOf(')', i);
5332 intent.mType = uri.substring(i, j);
5333 i = j + 1;
5334 }
5335
5336 if (uri.regionMatches(i, "launchFlags(", 0, 12)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07005337 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005338 i += 12;
5339 int j = uri.indexOf(')', i);
5340 intent.mFlags = Integer.decode(uri.substring(i, j)).intValue();
Dianne Hackborn24b1c232014-11-20 17:17:39 -08005341 if ((flags& URI_ALLOW_UNSAFE) == 0) {
5342 intent.mFlags &= ~IMMUTABLE_FLAGS;
5343 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005344 i = j + 1;
5345 }
5346
5347 if (uri.regionMatches(i, "component(", 0, 10)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07005348 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005349 i += 10;
5350 int j = uri.indexOf(')', i);
5351 int sep = uri.indexOf('!', i);
5352 if (sep >= 0 && sep < j) {
5353 String pkg = uri.substring(i, sep);
5354 String cls = uri.substring(sep + 1, j);
5355 intent.mComponent = new ComponentName(pkg, cls);
5356 }
5357 i = j + 1;
5358 }
5359
5360 if (uri.regionMatches(i, "extras(", 0, 7)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07005361 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005362 i += 7;
The Android Open Source Project10592532009-03-18 17:39:46 -07005363
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005364 final int closeParen = uri.indexOf(')', i);
5365 if (closeParen == -1) throw new URISyntaxException(uri,
5366 "EXTRA missing trailing ')'", i);
5367
5368 while (i < closeParen) {
5369 // fetch the key value
5370 int j = uri.indexOf('=', i);
5371 if (j <= i + 1 || i >= closeParen) {
5372 throw new URISyntaxException(uri, "EXTRA missing '='", i);
5373 }
5374 char type = uri.charAt(i);
5375 i++;
5376 String key = uri.substring(i, j);
5377 i = j + 1;
The Android Open Source Project10592532009-03-18 17:39:46 -07005378
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005379 // get type-value
5380 j = uri.indexOf('!', i);
5381 if (j == -1 || j >= closeParen) j = closeParen;
5382 if (i >= j) throw new URISyntaxException(uri, "EXTRA missing '!'", i);
5383 String value = uri.substring(i, j);
5384 i = j;
5385
5386 // create Bundle if it doesn't already exist
5387 if (intent.mExtras == null) intent.mExtras = new Bundle();
The Android Open Source Project10592532009-03-18 17:39:46 -07005388
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005389 // add item to bundle
5390 try {
5391 switch (type) {
5392 case 'S':
5393 intent.mExtras.putString(key, Uri.decode(value));
5394 break;
5395 case 'B':
5396 intent.mExtras.putBoolean(key, Boolean.parseBoolean(value));
5397 break;
5398 case 'b':
5399 intent.mExtras.putByte(key, Byte.parseByte(value));
5400 break;
5401 case 'c':
5402 intent.mExtras.putChar(key, Uri.decode(value).charAt(0));
5403 break;
5404 case 'd':
5405 intent.mExtras.putDouble(key, Double.parseDouble(value));
5406 break;
5407 case 'f':
5408 intent.mExtras.putFloat(key, Float.parseFloat(value));
5409 break;
5410 case 'i':
5411 intent.mExtras.putInt(key, Integer.parseInt(value));
5412 break;
5413 case 'l':
5414 intent.mExtras.putLong(key, Long.parseLong(value));
5415 break;
5416 case 's':
5417 intent.mExtras.putShort(key, Short.parseShort(value));
5418 break;
5419 default:
5420 throw new URISyntaxException(uri, "EXTRA has unknown type", i);
5421 }
5422 } catch (NumberFormatException e) {
5423 throw new URISyntaxException(uri, "EXTRA value can't be parsed", i);
5424 }
The Android Open Source Project10592532009-03-18 17:39:46 -07005425
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005426 char ch = uri.charAt(i);
5427 if (ch == ')') break;
5428 if (ch != '!') throw new URISyntaxException(uri, "EXTRA missing '!'", i);
5429 i++;
5430 }
5431 }
5432
Dianne Hackborn6cca1592009-09-20 12:40:03 -07005433 if (isIntentFragment) {
5434 intent.mData = Uri.parse(uri.substring(0, intentFragmentStart));
5435 } else {
5436 intent.mData = Uri.parse(uri);
5437 }
Tom Taylord4a47292009-12-21 13:59:18 -08005438
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005439 if (intent.mAction == null) {
5440 // By default, if no action is specified, then use VIEW.
5441 intent.mAction = ACTION_VIEW;
5442 }
5443
5444 } else {
5445 intent = new Intent(ACTION_VIEW, Uri.parse(uri));
5446 }
5447
5448 return intent;
5449 }
5450
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08005451 /** @hide */
5452 public interface CommandOptionHandler {
5453 boolean handleOption(String opt, ShellCommand cmd);
5454 }
5455
5456 /** @hide */
5457 public static Intent parseCommandArgs(ShellCommand cmd, CommandOptionHandler optionHandler)
5458 throws URISyntaxException {
5459 Intent intent = new Intent();
5460 Intent baseIntent = intent;
5461 boolean hasIntentInfo = false;
5462
5463 Uri data = null;
5464 String type = null;
5465
5466 String opt;
5467 while ((opt=cmd.getNextOption()) != null) {
5468 switch (opt) {
5469 case "-a":
5470 intent.setAction(cmd.getNextArgRequired());
5471 if (intent == baseIntent) {
5472 hasIntentInfo = true;
5473 }
5474 break;
5475 case "-d":
5476 data = Uri.parse(cmd.getNextArgRequired());
5477 if (intent == baseIntent) {
5478 hasIntentInfo = true;
5479 }
5480 break;
5481 case "-t":
5482 type = cmd.getNextArgRequired();
5483 if (intent == baseIntent) {
5484 hasIntentInfo = true;
5485 }
5486 break;
5487 case "-c":
5488 intent.addCategory(cmd.getNextArgRequired());
5489 if (intent == baseIntent) {
5490 hasIntentInfo = true;
5491 }
5492 break;
5493 case "-e":
5494 case "--es": {
5495 String key = cmd.getNextArgRequired();
5496 String value = cmd.getNextArgRequired();
5497 intent.putExtra(key, value);
5498 }
5499 break;
5500 case "--esn": {
5501 String key = cmd.getNextArgRequired();
5502 intent.putExtra(key, (String) null);
5503 }
5504 break;
5505 case "--ei": {
5506 String key = cmd.getNextArgRequired();
5507 String value = cmd.getNextArgRequired();
5508 intent.putExtra(key, Integer.decode(value));
5509 }
5510 break;
5511 case "--eu": {
5512 String key = cmd.getNextArgRequired();
5513 String value = cmd.getNextArgRequired();
5514 intent.putExtra(key, Uri.parse(value));
5515 }
5516 break;
5517 case "--ecn": {
5518 String key = cmd.getNextArgRequired();
5519 String value = cmd.getNextArgRequired();
5520 ComponentName cn = ComponentName.unflattenFromString(value);
5521 if (cn == null)
5522 throw new IllegalArgumentException("Bad component name: " + value);
5523 intent.putExtra(key, cn);
5524 }
5525 break;
5526 case "--eia": {
5527 String key = cmd.getNextArgRequired();
5528 String value = cmd.getNextArgRequired();
5529 String[] strings = value.split(",");
5530 int[] list = new int[strings.length];
5531 for (int i = 0; i < strings.length; i++) {
5532 list[i] = Integer.decode(strings[i]);
5533 }
5534 intent.putExtra(key, list);
5535 }
5536 break;
5537 case "--eial": {
5538 String key = cmd.getNextArgRequired();
5539 String value = cmd.getNextArgRequired();
5540 String[] strings = value.split(",");
5541 ArrayList<Integer> list = new ArrayList<>(strings.length);
5542 for (int i = 0; i < strings.length; i++) {
5543 list.add(Integer.decode(strings[i]));
5544 }
5545 intent.putExtra(key, list);
5546 }
5547 break;
5548 case "--el": {
5549 String key = cmd.getNextArgRequired();
5550 String value = cmd.getNextArgRequired();
5551 intent.putExtra(key, Long.valueOf(value));
5552 }
5553 break;
5554 case "--ela": {
5555 String key = cmd.getNextArgRequired();
5556 String value = cmd.getNextArgRequired();
5557 String[] strings = value.split(",");
5558 long[] list = new long[strings.length];
5559 for (int i = 0; i < strings.length; i++) {
5560 list[i] = Long.valueOf(strings[i]);
5561 }
5562 intent.putExtra(key, list);
5563 hasIntentInfo = true;
5564 }
5565 break;
5566 case "--elal": {
5567 String key = cmd.getNextArgRequired();
5568 String value = cmd.getNextArgRequired();
5569 String[] strings = value.split(",");
5570 ArrayList<Long> list = new ArrayList<>(strings.length);
5571 for (int i = 0; i < strings.length; i++) {
5572 list.add(Long.valueOf(strings[i]));
5573 }
5574 intent.putExtra(key, list);
5575 hasIntentInfo = true;
5576 }
5577 break;
5578 case "--ef": {
5579 String key = cmd.getNextArgRequired();
5580 String value = cmd.getNextArgRequired();
5581 intent.putExtra(key, Float.valueOf(value));
5582 hasIntentInfo = true;
5583 }
5584 break;
5585 case "--efa": {
5586 String key = cmd.getNextArgRequired();
5587 String value = cmd.getNextArgRequired();
5588 String[] strings = value.split(",");
5589 float[] list = new float[strings.length];
5590 for (int i = 0; i < strings.length; i++) {
5591 list[i] = Float.valueOf(strings[i]);
5592 }
5593 intent.putExtra(key, list);
5594 hasIntentInfo = true;
5595 }
5596 break;
5597 case "--efal": {
5598 String key = cmd.getNextArgRequired();
5599 String value = cmd.getNextArgRequired();
5600 String[] strings = value.split(",");
5601 ArrayList<Float> list = new ArrayList<>(strings.length);
5602 for (int i = 0; i < strings.length; i++) {
5603 list.add(Float.valueOf(strings[i]));
5604 }
5605 intent.putExtra(key, list);
5606 hasIntentInfo = true;
5607 }
5608 break;
5609 case "--esa": {
5610 String key = cmd.getNextArgRequired();
5611 String value = cmd.getNextArgRequired();
5612 // Split on commas unless they are preceeded by an escape.
5613 // The escape character must be escaped for the string and
5614 // again for the regex, thus four escape characters become one.
5615 String[] strings = value.split("(?<!\\\\),");
5616 intent.putExtra(key, strings);
5617 hasIntentInfo = true;
5618 }
5619 break;
5620 case "--esal": {
5621 String key = cmd.getNextArgRequired();
5622 String value = cmd.getNextArgRequired();
5623 // Split on commas unless they are preceeded by an escape.
5624 // The escape character must be escaped for the string and
5625 // again for the regex, thus four escape characters become one.
5626 String[] strings = value.split("(?<!\\\\),");
5627 ArrayList<String> list = new ArrayList<>(strings.length);
5628 for (int i = 0; i < strings.length; i++) {
5629 list.add(strings[i]);
5630 }
5631 intent.putExtra(key, list);
5632 hasIntentInfo = true;
5633 }
5634 break;
5635 case "--ez": {
5636 String key = cmd.getNextArgRequired();
5637 String value = cmd.getNextArgRequired().toLowerCase();
5638 // Boolean.valueOf() results in false for anything that is not "true", which is
5639 // error-prone in shell commands
5640 boolean arg;
5641 if ("true".equals(value) || "t".equals(value)) {
5642 arg = true;
5643 } else if ("false".equals(value) || "f".equals(value)) {
5644 arg = false;
5645 } else {
5646 try {
5647 arg = Integer.decode(value) != 0;
5648 } catch (NumberFormatException ex) {
5649 throw new IllegalArgumentException("Invalid boolean value: " + value);
5650 }
5651 }
5652
5653 intent.putExtra(key, arg);
5654 }
5655 break;
5656 case "-n": {
5657 String str = cmd.getNextArgRequired();
5658 ComponentName cn = ComponentName.unflattenFromString(str);
5659 if (cn == null)
5660 throw new IllegalArgumentException("Bad component name: " + str);
5661 intent.setComponent(cn);
5662 if (intent == baseIntent) {
5663 hasIntentInfo = true;
5664 }
5665 }
5666 break;
5667 case "-p": {
5668 String str = cmd.getNextArgRequired();
5669 intent.setPackage(str);
5670 if (intent == baseIntent) {
5671 hasIntentInfo = true;
5672 }
5673 }
5674 break;
5675 case "-f":
5676 String str = cmd.getNextArgRequired();
5677 intent.setFlags(Integer.decode(str).intValue());
5678 break;
5679 case "--grant-read-uri-permission":
5680 intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
5681 break;
5682 case "--grant-write-uri-permission":
5683 intent.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
5684 break;
5685 case "--grant-persistable-uri-permission":
5686 intent.addFlags(Intent.FLAG_GRANT_PERSISTABLE_URI_PERMISSION);
5687 break;
5688 case "--grant-prefix-uri-permission":
5689 intent.addFlags(Intent.FLAG_GRANT_PREFIX_URI_PERMISSION);
5690 break;
5691 case "--exclude-stopped-packages":
5692 intent.addFlags(Intent.FLAG_EXCLUDE_STOPPED_PACKAGES);
5693 break;
5694 case "--include-stopped-packages":
5695 intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
5696 break;
5697 case "--debug-log-resolution":
5698 intent.addFlags(Intent.FLAG_DEBUG_LOG_RESOLUTION);
5699 break;
5700 case "--activity-brought-to-front":
5701 intent.addFlags(Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT);
5702 break;
5703 case "--activity-clear-top":
5704 intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
5705 break;
5706 case "--activity-clear-when-task-reset":
5707 intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
5708 break;
5709 case "--activity-exclude-from-recents":
5710 intent.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
5711 break;
5712 case "--activity-launched-from-history":
5713 intent.addFlags(Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY);
5714 break;
5715 case "--activity-multiple-task":
5716 intent.addFlags(Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
5717 break;
5718 case "--activity-no-animation":
5719 intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
5720 break;
5721 case "--activity-no-history":
5722 intent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
5723 break;
5724 case "--activity-no-user-action":
5725 intent.addFlags(Intent.FLAG_ACTIVITY_NO_USER_ACTION);
5726 break;
5727 case "--activity-previous-is-top":
5728 intent.addFlags(Intent.FLAG_ACTIVITY_PREVIOUS_IS_TOP);
5729 break;
5730 case "--activity-reorder-to-front":
5731 intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
5732 break;
5733 case "--activity-reset-task-if-needed":
5734 intent.addFlags(Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
5735 break;
5736 case "--activity-single-top":
5737 intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
5738 break;
5739 case "--activity-clear-task":
5740 intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
5741 break;
5742 case "--activity-task-on-home":
5743 intent.addFlags(Intent.FLAG_ACTIVITY_TASK_ON_HOME);
5744 break;
5745 case "--receiver-registered-only":
5746 intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY);
5747 break;
5748 case "--receiver-replace-pending":
5749 intent.addFlags(Intent.FLAG_RECEIVER_REPLACE_PENDING);
5750 break;
Felipe Leme3cb48cd2016-01-27 08:39:09 -08005751 case "--receiver-foreground":
5752 intent.addFlags(Intent.FLAG_RECEIVER_FOREGROUND);
5753 break;
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08005754 case "--selector":
5755 intent.setDataAndType(data, type);
5756 intent = new Intent();
5757 break;
5758 default:
5759 if (optionHandler != null && optionHandler.handleOption(opt, cmd)) {
5760 // Okay, caller handled this option.
5761 } else {
5762 throw new IllegalArgumentException("Unknown option: " + opt);
5763 }
5764 break;
5765 }
5766 }
5767 intent.setDataAndType(data, type);
5768
5769 final boolean hasSelector = intent != baseIntent;
5770 if (hasSelector) {
5771 // A selector was specified; fix up.
5772 baseIntent.setSelector(intent);
5773 intent = baseIntent;
5774 }
5775
5776 String arg = cmd.getNextArg();
5777 baseIntent = null;
5778 if (arg == null) {
5779 if (hasSelector) {
5780 // If a selector has been specified, and no arguments
5781 // have been supplied for the main Intent, then we can
5782 // assume it is ACTION_MAIN CATEGORY_LAUNCHER; we don't
5783 // need to have a component name specified yet, the
5784 // selector will take care of that.
5785 baseIntent = new Intent(Intent.ACTION_MAIN);
5786 baseIntent.addCategory(Intent.CATEGORY_LAUNCHER);
5787 }
5788 } else if (arg.indexOf(':') >= 0) {
5789 // The argument is a URI. Fully parse it, and use that result
5790 // to fill in any data not specified so far.
5791 baseIntent = Intent.parseUri(arg, Intent.URI_INTENT_SCHEME
5792 | Intent.URI_ANDROID_APP_SCHEME | Intent.URI_ALLOW_UNSAFE);
5793 } else if (arg.indexOf('/') >= 0) {
5794 // The argument is a component name. Build an Intent to launch
5795 // it.
5796 baseIntent = new Intent(Intent.ACTION_MAIN);
5797 baseIntent.addCategory(Intent.CATEGORY_LAUNCHER);
5798 baseIntent.setComponent(ComponentName.unflattenFromString(arg));
5799 } else {
5800 // Assume the argument is a package name.
5801 baseIntent = new Intent(Intent.ACTION_MAIN);
5802 baseIntent.addCategory(Intent.CATEGORY_LAUNCHER);
5803 baseIntent.setPackage(arg);
5804 }
5805 if (baseIntent != null) {
5806 Bundle extras = intent.getExtras();
5807 intent.replaceExtras((Bundle)null);
5808 Bundle uriExtras = baseIntent.getExtras();
5809 baseIntent.replaceExtras((Bundle)null);
5810 if (intent.getAction() != null && baseIntent.getCategories() != null) {
5811 HashSet<String> cats = new HashSet<String>(baseIntent.getCategories());
5812 for (String c : cats) {
5813 baseIntent.removeCategory(c);
5814 }
5815 }
5816 intent.fillIn(baseIntent, Intent.FILL_IN_COMPONENT | Intent.FILL_IN_SELECTOR);
5817 if (extras == null) {
5818 extras = uriExtras;
5819 } else if (uriExtras != null) {
5820 uriExtras.putAll(extras);
5821 extras = uriExtras;
5822 }
5823 intent.replaceExtras(extras);
5824 hasIntentInfo = true;
5825 }
5826
5827 if (!hasIntentInfo) throw new IllegalArgumentException("No intent supplied");
5828 return intent;
5829 }
5830
5831 /** @hide */
5832 public static void printIntentArgsHelp(PrintWriter pw, String prefix) {
5833 final String[] lines = new String[] {
5834 "<INTENT> specifications include these flags and arguments:",
5835 " [-a <ACTION>] [-d <DATA_URI>] [-t <MIME_TYPE>]",
5836 " [-c <CATEGORY> [-c <CATEGORY>] ...]",
5837 " [-e|--es <EXTRA_KEY> <EXTRA_STRING_VALUE> ...]",
5838 " [--esn <EXTRA_KEY> ...]",
5839 " [--ez <EXTRA_KEY> <EXTRA_BOOLEAN_VALUE> ...]",
5840 " [--ei <EXTRA_KEY> <EXTRA_INT_VALUE> ...]",
5841 " [--el <EXTRA_KEY> <EXTRA_LONG_VALUE> ...]",
5842 " [--ef <EXTRA_KEY> <EXTRA_FLOAT_VALUE> ...]",
5843 " [--eu <EXTRA_KEY> <EXTRA_URI_VALUE> ...]",
5844 " [--ecn <EXTRA_KEY> <EXTRA_COMPONENT_NAME_VALUE>]",
5845 " [--eia <EXTRA_KEY> <EXTRA_INT_VALUE>[,<EXTRA_INT_VALUE...]]",
5846 " (mutiple extras passed as Integer[])",
5847 " [--eial <EXTRA_KEY> <EXTRA_INT_VALUE>[,<EXTRA_INT_VALUE...]]",
5848 " (mutiple extras passed as List<Integer>)",
5849 " [--ela <EXTRA_KEY> <EXTRA_LONG_VALUE>[,<EXTRA_LONG_VALUE...]]",
5850 " (mutiple extras passed as Long[])",
5851 " [--elal <EXTRA_KEY> <EXTRA_LONG_VALUE>[,<EXTRA_LONG_VALUE...]]",
5852 " (mutiple extras passed as List<Long>)",
5853 " [--efa <EXTRA_KEY> <EXTRA_FLOAT_VALUE>[,<EXTRA_FLOAT_VALUE...]]",
5854 " (mutiple extras passed as Float[])",
5855 " [--efal <EXTRA_KEY> <EXTRA_FLOAT_VALUE>[,<EXTRA_FLOAT_VALUE...]]",
5856 " (mutiple extras passed as List<Float>)",
5857 " [--esa <EXTRA_KEY> <EXTRA_STRING_VALUE>[,<EXTRA_STRING_VALUE...]]",
5858 " (mutiple extras passed as String[]; to embed a comma into a string,",
5859 " escape it using \"\\,\")",
5860 " [--esal <EXTRA_KEY> <EXTRA_STRING_VALUE>[,<EXTRA_STRING_VALUE...]]",
5861 " (mutiple extras passed as List<String>; to embed a comma into a string,",
5862 " escape it using \"\\,\")",
Felipe Leme3cb48cd2016-01-27 08:39:09 -08005863 " [--f <FLAG>]",
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08005864 " [--grant-read-uri-permission] [--grant-write-uri-permission]",
5865 " [--grant-persistable-uri-permission] [--grant-prefix-uri-permission]",
5866 " [--debug-log-resolution] [--exclude-stopped-packages]",
5867 " [--include-stopped-packages]",
5868 " [--activity-brought-to-front] [--activity-clear-top]",
5869 " [--activity-clear-when-task-reset] [--activity-exclude-from-recents]",
5870 " [--activity-launched-from-history] [--activity-multiple-task]",
5871 " [--activity-no-animation] [--activity-no-history]",
5872 " [--activity-no-user-action] [--activity-previous-is-top]",
5873 " [--activity-reorder-to-front] [--activity-reset-task-if-needed]",
5874 " [--activity-single-top] [--activity-clear-task]",
5875 " [--activity-task-on-home]",
5876 " [--receiver-registered-only] [--receiver-replace-pending]",
Felipe Leme3cb48cd2016-01-27 08:39:09 -08005877 " [--receiver-foreground]",
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08005878 " [--selector]",
5879 " [<URI> | <PACKAGE> | <COMPONENT>]"
5880 };
5881 for (String line : lines) {
5882 pw.print(prefix);
5883 pw.println(line);
5884 }
5885 }
5886
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005887 /**
5888 * Retrieve the general action to be performed, such as
5889 * {@link #ACTION_VIEW}. The action describes the general way the rest of
5890 * the information in the intent should be interpreted -- most importantly,
5891 * what to do with the data returned by {@link #getData}.
5892 *
5893 * @return The action of this intent or null if none is specified.
5894 *
5895 * @see #setAction
5896 */
5897 public String getAction() {
5898 return mAction;
5899 }
5900
5901 /**
5902 * Retrieve data this intent is operating on. This URI specifies the name
5903 * of the data; often it uses the content: scheme, specifying data in a
5904 * content provider. Other schemes may be handled by specific activities,
5905 * such as http: by the web browser.
5906 *
5907 * @return The URI of the data this intent is targeting or null.
5908 *
5909 * @see #getScheme
5910 * @see #setData
5911 */
5912 public Uri getData() {
5913 return mData;
5914 }
5915
5916 /**
5917 * The same as {@link #getData()}, but returns the URI as an encoded
5918 * String.
5919 */
5920 public String getDataString() {
5921 return mData != null ? mData.toString() : null;
5922 }
5923
5924 /**
5925 * Return the scheme portion of the intent's data. If the data is null or
5926 * does not include a scheme, null is returned. Otherwise, the scheme
5927 * prefix without the final ':' is returned, i.e. "http".
5928 *
5929 * <p>This is the same as calling getData().getScheme() (and checking for
5930 * null data).
5931 *
5932 * @return The scheme of this intent.
5933 *
5934 * @see #getData
5935 */
5936 public String getScheme() {
5937 return mData != null ? mData.getScheme() : null;
5938 }
5939
5940 /**
5941 * Retrieve any explicit MIME type included in the intent. This is usually
5942 * null, as the type is determined by the intent data.
5943 *
5944 * @return If a type was manually set, it is returned; else null is
5945 * returned.
5946 *
5947 * @see #resolveType(ContentResolver)
5948 * @see #setType
5949 */
5950 public String getType() {
5951 return mType;
5952 }
5953
5954 /**
5955 * Return the MIME data type of this intent. If the type field is
5956 * explicitly set, that is simply returned. Otherwise, if the data is set,
5957 * the type of that data is returned. If neither fields are set, a null is
5958 * returned.
5959 *
5960 * @return The MIME type of this intent.
5961 *
5962 * @see #getType
5963 * @see #resolveType(ContentResolver)
5964 */
5965 public String resolveType(Context context) {
5966 return resolveType(context.getContentResolver());
5967 }
5968
5969 /**
5970 * Return the MIME data type of this intent. If the type field is
5971 * explicitly set, that is simply returned. Otherwise, if the data is set,
5972 * the type of that data is returned. If neither fields are set, a null is
5973 * returned.
5974 *
5975 * @param resolver A ContentResolver that can be used to determine the MIME
5976 * type of the intent's data.
5977 *
5978 * @return The MIME type of this intent.
5979 *
5980 * @see #getType
5981 * @see #resolveType(Context)
5982 */
5983 public String resolveType(ContentResolver resolver) {
5984 if (mType != null) {
5985 return mType;
5986 }
5987 if (mData != null) {
5988 if ("content".equals(mData.getScheme())) {
5989 return resolver.getType(mData);
5990 }
5991 }
5992 return null;
5993 }
5994
5995 /**
5996 * Return the MIME data type of this intent, only if it will be needed for
5997 * intent resolution. This is not generally useful for application code;
5998 * it is used by the frameworks for communicating with back-end system
5999 * services.
6000 *
6001 * @param resolver A ContentResolver that can be used to determine the MIME
6002 * type of the intent's data.
6003 *
6004 * @return The MIME type of this intent, or null if it is unknown or not
6005 * needed.
6006 */
6007 public String resolveTypeIfNeeded(ContentResolver resolver) {
6008 if (mComponent != null) {
6009 return mType;
6010 }
6011 return resolveType(resolver);
6012 }
6013
6014 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09006015 * Check if a category exists in the intent.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006016 *
6017 * @param category The category to check.
6018 *
6019 * @return boolean True if the intent contains the category, else false.
6020 *
6021 * @see #getCategories
6022 * @see #addCategory
6023 */
6024 public boolean hasCategory(String category) {
6025 return mCategories != null && mCategories.contains(category);
6026 }
6027
6028 /**
6029 * Return the set of all categories in the intent. If there are no categories,
6030 * returns NULL.
6031 *
Dianne Hackbornf5b86712011-12-05 17:42:41 -08006032 * @return The set of categories you can examine. Do not modify!
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006033 *
6034 * @see #hasCategory
6035 * @see #addCategory
6036 */
6037 public Set<String> getCategories() {
6038 return mCategories;
6039 }
6040
6041 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08006042 * Return the specific selector associated with this Intent. If there is
6043 * none, returns null. See {@link #setSelector} for more information.
6044 *
6045 * @see #setSelector
6046 */
6047 public Intent getSelector() {
6048 return mSelector;
6049 }
6050
6051 /**
Dianne Hackborn21c241e2012-03-08 13:57:23 -08006052 * Return the {@link ClipData} associated with this Intent. If there is
6053 * none, returns null. See {@link #setClipData} for more information.
6054 *
John Spurlock125d1332013-11-25 11:58:37 -05006055 * @see #setClipData
Dianne Hackborn21c241e2012-03-08 13:57:23 -08006056 */
6057 public ClipData getClipData() {
6058 return mClipData;
6059 }
6060
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01006061 /** @hide */
6062 public int getContentUserHint() {
6063 return mContentUserHint;
6064 }
6065
Dianne Hackborn21c241e2012-03-08 13:57:23 -08006066 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006067 * Sets the ClassLoader that will be used when unmarshalling
6068 * any Parcelable values from the extras of this Intent.
6069 *
6070 * @param loader a ClassLoader, or null to use the default loader
6071 * at the time of unmarshalling.
6072 */
6073 public void setExtrasClassLoader(ClassLoader loader) {
6074 if (mExtras != null) {
6075 mExtras.setClassLoader(loader);
6076 }
6077 }
6078
6079 /**
6080 * Returns true if an extra value is associated with the given name.
6081 * @param name the extra's name
6082 * @return true if the given extra is present.
6083 */
6084 public boolean hasExtra(String name) {
6085 return mExtras != null && mExtras.containsKey(name);
6086 }
6087
6088 /**
6089 * Returns true if the Intent's extras contain a parcelled file descriptor.
6090 * @return true if the Intent contains a parcelled file descriptor.
6091 */
6092 public boolean hasFileDescriptors() {
6093 return mExtras != null && mExtras.hasFileDescriptors();
6094 }
The Android Open Source Project10592532009-03-18 17:39:46 -07006095
Jeff Sharkeyd136e512016-03-09 22:30:56 -07006096 /** {@hide} */
Dianne Hackborn9ecebbf2011-09-28 23:19:47 -04006097 public void setAllowFds(boolean allowFds) {
6098 if (mExtras != null) {
6099 mExtras.setAllowFds(allowFds);
6100 }
6101 }
6102
Jeff Sharkeyd136e512016-03-09 22:30:56 -07006103 /** {@hide} */
6104 public void setDefusable(boolean defusable) {
6105 if (mExtras != null) {
6106 mExtras.setDefusable(defusable);
6107 }
6108 }
6109
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006110 /**
6111 * Retrieve extended data from the intent.
6112 *
6113 * @param name The name of the desired item.
6114 *
6115 * @return the value of an item that previously added with putExtra()
6116 * or null if none was found.
6117 *
6118 * @deprecated
6119 * @hide
6120 */
6121 @Deprecated
6122 public Object getExtra(String name) {
6123 return getExtra(name, null);
6124 }
6125
6126 /**
6127 * Retrieve extended data from the intent.
6128 *
6129 * @param name The name of the desired item.
6130 * @param defaultValue the value to be returned if no value of the desired
6131 * type is stored with the given name.
6132 *
6133 * @return the value of an item that previously added with putExtra()
6134 * or the default value if none was found.
6135 *
6136 * @see #putExtra(String, boolean)
6137 */
6138 public boolean getBooleanExtra(String name, boolean defaultValue) {
6139 return mExtras == null ? defaultValue :
6140 mExtras.getBoolean(name, defaultValue);
6141 }
6142
6143 /**
6144 * Retrieve extended data from the intent.
6145 *
6146 * @param name The name of the desired item.
6147 * @param defaultValue the value to be returned if no value of the desired
6148 * type is stored with the given name.
6149 *
6150 * @return the value of an item that previously added with putExtra()
6151 * or the default value if none was found.
6152 *
6153 * @see #putExtra(String, byte)
6154 */
6155 public byte getByteExtra(String name, byte defaultValue) {
6156 return mExtras == null ? defaultValue :
6157 mExtras.getByte(name, defaultValue);
6158 }
6159
6160 /**
6161 * Retrieve extended data from the intent.
6162 *
6163 * @param name The name of the desired item.
6164 * @param defaultValue the value to be returned if no value of the desired
6165 * type is stored with the given name.
6166 *
6167 * @return the value of an item that previously added with putExtra()
6168 * or the default value if none was found.
6169 *
6170 * @see #putExtra(String, short)
6171 */
6172 public short getShortExtra(String name, short defaultValue) {
6173 return mExtras == null ? defaultValue :
6174 mExtras.getShort(name, defaultValue);
6175 }
6176
6177 /**
6178 * Retrieve extended data from the intent.
6179 *
6180 * @param name The name of the desired item.
6181 * @param defaultValue the value to be returned if no value of the desired
6182 * type is stored with the given name.
6183 *
6184 * @return the value of an item that previously added with putExtra()
6185 * or the default value if none was found.
6186 *
6187 * @see #putExtra(String, char)
6188 */
6189 public char getCharExtra(String name, char defaultValue) {
6190 return mExtras == null ? defaultValue :
6191 mExtras.getChar(name, defaultValue);
6192 }
6193
6194 /**
6195 * Retrieve extended data from the intent.
6196 *
6197 * @param name The name of the desired item.
6198 * @param defaultValue the value to be returned if no value of the desired
6199 * type is stored with the given name.
6200 *
6201 * @return the value of an item that previously added with putExtra()
6202 * or the default value if none was found.
6203 *
6204 * @see #putExtra(String, int)
6205 */
6206 public int getIntExtra(String name, int defaultValue) {
6207 return mExtras == null ? defaultValue :
6208 mExtras.getInt(name, defaultValue);
6209 }
6210
6211 /**
6212 * Retrieve extended data from the intent.
6213 *
6214 * @param name The name of the desired item.
6215 * @param defaultValue the value to be returned if no value of the desired
6216 * type is stored with the given name.
6217 *
6218 * @return the value of an item that previously added with putExtra()
6219 * or the default value if none was found.
6220 *
6221 * @see #putExtra(String, long)
6222 */
6223 public long getLongExtra(String name, long defaultValue) {
6224 return mExtras == null ? defaultValue :
6225 mExtras.getLong(name, defaultValue);
6226 }
6227
6228 /**
6229 * Retrieve extended data from the intent.
6230 *
6231 * @param name The name of the desired item.
6232 * @param defaultValue the value to be returned if no value of the desired
6233 * type is stored with the given name.
6234 *
6235 * @return the value of an item that previously added with putExtra(),
6236 * or the default value if no such item is present
6237 *
6238 * @see #putExtra(String, float)
6239 */
6240 public float getFloatExtra(String name, float defaultValue) {
6241 return mExtras == null ? defaultValue :
6242 mExtras.getFloat(name, defaultValue);
6243 }
6244
6245 /**
6246 * Retrieve extended data from the intent.
6247 *
6248 * @param name The name of the desired item.
6249 * @param defaultValue the value to be returned if no value of the desired
6250 * type is stored with the given name.
6251 *
6252 * @return the value of an item that previously added with putExtra()
6253 * or the default value if none was found.
6254 *
6255 * @see #putExtra(String, double)
6256 */
6257 public double getDoubleExtra(String name, double defaultValue) {
6258 return mExtras == null ? defaultValue :
6259 mExtras.getDouble(name, defaultValue);
6260 }
6261
6262 /**
6263 * Retrieve extended data from the intent.
6264 *
6265 * @param name The name of the desired item.
6266 *
6267 * @return the value of an item that previously added with putExtra()
6268 * or null if no String value was found.
6269 *
6270 * @see #putExtra(String, String)
6271 */
6272 public String getStringExtra(String name) {
6273 return mExtras == null ? null : mExtras.getString(name);
6274 }
6275
6276 /**
6277 * Retrieve extended data from the intent.
6278 *
6279 * @param name The name of the desired item.
6280 *
6281 * @return the value of an item that previously added with putExtra()
6282 * or null if no CharSequence value was found.
6283 *
6284 * @see #putExtra(String, CharSequence)
6285 */
6286 public CharSequence getCharSequenceExtra(String name) {
6287 return mExtras == null ? null : mExtras.getCharSequence(name);
6288 }
6289
6290 /**
6291 * Retrieve extended data from the intent.
6292 *
6293 * @param name The name of the desired item.
6294 *
6295 * @return the value of an item that previously added with putExtra()
6296 * or null if no Parcelable value was found.
6297 *
6298 * @see #putExtra(String, Parcelable)
6299 */
6300 public <T extends Parcelable> T getParcelableExtra(String name) {
6301 return mExtras == null ? null : mExtras.<T>getParcelable(name);
6302 }
6303
6304 /**
6305 * Retrieve extended data from the intent.
6306 *
6307 * @param name The name of the desired item.
6308 *
6309 * @return the value of an item that previously added with putExtra()
6310 * or null if no Parcelable[] value was found.
6311 *
6312 * @see #putExtra(String, Parcelable[])
6313 */
6314 public Parcelable[] getParcelableArrayExtra(String name) {
6315 return mExtras == null ? null : mExtras.getParcelableArray(name);
6316 }
6317
6318 /**
6319 * Retrieve extended data from the intent.
6320 *
6321 * @param name The name of the desired item.
6322 *
6323 * @return the value of an item that previously added with putExtra()
6324 * or null if no ArrayList<Parcelable> value was found.
6325 *
6326 * @see #putParcelableArrayListExtra(String, ArrayList)
6327 */
6328 public <T extends Parcelable> ArrayList<T> getParcelableArrayListExtra(String name) {
6329 return mExtras == null ? null : mExtras.<T>getParcelableArrayList(name);
6330 }
6331
6332 /**
6333 * Retrieve extended data from the intent.
6334 *
6335 * @param name The name of the desired item.
6336 *
6337 * @return the value of an item that previously added with putExtra()
6338 * or null if no Serializable value was found.
6339 *
6340 * @see #putExtra(String, Serializable)
6341 */
6342 public Serializable getSerializableExtra(String name) {
6343 return mExtras == null ? null : mExtras.getSerializable(name);
6344 }
6345
6346 /**
6347 * Retrieve extended data from the intent.
6348 *
6349 * @param name The name of the desired item.
6350 *
6351 * @return the value of an item that previously added with putExtra()
6352 * or null if no ArrayList<Integer> value was found.
6353 *
6354 * @see #putIntegerArrayListExtra(String, ArrayList)
6355 */
6356 public ArrayList<Integer> getIntegerArrayListExtra(String name) {
6357 return mExtras == null ? null : mExtras.getIntegerArrayList(name);
6358 }
6359
6360 /**
6361 * Retrieve extended data from the intent.
6362 *
6363 * @param name The name of the desired item.
6364 *
6365 * @return the value of an item that previously added with putExtra()
6366 * or null if no ArrayList<String> value was found.
6367 *
6368 * @see #putStringArrayListExtra(String, ArrayList)
6369 */
6370 public ArrayList<String> getStringArrayListExtra(String name) {
6371 return mExtras == null ? null : mExtras.getStringArrayList(name);
6372 }
6373
6374 /**
6375 * Retrieve extended data from the intent.
6376 *
6377 * @param name The name of the desired item.
6378 *
6379 * @return the value of an item that previously added with putExtra()
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00006380 * or null if no ArrayList<CharSequence> value was found.
6381 *
6382 * @see #putCharSequenceArrayListExtra(String, ArrayList)
6383 */
6384 public ArrayList<CharSequence> getCharSequenceArrayListExtra(String name) {
6385 return mExtras == null ? null : mExtras.getCharSequenceArrayList(name);
6386 }
6387
6388 /**
6389 * Retrieve extended data from the intent.
6390 *
6391 * @param name The name of the desired item.
6392 *
6393 * @return the value of an item that previously added with putExtra()
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006394 * or null if no boolean array value was found.
6395 *
6396 * @see #putExtra(String, boolean[])
6397 */
6398 public boolean[] getBooleanArrayExtra(String name) {
6399 return mExtras == null ? null : mExtras.getBooleanArray(name);
6400 }
6401
6402 /**
6403 * Retrieve extended data from the intent.
6404 *
6405 * @param name The name of the desired item.
6406 *
6407 * @return the value of an item that previously added with putExtra()
6408 * or null if no byte array value was found.
6409 *
6410 * @see #putExtra(String, byte[])
6411 */
6412 public byte[] getByteArrayExtra(String name) {
6413 return mExtras == null ? null : mExtras.getByteArray(name);
6414 }
6415
6416 /**
6417 * Retrieve extended data from the intent.
6418 *
6419 * @param name The name of the desired item.
6420 *
6421 * @return the value of an item that previously added with putExtra()
6422 * or null if no short array value was found.
6423 *
6424 * @see #putExtra(String, short[])
6425 */
6426 public short[] getShortArrayExtra(String name) {
6427 return mExtras == null ? null : mExtras.getShortArray(name);
6428 }
6429
6430 /**
6431 * Retrieve extended data from the intent.
6432 *
6433 * @param name The name of the desired item.
6434 *
6435 * @return the value of an item that previously added with putExtra()
6436 * or null if no char array value was found.
6437 *
6438 * @see #putExtra(String, char[])
6439 */
6440 public char[] getCharArrayExtra(String name) {
6441 return mExtras == null ? null : mExtras.getCharArray(name);
6442 }
6443
6444 /**
6445 * Retrieve extended data from the intent.
6446 *
6447 * @param name The name of the desired item.
6448 *
6449 * @return the value of an item that previously added with putExtra()
6450 * or null if no int array value was found.
6451 *
6452 * @see #putExtra(String, int[])
6453 */
6454 public int[] getIntArrayExtra(String name) {
6455 return mExtras == null ? null : mExtras.getIntArray(name);
6456 }
6457
6458 /**
6459 * Retrieve extended data from the intent.
6460 *
6461 * @param name The name of the desired item.
6462 *
6463 * @return the value of an item that previously added with putExtra()
6464 * or null if no long array value was found.
6465 *
6466 * @see #putExtra(String, long[])
6467 */
6468 public long[] getLongArrayExtra(String name) {
6469 return mExtras == null ? null : mExtras.getLongArray(name);
6470 }
6471
6472 /**
6473 * Retrieve extended data from the intent.
6474 *
6475 * @param name The name of the desired item.
6476 *
6477 * @return the value of an item that previously added with putExtra()
6478 * or null if no float array value was found.
6479 *
6480 * @see #putExtra(String, float[])
6481 */
6482 public float[] getFloatArrayExtra(String name) {
6483 return mExtras == null ? null : mExtras.getFloatArray(name);
6484 }
6485
6486 /**
6487 * Retrieve extended data from the intent.
6488 *
6489 * @param name The name of the desired item.
6490 *
6491 * @return the value of an item that previously added with putExtra()
6492 * or null if no double array value was found.
6493 *
6494 * @see #putExtra(String, double[])
6495 */
6496 public double[] getDoubleArrayExtra(String name) {
6497 return mExtras == null ? null : mExtras.getDoubleArray(name);
6498 }
6499
6500 /**
6501 * Retrieve extended data from the intent.
6502 *
6503 * @param name The name of the desired item.
6504 *
6505 * @return the value of an item that previously added with putExtra()
6506 * or null if no String array value was found.
6507 *
6508 * @see #putExtra(String, String[])
6509 */
6510 public String[] getStringArrayExtra(String name) {
6511 return mExtras == null ? null : mExtras.getStringArray(name);
6512 }
6513
6514 /**
6515 * Retrieve extended data from the intent.
6516 *
6517 * @param name The name of the desired item.
6518 *
6519 * @return the value of an item that previously added with putExtra()
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00006520 * or null if no CharSequence array value was found.
6521 *
6522 * @see #putExtra(String, CharSequence[])
6523 */
6524 public CharSequence[] getCharSequenceArrayExtra(String name) {
6525 return mExtras == null ? null : mExtras.getCharSequenceArray(name);
6526 }
6527
6528 /**
6529 * Retrieve extended data from the intent.
6530 *
6531 * @param name The name of the desired item.
6532 *
6533 * @return the value of an item that previously added with putExtra()
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006534 * or null if no Bundle value was found.
6535 *
6536 * @see #putExtra(String, Bundle)
6537 */
6538 public Bundle getBundleExtra(String name) {
6539 return mExtras == null ? null : mExtras.getBundle(name);
6540 }
6541
6542 /**
6543 * Retrieve extended data from the intent.
6544 *
6545 * @param name The name of the desired item.
6546 *
6547 * @return the value of an item that previously added with putExtra()
6548 * or null if no IBinder value was found.
6549 *
6550 * @see #putExtra(String, IBinder)
6551 *
6552 * @deprecated
6553 * @hide
6554 */
6555 @Deprecated
6556 public IBinder getIBinderExtra(String name) {
6557 return mExtras == null ? null : mExtras.getIBinder(name);
6558 }
6559
6560 /**
6561 * Retrieve extended data from the intent.
6562 *
6563 * @param name The name of the desired item.
6564 * @param defaultValue The default value to return in case no item is
6565 * associated with the key 'name'
6566 *
6567 * @return the value of an item that previously added with putExtra()
6568 * or defaultValue if none was found.
6569 *
6570 * @see #putExtra
6571 *
6572 * @deprecated
6573 * @hide
6574 */
6575 @Deprecated
6576 public Object getExtra(String name, Object defaultValue) {
6577 Object result = defaultValue;
6578 if (mExtras != null) {
6579 Object result2 = mExtras.get(name);
6580 if (result2 != null) {
6581 result = result2;
6582 }
6583 }
6584
6585 return result;
6586 }
6587
6588 /**
6589 * Retrieves a map of extended data from the intent.
6590 *
6591 * @return the map of all extras previously added with putExtra(),
6592 * or null if none have been added.
6593 */
6594 public Bundle getExtras() {
6595 return (mExtras != null)
6596 ? new Bundle(mExtras)
6597 : null;
6598 }
6599
6600 /**
Dianne Hackborna83ce1d2015-03-11 15:16:13 -07006601 * Filter extras to only basic types.
6602 * @hide
6603 */
6604 public void removeUnsafeExtras() {
6605 if (mExtras != null) {
6606 mExtras.filterValues();
6607 }
6608 }
6609
6610 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006611 * Retrieve any special flags associated with this intent. You will
6612 * normally just set them with {@link #setFlags} and let the system
6613 * take the appropriate action with them.
6614 *
6615 * @return int The currently set flags.
6616 *
6617 * @see #setFlags
6618 */
6619 public int getFlags() {
6620 return mFlags;
6621 }
6622
Dianne Hackborne7f97212011-02-24 14:40:20 -08006623 /** @hide */
6624 public boolean isExcludingStopped() {
6625 return (mFlags&(FLAG_EXCLUDE_STOPPED_PACKAGES|FLAG_INCLUDE_STOPPED_PACKAGES))
6626 == FLAG_EXCLUDE_STOPPED_PACKAGES;
6627 }
6628
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006629 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006630 * Retrieve the application package name this Intent is limited to. When
6631 * resolving an Intent, if non-null this limits the resolution to only
6632 * components in the given application package.
6633 *
6634 * @return The name of the application package for the Intent.
6635 *
6636 * @see #resolveActivity
6637 * @see #setPackage
6638 */
6639 public String getPackage() {
6640 return mPackage;
6641 }
6642
6643 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006644 * Retrieve the concrete component associated with the intent. When receiving
6645 * an intent, this is the component that was found to best handle it (that is,
6646 * yourself) and will always be non-null; in all other cases it will be
6647 * null unless explicitly set.
6648 *
6649 * @return The name of the application component to handle the intent.
6650 *
6651 * @see #resolveActivity
6652 * @see #setComponent
6653 */
6654 public ComponentName getComponent() {
6655 return mComponent;
6656 }
6657
6658 /**
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08006659 * Get the bounds of the sender of this intent, in screen coordinates. This can be
6660 * used as a hint to the receiver for animations and the like. Null means that there
6661 * is no source bounds.
6662 */
6663 public Rect getSourceBounds() {
6664 return mSourceBounds;
6665 }
6666
6667 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006668 * Return the Activity component that should be used to handle this intent.
6669 * The appropriate component is determined based on the information in the
6670 * intent, evaluated as follows:
6671 *
6672 * <p>If {@link #getComponent} returns an explicit class, that is returned
6673 * without any further consideration.
6674 *
6675 * <p>The activity must handle the {@link Intent#CATEGORY_DEFAULT} Intent
6676 * category to be considered.
6677 *
6678 * <p>If {@link #getAction} is non-NULL, the activity must handle this
6679 * action.
6680 *
6681 * <p>If {@link #resolveType} returns non-NULL, the activity must handle
6682 * this type.
6683 *
6684 * <p>If {@link #addCategory} has added any categories, the activity must
6685 * handle ALL of the categories specified.
6686 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006687 * <p>If {@link #getPackage} is non-NULL, only activity components in
6688 * that application package will be considered.
6689 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006690 * <p>If there are no activities that satisfy all of these conditions, a
6691 * null string is returned.
6692 *
6693 * <p>If multiple activities are found to satisfy the intent, the one with
6694 * the highest priority will be used. If there are multiple activities
6695 * with the same priority, the system will either pick the best activity
6696 * based on user preference, or resolve to a system class that will allow
6697 * the user to pick an activity and forward from there.
6698 *
6699 * <p>This method is implemented simply by calling
6700 * {@link PackageManager#resolveActivity} with the "defaultOnly" parameter
6701 * true.</p>
6702 * <p> This API is called for you as part of starting an activity from an
6703 * intent. You do not normally need to call it yourself.</p>
6704 *
6705 * @param pm The package manager with which to resolve the Intent.
6706 *
6707 * @return Name of the component implementing an activity that can
6708 * display the intent.
6709 *
6710 * @see #setComponent
6711 * @see #getComponent
6712 * @see #resolveActivityInfo
6713 */
6714 public ComponentName resolveActivity(PackageManager pm) {
6715 if (mComponent != null) {
6716 return mComponent;
6717 }
6718
6719 ResolveInfo info = pm.resolveActivity(
6720 this, PackageManager.MATCH_DEFAULT_ONLY);
6721 if (info != null) {
6722 return new ComponentName(
6723 info.activityInfo.applicationInfo.packageName,
6724 info.activityInfo.name);
6725 }
6726
6727 return null;
6728 }
6729
6730 /**
6731 * Resolve the Intent into an {@link ActivityInfo}
6732 * describing the activity that should execute the intent. Resolution
6733 * follows the same rules as described for {@link #resolveActivity}, but
6734 * you get back the completely information about the resolved activity
6735 * instead of just its class name.
6736 *
6737 * @param pm The package manager with which to resolve the Intent.
6738 * @param flags Addition information to retrieve as per
6739 * {@link PackageManager#getActivityInfo(ComponentName, int)
6740 * PackageManager.getActivityInfo()}.
6741 *
6742 * @return PackageManager.ActivityInfo
6743 *
6744 * @see #resolveActivity
6745 */
6746 public ActivityInfo resolveActivityInfo(PackageManager pm, int flags) {
6747 ActivityInfo ai = null;
6748 if (mComponent != null) {
6749 try {
6750 ai = pm.getActivityInfo(mComponent, flags);
6751 } catch (PackageManager.NameNotFoundException e) {
6752 // ignore
6753 }
6754 } else {
6755 ResolveInfo info = pm.resolveActivity(
Dianne Hackborn9bfb7072009-09-22 11:37:40 -07006756 this, PackageManager.MATCH_DEFAULT_ONLY | flags);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006757 if (info != null) {
6758 ai = info.activityInfo;
6759 }
6760 }
6761
6762 return ai;
6763 }
6764
6765 /**
Dianne Hackborn221ea892013-08-04 16:50:16 -07006766 * Special function for use by the system to resolve service
6767 * intents to system apps. Throws an exception if there are
6768 * multiple potential matches to the Intent. Returns null if
6769 * there are no matches.
6770 * @hide
6771 */
6772 public ComponentName resolveSystemService(PackageManager pm, int flags) {
6773 if (mComponent != null) {
6774 return mComponent;
6775 }
6776
6777 List<ResolveInfo> results = pm.queryIntentServices(this, flags);
6778 if (results == null) {
6779 return null;
6780 }
6781 ComponentName comp = null;
6782 for (int i=0; i<results.size(); i++) {
6783 ResolveInfo ri = results.get(i);
6784 if ((ri.serviceInfo.applicationInfo.flags&ApplicationInfo.FLAG_SYSTEM) == 0) {
6785 continue;
6786 }
6787 ComponentName foundComp = new ComponentName(ri.serviceInfo.applicationInfo.packageName,
6788 ri.serviceInfo.name);
6789 if (comp != null) {
6790 throw new IllegalStateException("Multiple system services handle " + this
6791 + ": " + comp + ", " + foundComp);
6792 }
6793 comp = foundComp;
6794 }
6795 return comp;
6796 }
6797
6798 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006799 * Set the general action to be performed.
6800 *
6801 * @param action An action name, such as ACTION_VIEW. Application-specific
6802 * actions should be prefixed with the vendor's package name.
6803 *
6804 * @return Returns the same Intent object, for chaining multiple calls
6805 * into a single statement.
6806 *
6807 * @see #getAction
6808 */
6809 public Intent setAction(String action) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08006810 mAction = action != null ? action.intern() : null;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006811 return this;
6812 }
6813
6814 /**
6815 * Set the data this intent is operating on. This method automatically
Nick Pellyccae4122012-01-09 14:12:58 -08006816 * clears any type that was previously set by {@link #setType} or
6817 * {@link #setTypeAndNormalize}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006818 *
Nick Pellyccae4122012-01-09 14:12:58 -08006819 * <p><em>Note: scheme matching in the Android framework is
6820 * case-sensitive, unlike the formal RFC. As a result,
6821 * you should always write your Uri with a lower case scheme,
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04006822 * or use {@link Uri#normalizeScheme} or
Nick Pellyccae4122012-01-09 14:12:58 -08006823 * {@link #setDataAndNormalize}
6824 * to ensure that the scheme is converted to lower case.</em>
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07006825 *
Nick Pellyccae4122012-01-09 14:12:58 -08006826 * @param data The Uri of the data this intent is now targeting.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006827 *
6828 * @return Returns the same Intent object, for chaining multiple calls
6829 * into a single statement.
6830 *
6831 * @see #getData
Nick Pellyccae4122012-01-09 14:12:58 -08006832 * @see #setDataAndNormalize
Dianne Hackborn221ea892013-08-04 16:50:16 -07006833 * @see android.net.Uri#normalizeScheme()
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006834 */
6835 public Intent setData(Uri data) {
6836 mData = data;
6837 mType = null;
6838 return this;
6839 }
6840
6841 /**
Nick Pellyccae4122012-01-09 14:12:58 -08006842 * Normalize and set the data this intent is operating on.
6843 *
6844 * <p>This method automatically clears any type that was
6845 * previously set (for example, by {@link #setType}).
6846 *
6847 * <p>The data Uri is normalized using
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04006848 * {@link android.net.Uri#normalizeScheme} before it is set,
Nick Pellyccae4122012-01-09 14:12:58 -08006849 * so really this is just a convenience method for
6850 * <pre>
6851 * setData(data.normalize())
6852 * </pre>
6853 *
6854 * @param data The Uri of the data this intent is now targeting.
6855 *
6856 * @return Returns the same Intent object, for chaining multiple calls
6857 * into a single statement.
6858 *
6859 * @see #getData
6860 * @see #setType
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04006861 * @see android.net.Uri#normalizeScheme
Nick Pellyccae4122012-01-09 14:12:58 -08006862 */
6863 public Intent setDataAndNormalize(Uri data) {
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04006864 return setData(data.normalizeScheme());
Nick Pellyccae4122012-01-09 14:12:58 -08006865 }
6866
6867 /**
6868 * Set an explicit MIME data type.
6869 *
6870 * <p>This is used to create intents that only specify a type and not data,
6871 * for example to indicate the type of data to return.
6872 *
6873 * <p>This method automatically clears any data that was
6874 * previously set (for example by {@link #setData}).
Romain Guy4969af72009-06-17 10:53:19 -07006875 *
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07006876 * <p><em>Note: MIME type matching in the Android framework is
6877 * case-sensitive, unlike formal RFC MIME types. As a result,
6878 * you should always write your MIME types with lower case letters,
Nick Pellyccae4122012-01-09 14:12:58 -08006879 * or use {@link #normalizeMimeType} or {@link #setTypeAndNormalize}
6880 * to ensure that it is converted to lower case.</em>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006881 *
6882 * @param type The MIME type of the data being handled by this intent.
6883 *
6884 * @return Returns the same Intent object, for chaining multiple calls
6885 * into a single statement.
6886 *
6887 * @see #getType
Nick Pellyccae4122012-01-09 14:12:58 -08006888 * @see #setTypeAndNormalize
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006889 * @see #setDataAndType
Nick Pellyccae4122012-01-09 14:12:58 -08006890 * @see #normalizeMimeType
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006891 */
6892 public Intent setType(String type) {
6893 mData = null;
6894 mType = type;
6895 return this;
6896 }
6897
6898 /**
Nick Pellyccae4122012-01-09 14:12:58 -08006899 * Normalize and set an explicit MIME data type.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006900 *
Nick Pellyccae4122012-01-09 14:12:58 -08006901 * <p>This is used to create intents that only specify a type and not data,
6902 * for example to indicate the type of data to return.
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07006903 *
Nick Pellyccae4122012-01-09 14:12:58 -08006904 * <p>This method automatically clears any data that was
6905 * previously set (for example by {@link #setData}).
6906 *
6907 * <p>The MIME type is normalized using
6908 * {@link #normalizeMimeType} before it is set,
6909 * so really this is just a convenience method for
6910 * <pre>
6911 * setType(Intent.normalizeMimeType(type))
6912 * </pre>
6913 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006914 * @param type The MIME type of the data being handled by this intent.
6915 *
6916 * @return Returns the same Intent object, for chaining multiple calls
6917 * into a single statement.
6918 *
Nick Pellyccae4122012-01-09 14:12:58 -08006919 * @see #getType
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006920 * @see #setData
Nick Pellyccae4122012-01-09 14:12:58 -08006921 * @see #normalizeMimeType
6922 */
6923 public Intent setTypeAndNormalize(String type) {
6924 return setType(normalizeMimeType(type));
6925 }
6926
6927 /**
6928 * (Usually optional) Set the data for the intent along with an explicit
6929 * MIME data type. This method should very rarely be used -- it allows you
6930 * to override the MIME type that would ordinarily be inferred from the
6931 * data with your own type given here.
6932 *
6933 * <p><em>Note: MIME type and Uri scheme matching in the
6934 * Android framework is case-sensitive, unlike the formal RFC definitions.
6935 * As a result, you should always write these elements with lower case letters,
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04006936 * or use {@link #normalizeMimeType} or {@link android.net.Uri#normalizeScheme} or
Nick Pellyccae4122012-01-09 14:12:58 -08006937 * {@link #setDataAndTypeAndNormalize}
6938 * to ensure that they are converted to lower case.</em>
6939 *
6940 * @param data The Uri of the data this intent is now targeting.
6941 * @param type The MIME type of the data being handled by this intent.
6942 *
6943 * @return Returns the same Intent object, for chaining multiple calls
6944 * into a single statement.
6945 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006946 * @see #setType
Nick Pellyccae4122012-01-09 14:12:58 -08006947 * @see #setData
6948 * @see #normalizeMimeType
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04006949 * @see android.net.Uri#normalizeScheme
Nick Pellyccae4122012-01-09 14:12:58 -08006950 * @see #setDataAndTypeAndNormalize
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006951 */
6952 public Intent setDataAndType(Uri data, String type) {
6953 mData = data;
6954 mType = type;
6955 return this;
6956 }
6957
6958 /**
Nick Pellyccae4122012-01-09 14:12:58 -08006959 * (Usually optional) Normalize and set both the data Uri and an explicit
6960 * MIME data type. This method should very rarely be used -- it allows you
6961 * to override the MIME type that would ordinarily be inferred from the
6962 * data with your own type given here.
6963 *
6964 * <p>The data Uri and the MIME type are normalize using
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04006965 * {@link android.net.Uri#normalizeScheme} and {@link #normalizeMimeType}
Nick Pellyccae4122012-01-09 14:12:58 -08006966 * before they are set, so really this is just a convenience method for
6967 * <pre>
6968 * setDataAndType(data.normalize(), Intent.normalizeMimeType(type))
6969 * </pre>
6970 *
6971 * @param data The Uri of the data this intent is now targeting.
6972 * @param type The MIME type of the data being handled by this intent.
6973 *
6974 * @return Returns the same Intent object, for chaining multiple calls
6975 * into a single statement.
6976 *
6977 * @see #setType
6978 * @see #setData
6979 * @see #setDataAndType
6980 * @see #normalizeMimeType
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04006981 * @see android.net.Uri#normalizeScheme
Nick Pellyccae4122012-01-09 14:12:58 -08006982 */
6983 public Intent setDataAndTypeAndNormalize(Uri data, String type) {
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04006984 return setDataAndType(data.normalizeScheme(), normalizeMimeType(type));
Nick Pellyccae4122012-01-09 14:12:58 -08006985 }
6986
6987 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006988 * Add a new category to the intent. Categories provide additional detail
Ken Wakasaf76a50c2012-03-09 19:56:35 +09006989 * about the action the intent performs. When resolving an intent, only
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006990 * activities that provide <em>all</em> of the requested categories will be
6991 * used.
6992 *
6993 * @param category The desired category. This can be either one of the
6994 * predefined Intent categories, or a custom category in your own
6995 * namespace.
6996 *
6997 * @return Returns the same Intent object, for chaining multiple calls
6998 * into a single statement.
6999 *
7000 * @see #hasCategory
7001 * @see #removeCategory
7002 */
7003 public Intent addCategory(String category) {
7004 if (mCategories == null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07007005 mCategories = new ArraySet<String>();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007006 }
Jeff Brown2c376fc2011-01-28 17:34:01 -08007007 mCategories.add(category.intern());
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007008 return this;
7009 }
7010
7011 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09007012 * Remove a category from an intent.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007013 *
7014 * @param category The category to remove.
7015 *
7016 * @see #addCategory
7017 */
7018 public void removeCategory(String category) {
7019 if (mCategories != null) {
7020 mCategories.remove(category);
7021 if (mCategories.size() == 0) {
7022 mCategories = null;
7023 }
7024 }
7025 }
7026
7027 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08007028 * Set a selector for this Intent. This is a modification to the kinds of
7029 * things the Intent will match. If the selector is set, it will be used
7030 * when trying to find entities that can handle the Intent, instead of the
7031 * main contents of the Intent. This allows you build an Intent containing
7032 * a generic protocol while targeting it more specifically.
7033 *
7034 * <p>An example of where this may be used is with things like
7035 * {@link #CATEGORY_APP_BROWSER}. This category allows you to build an
7036 * Intent that will launch the Browser application. However, the correct
7037 * main entry point of an application is actually {@link #ACTION_MAIN}
7038 * {@link #CATEGORY_LAUNCHER} with {@link #setComponent(ComponentName)}
7039 * used to specify the actual Activity to launch. If you launch the browser
7040 * with something different, undesired behavior may happen if the user has
7041 * previously or later launches it the normal way, since they do not match.
7042 * Instead, you can build an Intent with the MAIN action (but no ComponentName
7043 * yet specified) and set a selector with {@link #ACTION_MAIN} and
7044 * {@link #CATEGORY_APP_BROWSER} to point it specifically to the browser activity.
7045 *
7046 * <p>Setting a selector does not impact the behavior of
7047 * {@link #filterEquals(Intent)} and {@link #filterHashCode()}. This is part of the
7048 * desired behavior of a selector -- it does not impact the base meaning
7049 * of the Intent, just what kinds of things will be matched against it
7050 * when determining who can handle it.</p>
7051 *
7052 * <p>You can not use both a selector and {@link #setPackage(String)} on
7053 * the same base Intent.</p>
7054 *
7055 * @param selector The desired selector Intent; set to null to not use
7056 * a special selector.
7057 */
7058 public void setSelector(Intent selector) {
7059 if (selector == this) {
7060 throw new IllegalArgumentException(
7061 "Intent being set as a selector of itself");
7062 }
7063 if (selector != null && mPackage != null) {
7064 throw new IllegalArgumentException(
7065 "Can't set selector when package name is already set");
7066 }
7067 mSelector = selector;
7068 }
7069
7070 /**
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007071 * Set a {@link ClipData} associated with this Intent. This replaces any
7072 * previously set ClipData.
7073 *
7074 * <p>The ClipData in an intent is not used for Intent matching or other
7075 * such operations. Semantically it is like extras, used to transmit
7076 * additional data with the Intent. The main feature of using this over
7077 * the extras for data is that {@link #FLAG_GRANT_READ_URI_PERMISSION}
7078 * and {@link #FLAG_GRANT_WRITE_URI_PERMISSION} will operate on any URI
7079 * items included in the clip data. This is useful, in particular, if
7080 * you want to transmit an Intent containing multiple <code>content:</code>
7081 * URIs for which the recipient may not have global permission to access the
7082 * content provider.
7083 *
7084 * <p>If the ClipData contains items that are themselves Intents, any
7085 * grant flags in those Intents will be ignored. Only the top-level flags
7086 * of the main Intent are respected, and will be applied to all Uri or
7087 * Intent items in the clip (or sub-items of the clip).
7088 *
7089 * <p>The MIME type, label, and icon in the ClipData object are not
7090 * directly used by Intent. Applications should generally rely on the
7091 * MIME type of the Intent itself, not what it may find in the ClipData.
7092 * A common practice is to construct a ClipData for use with an Intent
John Spurlock33900182014-01-02 11:04:18 -05007093 * with a MIME type of "*&#47;*".
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007094 *
7095 * @param clip The new clip to set. May be null to clear the current clip.
7096 */
7097 public void setClipData(ClipData clip) {
7098 mClipData = clip;
7099 }
7100
7101 /**
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01007102 * This is NOT a secure mechanism to identify the user who sent the intent.
7103 * When the intent is sent to a different user, it is used to fix uris by adding the userId
7104 * who sent the intent.
7105 * @hide
7106 */
Nicolas Prevot107f7b72015-07-01 16:31:48 +01007107 public void prepareToLeaveUser(int userId) {
7108 // If mContentUserHint is not UserHandle.USER_CURRENT, the intent has already left a user.
7109 // We want mContentUserHint to refer to the original user, so don't do anything.
7110 if (mContentUserHint == UserHandle.USER_CURRENT) {
7111 mContentUserHint = userId;
7112 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01007113 }
7114
7115 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007116 * Add extended data to the intent. The name must include a package
7117 * prefix, for example the app com.android.contacts would use names
7118 * like "com.android.contacts.ShowAll".
7119 *
7120 * @param name The name of the extra data, with package prefix.
7121 * @param value The boolean data value.
7122 *
7123 * @return Returns the same Intent object, for chaining multiple calls
7124 * into a single statement.
7125 *
7126 * @see #putExtras
7127 * @see #removeExtra
7128 * @see #getBooleanExtra(String, boolean)
7129 */
7130 public Intent putExtra(String name, boolean value) {
7131 if (mExtras == null) {
7132 mExtras = new Bundle();
7133 }
7134 mExtras.putBoolean(name, value);
7135 return this;
7136 }
7137
7138 /**
7139 * Add extended data to the intent. The name must include a package
7140 * prefix, for example the app com.android.contacts would use names
7141 * like "com.android.contacts.ShowAll".
7142 *
7143 * @param name The name of the extra data, with package prefix.
7144 * @param value The byte data value.
7145 *
7146 * @return Returns the same Intent object, for chaining multiple calls
7147 * into a single statement.
7148 *
7149 * @see #putExtras
7150 * @see #removeExtra
7151 * @see #getByteExtra(String, byte)
7152 */
7153 public Intent putExtra(String name, byte value) {
7154 if (mExtras == null) {
7155 mExtras = new Bundle();
7156 }
7157 mExtras.putByte(name, value);
7158 return this;
7159 }
7160
7161 /**
7162 * Add extended data to the intent. The name must include a package
7163 * prefix, for example the app com.android.contacts would use names
7164 * like "com.android.contacts.ShowAll".
7165 *
7166 * @param name The name of the extra data, with package prefix.
7167 * @param value The char data value.
7168 *
7169 * @return Returns the same Intent object, for chaining multiple calls
7170 * into a single statement.
7171 *
7172 * @see #putExtras
7173 * @see #removeExtra
7174 * @see #getCharExtra(String, char)
7175 */
7176 public Intent putExtra(String name, char value) {
7177 if (mExtras == null) {
7178 mExtras = new Bundle();
7179 }
7180 mExtras.putChar(name, value);
7181 return this;
7182 }
7183
7184 /**
7185 * Add extended data to the intent. The name must include a package
7186 * prefix, for example the app com.android.contacts would use names
7187 * like "com.android.contacts.ShowAll".
7188 *
7189 * @param name The name of the extra data, with package prefix.
7190 * @param value The short data value.
7191 *
7192 * @return Returns the same Intent object, for chaining multiple calls
7193 * into a single statement.
7194 *
7195 * @see #putExtras
7196 * @see #removeExtra
7197 * @see #getShortExtra(String, short)
7198 */
7199 public Intent putExtra(String name, short value) {
7200 if (mExtras == null) {
7201 mExtras = new Bundle();
7202 }
7203 mExtras.putShort(name, value);
7204 return this;
7205 }
7206
7207 /**
7208 * Add extended data to the intent. The name must include a package
7209 * prefix, for example the app com.android.contacts would use names
7210 * like "com.android.contacts.ShowAll".
7211 *
7212 * @param name The name of the extra data, with package prefix.
7213 * @param value The integer data value.
7214 *
7215 * @return Returns the same Intent object, for chaining multiple calls
7216 * into a single statement.
7217 *
7218 * @see #putExtras
7219 * @see #removeExtra
7220 * @see #getIntExtra(String, int)
7221 */
7222 public Intent putExtra(String name, int value) {
7223 if (mExtras == null) {
7224 mExtras = new Bundle();
7225 }
7226 mExtras.putInt(name, value);
7227 return this;
7228 }
7229
7230 /**
7231 * Add extended data to the intent. The name must include a package
7232 * prefix, for example the app com.android.contacts would use names
7233 * like "com.android.contacts.ShowAll".
7234 *
7235 * @param name The name of the extra data, with package prefix.
7236 * @param value The long data value.
7237 *
7238 * @return Returns the same Intent object, for chaining multiple calls
7239 * into a single statement.
7240 *
7241 * @see #putExtras
7242 * @see #removeExtra
7243 * @see #getLongExtra(String, long)
7244 */
7245 public Intent putExtra(String name, long value) {
7246 if (mExtras == null) {
7247 mExtras = new Bundle();
7248 }
7249 mExtras.putLong(name, value);
7250 return this;
7251 }
7252
7253 /**
7254 * Add extended data to the intent. The name must include a package
7255 * prefix, for example the app com.android.contacts would use names
7256 * like "com.android.contacts.ShowAll".
7257 *
7258 * @param name The name of the extra data, with package prefix.
7259 * @param value The float data value.
7260 *
7261 * @return Returns the same Intent object, for chaining multiple calls
7262 * into a single statement.
7263 *
7264 * @see #putExtras
7265 * @see #removeExtra
7266 * @see #getFloatExtra(String, float)
7267 */
7268 public Intent putExtra(String name, float value) {
7269 if (mExtras == null) {
7270 mExtras = new Bundle();
7271 }
7272 mExtras.putFloat(name, value);
7273 return this;
7274 }
7275
7276 /**
7277 * Add extended data to the intent. The name must include a package
7278 * prefix, for example the app com.android.contacts would use names
7279 * like "com.android.contacts.ShowAll".
7280 *
7281 * @param name The name of the extra data, with package prefix.
7282 * @param value The double data value.
7283 *
7284 * @return Returns the same Intent object, for chaining multiple calls
7285 * into a single statement.
7286 *
7287 * @see #putExtras
7288 * @see #removeExtra
7289 * @see #getDoubleExtra(String, double)
7290 */
7291 public Intent putExtra(String name, double value) {
7292 if (mExtras == null) {
7293 mExtras = new Bundle();
7294 }
7295 mExtras.putDouble(name, value);
7296 return this;
7297 }
7298
7299 /**
7300 * Add extended data to the intent. The name must include a package
7301 * prefix, for example the app com.android.contacts would use names
7302 * like "com.android.contacts.ShowAll".
7303 *
7304 * @param name The name of the extra data, with package prefix.
7305 * @param value The String data value.
7306 *
7307 * @return Returns the same Intent object, for chaining multiple calls
7308 * into a single statement.
7309 *
7310 * @see #putExtras
7311 * @see #removeExtra
7312 * @see #getStringExtra(String)
7313 */
7314 public Intent putExtra(String name, String value) {
7315 if (mExtras == null) {
7316 mExtras = new Bundle();
7317 }
7318 mExtras.putString(name, value);
7319 return this;
7320 }
7321
7322 /**
7323 * Add extended data to the intent. The name must include a package
7324 * prefix, for example the app com.android.contacts would use names
7325 * like "com.android.contacts.ShowAll".
7326 *
7327 * @param name The name of the extra data, with package prefix.
7328 * @param value The CharSequence data value.
7329 *
7330 * @return Returns the same Intent object, for chaining multiple calls
7331 * into a single statement.
7332 *
7333 * @see #putExtras
7334 * @see #removeExtra
7335 * @see #getCharSequenceExtra(String)
7336 */
7337 public Intent putExtra(String name, CharSequence value) {
7338 if (mExtras == null) {
7339 mExtras = new Bundle();
7340 }
7341 mExtras.putCharSequence(name, value);
7342 return this;
7343 }
7344
7345 /**
7346 * Add extended data to the intent. The name must include a package
7347 * prefix, for example the app com.android.contacts would use names
7348 * like "com.android.contacts.ShowAll".
7349 *
7350 * @param name The name of the extra data, with package prefix.
7351 * @param value The Parcelable data value.
7352 *
7353 * @return Returns the same Intent object, for chaining multiple calls
7354 * into a single statement.
7355 *
7356 * @see #putExtras
7357 * @see #removeExtra
7358 * @see #getParcelableExtra(String)
7359 */
7360 public Intent putExtra(String name, Parcelable value) {
7361 if (mExtras == null) {
7362 mExtras = new Bundle();
7363 }
7364 mExtras.putParcelable(name, value);
7365 return this;
7366 }
7367
7368 /**
7369 * Add extended data to the intent. The name must include a package
7370 * prefix, for example the app com.android.contacts would use names
7371 * like "com.android.contacts.ShowAll".
7372 *
7373 * @param name The name of the extra data, with package prefix.
7374 * @param value The Parcelable[] data value.
7375 *
7376 * @return Returns the same Intent object, for chaining multiple calls
7377 * into a single statement.
7378 *
7379 * @see #putExtras
7380 * @see #removeExtra
7381 * @see #getParcelableArrayExtra(String)
7382 */
7383 public Intent putExtra(String name, Parcelable[] value) {
7384 if (mExtras == null) {
7385 mExtras = new Bundle();
7386 }
7387 mExtras.putParcelableArray(name, value);
7388 return this;
7389 }
7390
7391 /**
7392 * Add extended data to the intent. The name must include a package
7393 * prefix, for example the app com.android.contacts would use names
7394 * like "com.android.contacts.ShowAll".
7395 *
7396 * @param name The name of the extra data, with package prefix.
7397 * @param value The ArrayList<Parcelable> data value.
7398 *
7399 * @return Returns the same Intent object, for chaining multiple calls
7400 * into a single statement.
7401 *
7402 * @see #putExtras
7403 * @see #removeExtra
7404 * @see #getParcelableArrayListExtra(String)
7405 */
7406 public Intent putParcelableArrayListExtra(String name, ArrayList<? extends Parcelable> value) {
7407 if (mExtras == null) {
7408 mExtras = new Bundle();
7409 }
7410 mExtras.putParcelableArrayList(name, value);
7411 return this;
7412 }
7413
7414 /**
7415 * Add extended data to the intent. The name must include a package
7416 * prefix, for example the app com.android.contacts would use names
7417 * like "com.android.contacts.ShowAll".
7418 *
7419 * @param name The name of the extra data, with package prefix.
7420 * @param value The ArrayList<Integer> data value.
7421 *
7422 * @return Returns the same Intent object, for chaining multiple calls
7423 * into a single statement.
7424 *
7425 * @see #putExtras
7426 * @see #removeExtra
7427 * @see #getIntegerArrayListExtra(String)
7428 */
7429 public Intent putIntegerArrayListExtra(String name, ArrayList<Integer> value) {
7430 if (mExtras == null) {
7431 mExtras = new Bundle();
7432 }
7433 mExtras.putIntegerArrayList(name, value);
7434 return this;
7435 }
7436
7437 /**
7438 * Add extended data to the intent. The name must include a package
7439 * prefix, for example the app com.android.contacts would use names
7440 * like "com.android.contacts.ShowAll".
7441 *
7442 * @param name The name of the extra data, with package prefix.
7443 * @param value The ArrayList<String> data value.
7444 *
7445 * @return Returns the same Intent object, for chaining multiple calls
7446 * into a single statement.
7447 *
7448 * @see #putExtras
7449 * @see #removeExtra
7450 * @see #getStringArrayListExtra(String)
7451 */
7452 public Intent putStringArrayListExtra(String name, ArrayList<String> value) {
7453 if (mExtras == null) {
7454 mExtras = new Bundle();
7455 }
7456 mExtras.putStringArrayList(name, value);
7457 return this;
7458 }
7459
7460 /**
7461 * Add extended data to the intent. The name must include a package
7462 * prefix, for example the app com.android.contacts would use names
7463 * like "com.android.contacts.ShowAll".
7464 *
7465 * @param name The name of the extra data, with package prefix.
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00007466 * @param value The ArrayList<CharSequence> data value.
7467 *
7468 * @return Returns the same Intent object, for chaining multiple calls
7469 * into a single statement.
7470 *
7471 * @see #putExtras
7472 * @see #removeExtra
7473 * @see #getCharSequenceArrayListExtra(String)
7474 */
7475 public Intent putCharSequenceArrayListExtra(String name, ArrayList<CharSequence> value) {
7476 if (mExtras == null) {
7477 mExtras = new Bundle();
7478 }
7479 mExtras.putCharSequenceArrayList(name, value);
7480 return this;
7481 }
7482
7483 /**
7484 * Add extended data to the intent. The name must include a package
7485 * prefix, for example the app com.android.contacts would use names
7486 * like "com.android.contacts.ShowAll".
7487 *
7488 * @param name The name of the extra data, with package prefix.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007489 * @param value The Serializable data value.
7490 *
7491 * @return Returns the same Intent object, for chaining multiple calls
7492 * into a single statement.
7493 *
7494 * @see #putExtras
7495 * @see #removeExtra
7496 * @see #getSerializableExtra(String)
7497 */
7498 public Intent putExtra(String name, Serializable value) {
7499 if (mExtras == null) {
7500 mExtras = new Bundle();
7501 }
7502 mExtras.putSerializable(name, value);
7503 return this;
7504 }
7505
7506 /**
7507 * Add extended data to the intent. The name must include a package
7508 * prefix, for example the app com.android.contacts would use names
7509 * like "com.android.contacts.ShowAll".
7510 *
7511 * @param name The name of the extra data, with package prefix.
7512 * @param value The boolean array data value.
7513 *
7514 * @return Returns the same Intent object, for chaining multiple calls
7515 * into a single statement.
7516 *
7517 * @see #putExtras
7518 * @see #removeExtra
7519 * @see #getBooleanArrayExtra(String)
7520 */
7521 public Intent putExtra(String name, boolean[] value) {
7522 if (mExtras == null) {
7523 mExtras = new Bundle();
7524 }
7525 mExtras.putBooleanArray(name, value);
7526 return this;
7527 }
7528
7529 /**
7530 * Add extended data to the intent. The name must include a package
7531 * prefix, for example the app com.android.contacts would use names
7532 * like "com.android.contacts.ShowAll".
7533 *
7534 * @param name The name of the extra data, with package prefix.
7535 * @param value The byte array data value.
7536 *
7537 * @return Returns the same Intent object, for chaining multiple calls
7538 * into a single statement.
7539 *
7540 * @see #putExtras
7541 * @see #removeExtra
7542 * @see #getByteArrayExtra(String)
7543 */
7544 public Intent putExtra(String name, byte[] value) {
7545 if (mExtras == null) {
7546 mExtras = new Bundle();
7547 }
7548 mExtras.putByteArray(name, value);
7549 return this;
7550 }
7551
7552 /**
7553 * Add extended data to the intent. The name must include a package
7554 * prefix, for example the app com.android.contacts would use names
7555 * like "com.android.contacts.ShowAll".
7556 *
7557 * @param name The name of the extra data, with package prefix.
7558 * @param value The short array data value.
7559 *
7560 * @return Returns the same Intent object, for chaining multiple calls
7561 * into a single statement.
7562 *
7563 * @see #putExtras
7564 * @see #removeExtra
7565 * @see #getShortArrayExtra(String)
7566 */
7567 public Intent putExtra(String name, short[] value) {
7568 if (mExtras == null) {
7569 mExtras = new Bundle();
7570 }
7571 mExtras.putShortArray(name, value);
7572 return this;
7573 }
7574
7575 /**
7576 * Add extended data to the intent. The name must include a package
7577 * prefix, for example the app com.android.contacts would use names
7578 * like "com.android.contacts.ShowAll".
7579 *
7580 * @param name The name of the extra data, with package prefix.
7581 * @param value The char array data value.
7582 *
7583 * @return Returns the same Intent object, for chaining multiple calls
7584 * into a single statement.
7585 *
7586 * @see #putExtras
7587 * @see #removeExtra
7588 * @see #getCharArrayExtra(String)
7589 */
7590 public Intent putExtra(String name, char[] value) {
7591 if (mExtras == null) {
7592 mExtras = new Bundle();
7593 }
7594 mExtras.putCharArray(name, value);
7595 return this;
7596 }
7597
7598 /**
7599 * Add extended data to the intent. The name must include a package
7600 * prefix, for example the app com.android.contacts would use names
7601 * like "com.android.contacts.ShowAll".
7602 *
7603 * @param name The name of the extra data, with package prefix.
7604 * @param value The int array data value.
7605 *
7606 * @return Returns the same Intent object, for chaining multiple calls
7607 * into a single statement.
7608 *
7609 * @see #putExtras
7610 * @see #removeExtra
7611 * @see #getIntArrayExtra(String)
7612 */
7613 public Intent putExtra(String name, int[] value) {
7614 if (mExtras == null) {
7615 mExtras = new Bundle();
7616 }
7617 mExtras.putIntArray(name, value);
7618 return this;
7619 }
7620
7621 /**
7622 * Add extended data to the intent. The name must include a package
7623 * prefix, for example the app com.android.contacts would use names
7624 * like "com.android.contacts.ShowAll".
7625 *
7626 * @param name The name of the extra data, with package prefix.
7627 * @param value The byte array data value.
7628 *
7629 * @return Returns the same Intent object, for chaining multiple calls
7630 * into a single statement.
7631 *
7632 * @see #putExtras
7633 * @see #removeExtra
7634 * @see #getLongArrayExtra(String)
7635 */
7636 public Intent putExtra(String name, long[] value) {
7637 if (mExtras == null) {
7638 mExtras = new Bundle();
7639 }
7640 mExtras.putLongArray(name, value);
7641 return this;
7642 }
7643
7644 /**
7645 * Add extended data to the intent. The name must include a package
7646 * prefix, for example the app com.android.contacts would use names
7647 * like "com.android.contacts.ShowAll".
7648 *
7649 * @param name The name of the extra data, with package prefix.
7650 * @param value The float array data value.
7651 *
7652 * @return Returns the same Intent object, for chaining multiple calls
7653 * into a single statement.
7654 *
7655 * @see #putExtras
7656 * @see #removeExtra
7657 * @see #getFloatArrayExtra(String)
7658 */
7659 public Intent putExtra(String name, float[] value) {
7660 if (mExtras == null) {
7661 mExtras = new Bundle();
7662 }
7663 mExtras.putFloatArray(name, value);
7664 return this;
7665 }
7666
7667 /**
7668 * Add extended data to the intent. The name must include a package
7669 * prefix, for example the app com.android.contacts would use names
7670 * like "com.android.contacts.ShowAll".
7671 *
7672 * @param name The name of the extra data, with package prefix.
7673 * @param value The double array data value.
7674 *
7675 * @return Returns the same Intent object, for chaining multiple calls
7676 * into a single statement.
7677 *
7678 * @see #putExtras
7679 * @see #removeExtra
7680 * @see #getDoubleArrayExtra(String)
7681 */
7682 public Intent putExtra(String name, double[] value) {
7683 if (mExtras == null) {
7684 mExtras = new Bundle();
7685 }
7686 mExtras.putDoubleArray(name, value);
7687 return this;
7688 }
7689
7690 /**
7691 * Add extended data to the intent. The name must include a package
7692 * prefix, for example the app com.android.contacts would use names
7693 * like "com.android.contacts.ShowAll".
7694 *
7695 * @param name The name of the extra data, with package prefix.
7696 * @param value The String array data value.
7697 *
7698 * @return Returns the same Intent object, for chaining multiple calls
7699 * into a single statement.
7700 *
7701 * @see #putExtras
7702 * @see #removeExtra
7703 * @see #getStringArrayExtra(String)
7704 */
7705 public Intent putExtra(String name, String[] value) {
7706 if (mExtras == null) {
7707 mExtras = new Bundle();
7708 }
7709 mExtras.putStringArray(name, value);
7710 return this;
7711 }
7712
7713 /**
7714 * Add extended data to the intent. The name must include a package
7715 * prefix, for example the app com.android.contacts would use names
7716 * like "com.android.contacts.ShowAll".
7717 *
7718 * @param name The name of the extra data, with package prefix.
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00007719 * @param value The CharSequence array data value.
7720 *
7721 * @return Returns the same Intent object, for chaining multiple calls
7722 * into a single statement.
7723 *
7724 * @see #putExtras
7725 * @see #removeExtra
7726 * @see #getCharSequenceArrayExtra(String)
7727 */
7728 public Intent putExtra(String name, CharSequence[] value) {
7729 if (mExtras == null) {
7730 mExtras = new Bundle();
7731 }
7732 mExtras.putCharSequenceArray(name, value);
7733 return this;
7734 }
7735
7736 /**
7737 * Add extended data to the intent. The name must include a package
7738 * prefix, for example the app com.android.contacts would use names
7739 * like "com.android.contacts.ShowAll".
7740 *
7741 * @param name The name of the extra data, with package prefix.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007742 * @param value The Bundle data value.
7743 *
7744 * @return Returns the same Intent object, for chaining multiple calls
7745 * into a single statement.
7746 *
7747 * @see #putExtras
7748 * @see #removeExtra
7749 * @see #getBundleExtra(String)
7750 */
7751 public Intent putExtra(String name, Bundle value) {
7752 if (mExtras == null) {
7753 mExtras = new Bundle();
7754 }
7755 mExtras.putBundle(name, value);
7756 return this;
7757 }
7758
7759 /**
7760 * Add extended data to the intent. The name must include a package
7761 * prefix, for example the app com.android.contacts would use names
7762 * like "com.android.contacts.ShowAll".
7763 *
7764 * @param name The name of the extra data, with package prefix.
7765 * @param value The IBinder data value.
7766 *
7767 * @return Returns the same Intent object, for chaining multiple calls
7768 * into a single statement.
7769 *
7770 * @see #putExtras
7771 * @see #removeExtra
7772 * @see #getIBinderExtra(String)
7773 *
7774 * @deprecated
7775 * @hide
7776 */
7777 @Deprecated
7778 public Intent putExtra(String name, IBinder value) {
7779 if (mExtras == null) {
7780 mExtras = new Bundle();
7781 }
7782 mExtras.putIBinder(name, value);
7783 return this;
7784 }
7785
7786 /**
7787 * Copy all extras in 'src' in to this intent.
7788 *
7789 * @param src Contains the extras to copy.
7790 *
7791 * @see #putExtra
7792 */
7793 public Intent putExtras(Intent src) {
7794 if (src.mExtras != null) {
7795 if (mExtras == null) {
7796 mExtras = new Bundle(src.mExtras);
7797 } else {
7798 mExtras.putAll(src.mExtras);
7799 }
7800 }
7801 return this;
7802 }
7803
7804 /**
7805 * Add a set of extended data to the intent. The keys must include a package
7806 * prefix, for example the app com.android.contacts would use names
7807 * like "com.android.contacts.ShowAll".
7808 *
7809 * @param extras The Bundle of extras to add to this intent.
7810 *
7811 * @see #putExtra
7812 * @see #removeExtra
7813 */
7814 public Intent putExtras(Bundle extras) {
7815 if (mExtras == null) {
7816 mExtras = new Bundle();
7817 }
7818 mExtras.putAll(extras);
7819 return this;
7820 }
7821
7822 /**
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08007823 * Completely replace the extras in the Intent with the extras in the
7824 * given Intent.
The Android Open Source Project10592532009-03-18 17:39:46 -07007825 *
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08007826 * @param src The exact extras contained in this Intent are copied
7827 * into the target intent, replacing any that were previously there.
7828 */
7829 public Intent replaceExtras(Intent src) {
7830 mExtras = src.mExtras != null ? new Bundle(src.mExtras) : null;
7831 return this;
7832 }
The Android Open Source Project10592532009-03-18 17:39:46 -07007833
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08007834 /**
7835 * Completely replace the extras in the Intent with the given Bundle of
7836 * extras.
The Android Open Source Project10592532009-03-18 17:39:46 -07007837 *
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08007838 * @param extras The new set of extras in the Intent, or null to erase
7839 * all extras.
7840 */
7841 public Intent replaceExtras(Bundle extras) {
7842 mExtras = extras != null ? new Bundle(extras) : null;
7843 return this;
7844 }
The Android Open Source Project10592532009-03-18 17:39:46 -07007845
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08007846 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007847 * Remove extended data from the intent.
7848 *
7849 * @see #putExtra
7850 */
7851 public void removeExtra(String name) {
7852 if (mExtras != null) {
7853 mExtras.remove(name);
7854 if (mExtras.size() == 0) {
7855 mExtras = null;
7856 }
7857 }
7858 }
7859
7860 /**
7861 * Set special flags controlling how this intent is handled. Most values
7862 * here depend on the type of component being executed by the Intent,
7863 * specifically the FLAG_ACTIVITY_* flags are all for use with
7864 * {@link Context#startActivity Context.startActivity()} and the
7865 * FLAG_RECEIVER_* flags are all for use with
7866 * {@link Context#sendBroadcast(Intent) Context.sendBroadcast()}.
7867 *
Scott Main7aee61f2011-02-08 11:25:01 -08007868 * <p>See the
7869 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
7870 * Stack</a> documentation for important information on how some of these options impact
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007871 * the behavior of your application.
7872 *
7873 * @param flags The desired flags.
7874 *
7875 * @return Returns the same Intent object, for chaining multiple calls
7876 * into a single statement.
7877 *
7878 * @see #getFlags
7879 * @see #addFlags
7880 *
7881 * @see #FLAG_GRANT_READ_URI_PERMISSION
7882 * @see #FLAG_GRANT_WRITE_URI_PERMISSION
Jeff Sharkey846318a2014-04-04 12:12:41 -07007883 * @see #FLAG_GRANT_PERSISTABLE_URI_PERMISSION
7884 * @see #FLAG_GRANT_PREFIX_URI_PERMISSION
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007885 * @see #FLAG_DEBUG_LOG_RESOLUTION
7886 * @see #FLAG_FROM_BACKGROUND
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007887 * @see #FLAG_ACTIVITY_BROUGHT_TO_FRONT
Dianne Hackborn621e17d2010-11-22 15:59:56 -08007888 * @see #FLAG_ACTIVITY_CLEAR_TASK
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007889 * @see #FLAG_ACTIVITY_CLEAR_TOP
Dianne Hackborn621e17d2010-11-22 15:59:56 -08007890 * @see #FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007891 * @see #FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS
7892 * @see #FLAG_ACTIVITY_FORWARD_RESULT
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08007893 * @see #FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007894 * @see #FLAG_ACTIVITY_MULTIPLE_TASK
Craig Mautnerd00f4742014-03-12 14:17:26 -07007895 * @see #FLAG_ACTIVITY_NEW_DOCUMENT
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007896 * @see #FLAG_ACTIVITY_NEW_TASK
Dianne Hackborn621e17d2010-11-22 15:59:56 -08007897 * @see #FLAG_ACTIVITY_NO_ANIMATION
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007898 * @see #FLAG_ACTIVITY_NO_HISTORY
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08007899 * @see #FLAG_ACTIVITY_NO_USER_ACTION
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08007900 * @see #FLAG_ACTIVITY_PREVIOUS_IS_TOP
7901 * @see #FLAG_ACTIVITY_RESET_TASK_IF_NEEDED
Dianne Hackborn621e17d2010-11-22 15:59:56 -08007902 * @see #FLAG_ACTIVITY_REORDER_TO_FRONT
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007903 * @see #FLAG_ACTIVITY_SINGLE_TOP
Dianne Hackborn621e17d2010-11-22 15:59:56 -08007904 * @see #FLAG_ACTIVITY_TASK_ON_HOME
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007905 * @see #FLAG_RECEIVER_REGISTERED_ONLY
7906 */
7907 public Intent setFlags(int flags) {
7908 mFlags = flags;
7909 return this;
7910 }
7911
7912 /**
7913 * Add additional flags to the intent (or with existing flags
7914 * value).
7915 *
7916 * @param flags The new flags to set.
7917 *
7918 * @return Returns the same Intent object, for chaining multiple calls
7919 * into a single statement.
7920 *
7921 * @see #setFlags
7922 */
7923 public Intent addFlags(int flags) {
7924 mFlags |= flags;
7925 return this;
7926 }
7927
7928 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007929 * (Usually optional) Set an explicit application package name that limits
7930 * the components this Intent will resolve to. If left to the default
7931 * value of null, all components in all applications will considered.
7932 * If non-null, the Intent can only match the components in the given
7933 * application package.
7934 *
7935 * @param packageName The name of the application package to handle the
7936 * intent, or null to allow any application package.
7937 *
7938 * @return Returns the same Intent object, for chaining multiple calls
7939 * into a single statement.
7940 *
7941 * @see #getPackage
7942 * @see #resolveActivity
7943 */
7944 public Intent setPackage(String packageName) {
Dianne Hackbornf5b86712011-12-05 17:42:41 -08007945 if (packageName != null && mSelector != null) {
7946 throw new IllegalArgumentException(
7947 "Can't set package name when selector is already set");
7948 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007949 mPackage = packageName;
7950 return this;
7951 }
7952
7953 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007954 * (Usually optional) Explicitly set the component to handle the intent.
7955 * If left with the default value of null, the system will determine the
7956 * appropriate class to use based on the other fields (action, data,
7957 * type, categories) in the Intent. If this class is defined, the
7958 * specified class will always be used regardless of the other fields. You
7959 * should only set this value when you know you absolutely want a specific
7960 * class to be used; otherwise it is better to let the system find the
7961 * appropriate class so that you will respect the installed applications
7962 * and user preferences.
7963 *
7964 * @param component The name of the application component to handle the
7965 * intent, or null to let the system find one for you.
7966 *
7967 * @return Returns the same Intent object, for chaining multiple calls
7968 * into a single statement.
7969 *
7970 * @see #setClass
7971 * @see #setClassName(Context, String)
7972 * @see #setClassName(String, String)
7973 * @see #getComponent
7974 * @see #resolveActivity
7975 */
7976 public Intent setComponent(ComponentName component) {
7977 mComponent = component;
7978 return this;
7979 }
7980
7981 /**
7982 * Convenience for calling {@link #setComponent} with an
7983 * explicit class name.
7984 *
7985 * @param packageContext A Context of the application package implementing
7986 * this class.
7987 * @param className The name of a class inside of the application package
7988 * that will be used as the component for this Intent.
7989 *
7990 * @return Returns the same Intent object, for chaining multiple calls
7991 * into a single statement.
7992 *
7993 * @see #setComponent
7994 * @see #setClass
7995 */
7996 public Intent setClassName(Context packageContext, String className) {
7997 mComponent = new ComponentName(packageContext, className);
7998 return this;
7999 }
8000
8001 /**
8002 * Convenience for calling {@link #setComponent} with an
8003 * explicit application package name and class name.
8004 *
8005 * @param packageName The name of the package implementing the desired
8006 * component.
8007 * @param className The name of a class inside of the application package
8008 * that will be used as the component for this Intent.
8009 *
8010 * @return Returns the same Intent object, for chaining multiple calls
8011 * into a single statement.
8012 *
8013 * @see #setComponent
8014 * @see #setClass
8015 */
8016 public Intent setClassName(String packageName, String className) {
8017 mComponent = new ComponentName(packageName, className);
8018 return this;
8019 }
8020
8021 /**
8022 * Convenience for calling {@link #setComponent(ComponentName)} with the
8023 * name returned by a {@link Class} object.
8024 *
8025 * @param packageContext A Context of the application package implementing
8026 * this class.
8027 * @param cls The class name to set, equivalent to
8028 * <code>setClassName(context, cls.getName())</code>.
8029 *
8030 * @return Returns the same Intent object, for chaining multiple calls
8031 * into a single statement.
8032 *
8033 * @see #setComponent
8034 */
8035 public Intent setClass(Context packageContext, Class<?> cls) {
8036 mComponent = new ComponentName(packageContext, cls);
8037 return this;
8038 }
8039
8040 /**
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08008041 * Set the bounds of the sender of this intent, in screen coordinates. This can be
8042 * used as a hint to the receiver for animations and the like. Null means that there
8043 * is no source bounds.
8044 */
8045 public void setSourceBounds(Rect r) {
8046 if (r != null) {
8047 mSourceBounds = new Rect(r);
8048 } else {
Daniel Lehmanna5b58df2011-10-12 16:24:22 -07008049 mSourceBounds = null;
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08008050 }
8051 }
8052
Tor Norbyed9273d62013-05-30 15:59:53 -07008053 /** @hide */
8054 @IntDef(flag = true,
8055 value = {
8056 FILL_IN_ACTION,
8057 FILL_IN_DATA,
8058 FILL_IN_CATEGORIES,
8059 FILL_IN_COMPONENT,
8060 FILL_IN_PACKAGE,
8061 FILL_IN_SOURCE_BOUNDS,
8062 FILL_IN_SELECTOR,
8063 FILL_IN_CLIP_DATA
8064 })
8065 @Retention(RetentionPolicy.SOURCE)
8066 public @interface FillInFlags {}
8067
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08008068 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008069 * Use with {@link #fillIn} to allow the current action value to be
8070 * overwritten, even if it is already set.
8071 */
8072 public static final int FILL_IN_ACTION = 1<<0;
8073
8074 /**
8075 * Use with {@link #fillIn} to allow the current data or type value
8076 * overwritten, even if it is already set.
8077 */
8078 public static final int FILL_IN_DATA = 1<<1;
8079
8080 /**
8081 * Use with {@link #fillIn} to allow the current categories to be
8082 * overwritten, even if they are already set.
8083 */
8084 public static final int FILL_IN_CATEGORIES = 1<<2;
8085
8086 /**
8087 * Use with {@link #fillIn} to allow the current component value to be
8088 * overwritten, even if it is already set.
8089 */
8090 public static final int FILL_IN_COMPONENT = 1<<3;
8091
8092 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008093 * Use with {@link #fillIn} to allow the current package value to be
8094 * overwritten, even if it is already set.
8095 */
8096 public static final int FILL_IN_PACKAGE = 1<<4;
8097
8098 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008099 * Use with {@link #fillIn} to allow the current bounds rectangle to be
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08008100 * overwritten, even if it is already set.
8101 */
8102 public static final int FILL_IN_SOURCE_BOUNDS = 1<<5;
8103
8104 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008105 * Use with {@link #fillIn} to allow the current selector to be
8106 * overwritten, even if it is already set.
8107 */
8108 public static final int FILL_IN_SELECTOR = 1<<6;
8109
8110 /**
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008111 * Use with {@link #fillIn} to allow the current ClipData to be
8112 * overwritten, even if it is already set.
8113 */
8114 public static final int FILL_IN_CLIP_DATA = 1<<7;
8115
8116 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008117 * Copy the contents of <var>other</var> in to this object, but only
8118 * where fields are not defined by this object. For purposes of a field
8119 * being defined, the following pieces of data in the Intent are
8120 * considered to be separate fields:
8121 *
8122 * <ul>
8123 * <li> action, as set by {@link #setAction}.
Nick Pellyccae4122012-01-09 14:12:58 -08008124 * <li> data Uri and MIME type, as set by {@link #setData(Uri)},
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008125 * {@link #setType(String)}, or {@link #setDataAndType(Uri, String)}.
8126 * <li> categories, as set by {@link #addCategory}.
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008127 * <li> package, as set by {@link #setPackage}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008128 * <li> component, as set by {@link #setComponent(ComponentName)} or
8129 * related methods.
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008130 * <li> source bounds, as set by {@link #setSourceBounds}.
8131 * <li> selector, as set by {@link #setSelector(Intent)}.
8132 * <li> clip data, as set by {@link #setClipData(ClipData)}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008133 * <li> each top-level name in the associated extras.
8134 * </ul>
8135 *
8136 * <p>In addition, you can use the {@link #FILL_IN_ACTION},
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008137 * {@link #FILL_IN_DATA}, {@link #FILL_IN_CATEGORIES}, {@link #FILL_IN_PACKAGE},
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008138 * {@link #FILL_IN_COMPONENT}, {@link #FILL_IN_SOURCE_BOUNDS},
8139 * {@link #FILL_IN_SELECTOR}, and {@link #FILL_IN_CLIP_DATA} to override
8140 * the restriction where the corresponding field will not be replaced if
8141 * it is already set.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008142 *
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008143 * <p>Note: The component field will only be copied if {@link #FILL_IN_COMPONENT}
8144 * is explicitly specified. The selector will only be copied if
8145 * {@link #FILL_IN_SELECTOR} is explicitly specified.
Brett Chabot3e391752009-07-21 16:07:23 -07008146 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008147 * <p>For example, consider Intent A with {data="foo", categories="bar"}
8148 * and Intent B with {action="gotit", data-type="some/thing",
8149 * categories="one","two"}.
8150 *
8151 * <p>Calling A.fillIn(B, Intent.FILL_IN_DATA) will result in A now
8152 * containing: {action="gotit", data-type="some/thing",
8153 * categories="bar"}.
8154 *
8155 * @param other Another Intent whose values are to be used to fill in
8156 * the current one.
8157 * @param flags Options to control which fields can be filled in.
8158 *
8159 * @return Returns a bit mask of {@link #FILL_IN_ACTION},
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008160 * {@link #FILL_IN_DATA}, {@link #FILL_IN_CATEGORIES}, {@link #FILL_IN_PACKAGE},
Tor Norbyed9273d62013-05-30 15:59:53 -07008161 * {@link #FILL_IN_COMPONENT}, {@link #FILL_IN_SOURCE_BOUNDS},
8162 * {@link #FILL_IN_SELECTOR} and {@link #FILL_IN_CLIP_DATA indicating which fields were
8163 * changed.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008164 */
Tor Norbyed9273d62013-05-30 15:59:53 -07008165 @FillInFlags
8166 public int fillIn(Intent other, @FillInFlags int flags) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008167 int changes = 0;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008168 boolean mayHaveCopiedUris = false;
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008169 if (other.mAction != null
8170 && (mAction == null || (flags&FILL_IN_ACTION) != 0)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008171 mAction = other.mAction;
8172 changes |= FILL_IN_ACTION;
8173 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008174 if ((other.mData != null || other.mType != null)
8175 && ((mData == null && mType == null)
8176 || (flags&FILL_IN_DATA) != 0)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008177 mData = other.mData;
8178 mType = other.mType;
8179 changes |= FILL_IN_DATA;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008180 mayHaveCopiedUris = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008181 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008182 if (other.mCategories != null
8183 && (mCategories == null || (flags&FILL_IN_CATEGORIES) != 0)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008184 if (other.mCategories != null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07008185 mCategories = new ArraySet<String>(other.mCategories);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008186 }
8187 changes |= FILL_IN_CATEGORIES;
8188 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008189 if (other.mPackage != null
8190 && (mPackage == null || (flags&FILL_IN_PACKAGE) != 0)) {
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008191 // Only do this if mSelector is not set.
8192 if (mSelector == null) {
8193 mPackage = other.mPackage;
8194 changes |= FILL_IN_PACKAGE;
8195 }
8196 }
8197 // Selector is special: it can only be set if explicitly allowed,
8198 // for the same reason as the component name.
8199 if (other.mSelector != null && (flags&FILL_IN_SELECTOR) != 0) {
8200 if (mPackage == null) {
8201 mSelector = new Intent(other.mSelector);
8202 mPackage = null;
8203 changes |= FILL_IN_SELECTOR;
8204 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008205 }
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008206 if (other.mClipData != null
8207 && (mClipData == null || (flags&FILL_IN_CLIP_DATA) != 0)) {
8208 mClipData = other.mClipData;
8209 changes |= FILL_IN_CLIP_DATA;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008210 mayHaveCopiedUris = true;
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008211 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008212 // Component is special: it can -only- be set if explicitly allowed,
8213 // since otherwise the sender could force the intent somewhere the
8214 // originator didn't intend.
8215 if (other.mComponent != null && (flags&FILL_IN_COMPONENT) != 0) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008216 mComponent = other.mComponent;
8217 changes |= FILL_IN_COMPONENT;
8218 }
8219 mFlags |= other.mFlags;
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08008220 if (other.mSourceBounds != null
8221 && (mSourceBounds == null || (flags&FILL_IN_SOURCE_BOUNDS) != 0)) {
8222 mSourceBounds = new Rect(other.mSourceBounds);
8223 changes |= FILL_IN_SOURCE_BOUNDS;
8224 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008225 if (mExtras == null) {
8226 if (other.mExtras != null) {
8227 mExtras = new Bundle(other.mExtras);
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008228 mayHaveCopiedUris = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008229 }
8230 } else if (other.mExtras != null) {
8231 try {
8232 Bundle newb = new Bundle(other.mExtras);
8233 newb.putAll(mExtras);
8234 mExtras = newb;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008235 mayHaveCopiedUris = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008236 } catch (RuntimeException e) {
8237 // Modifying the extras can cause us to unparcel the contents
8238 // of the bundle, and if we do this in the system process that
8239 // may fail. We really should handle this (i.e., the Bundle
8240 // impl shouldn't be on top of a plain map), but for now just
8241 // ignore it and keep the original contents. :(
8242 Log.w("Intent", "Failure filling in extras", e);
8243 }
8244 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008245 if (mayHaveCopiedUris && mContentUserHint == UserHandle.USER_CURRENT
8246 && other.mContentUserHint != UserHandle.USER_CURRENT) {
8247 mContentUserHint = other.mContentUserHint;
8248 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008249 return changes;
8250 }
8251
8252 /**
8253 * Wrapper class holding an Intent and implementing comparisons on it for
8254 * the purpose of filtering. The class implements its
8255 * {@link #equals equals()} and {@link #hashCode hashCode()} methods as
8256 * simple calls to {@link Intent#filterEquals(Intent)} filterEquals()} and
8257 * {@link android.content.Intent#filterHashCode()} filterHashCode()}
8258 * on the wrapped Intent.
8259 */
8260 public static final class FilterComparison {
8261 private final Intent mIntent;
8262 private final int mHashCode;
8263
8264 public FilterComparison(Intent intent) {
8265 mIntent = intent;
8266 mHashCode = intent.filterHashCode();
8267 }
8268
8269 /**
8270 * Return the Intent that this FilterComparison represents.
8271 * @return Returns the Intent held by the FilterComparison. Do
8272 * not modify!
8273 */
8274 public Intent getIntent() {
8275 return mIntent;
8276 }
8277
8278 @Override
8279 public boolean equals(Object obj) {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08008280 if (obj instanceof FilterComparison) {
8281 Intent other = ((FilterComparison)obj).mIntent;
8282 return mIntent.filterEquals(other);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008283 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08008284 return false;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008285 }
8286
8287 @Override
8288 public int hashCode() {
8289 return mHashCode;
8290 }
8291 }
8292
8293 /**
8294 * Determine if two intents are the same for the purposes of intent
8295 * resolution (filtering). That is, if their action, data, type,
8296 * class, and categories are the same. This does <em>not</em> compare
8297 * any extra data included in the intents.
8298 *
8299 * @param other The other Intent to compare against.
8300 *
8301 * @return Returns true if action, data, type, class, and categories
8302 * are the same.
8303 */
8304 public boolean filterEquals(Intent other) {
8305 if (other == null) {
8306 return false;
8307 }
Christopher Tate63d9ae12014-06-19 19:07:26 -07008308 if (!Objects.equals(this.mAction, other.mAction)) return false;
8309 if (!Objects.equals(this.mData, other.mData)) return false;
8310 if (!Objects.equals(this.mType, other.mType)) return false;
8311 if (!Objects.equals(this.mPackage, other.mPackage)) return false;
8312 if (!Objects.equals(this.mComponent, other.mComponent)) return false;
8313 if (!Objects.equals(this.mCategories, other.mCategories)) return false;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008314
8315 return true;
8316 }
8317
8318 /**
8319 * Generate hash code that matches semantics of filterEquals().
8320 *
8321 * @return Returns the hash value of the action, data, type, class, and
8322 * categories.
8323 *
8324 * @see #filterEquals
8325 */
8326 public int filterHashCode() {
8327 int code = 0;
8328 if (mAction != null) {
8329 code += mAction.hashCode();
8330 }
8331 if (mData != null) {
8332 code += mData.hashCode();
8333 }
8334 if (mType != null) {
8335 code += mType.hashCode();
8336 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008337 if (mPackage != null) {
8338 code += mPackage.hashCode();
8339 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008340 if (mComponent != null) {
8341 code += mComponent.hashCode();
8342 }
8343 if (mCategories != null) {
8344 code += mCategories.hashCode();
8345 }
8346 return code;
8347 }
8348
8349 @Override
8350 public String toString() {
Dianne Hackborn90c52de2011-09-23 12:57:44 -07008351 StringBuilder b = new StringBuilder(128);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008352
Dianne Hackborn1d442e02009-04-20 18:14:05 -07008353 b.append("Intent { ");
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008354 toShortString(b, true, true, true, false);
Dianne Hackborn1d442e02009-04-20 18:14:05 -07008355 b.append(" }");
8356
8357 return b.toString();
8358 }
8359
8360 /** @hide */
Dianne Hackborn90c52de2011-09-23 12:57:44 -07008361 public String toInsecureString() {
8362 StringBuilder b = new StringBuilder(128);
8363
8364 b.append("Intent { ");
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008365 toShortString(b, false, true, true, false);
Dianne Hackborn90c52de2011-09-23 12:57:44 -07008366 b.append(" }");
8367
Dianne Hackborn1d442e02009-04-20 18:14:05 -07008368 return b.toString();
8369 }
Romain Guy4969af72009-06-17 10:53:19 -07008370
Dianne Hackborn1d442e02009-04-20 18:14:05 -07008371 /** @hide */
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008372 public String toInsecureStringWithClip() {
Dianne Hackborn90c52de2011-09-23 12:57:44 -07008373 StringBuilder b = new StringBuilder(128);
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008374
8375 b.append("Intent { ");
8376 toShortString(b, false, true, true, true);
8377 b.append(" }");
8378
Dianne Hackborn90c52de2011-09-23 12:57:44 -07008379 return b.toString();
8380 }
8381
8382 /** @hide */
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008383 public String toShortString(boolean secure, boolean comp, boolean extras, boolean clip) {
8384 StringBuilder b = new StringBuilder(128);
8385 toShortString(b, secure, comp, extras, clip);
8386 return b.toString();
8387 }
8388
8389 /** @hide */
8390 public void toShortString(StringBuilder b, boolean secure, boolean comp, boolean extras,
8391 boolean clip) {
Dianne Hackborn1d442e02009-04-20 18:14:05 -07008392 boolean first = true;
8393 if (mAction != null) {
8394 b.append("act=").append(mAction);
8395 first = false;
8396 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008397 if (mCategories != null) {
Dianne Hackborn1d442e02009-04-20 18:14:05 -07008398 if (!first) {
8399 b.append(' ');
8400 }
8401 first = false;
8402 b.append("cat=[");
Dianne Hackbornadd005c2013-07-17 18:43:12 -07008403 for (int i=0; i<mCategories.size(); i++) {
8404 if (i > 0) b.append(',');
8405 b.append(mCategories.valueAt(i));
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008406 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07008407 b.append("]");
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008408 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07008409 if (mData != null) {
8410 if (!first) {
8411 b.append(' ');
8412 }
8413 first = false;
Wink Savillea4288072010-10-12 12:36:38 -07008414 b.append("dat=");
Dianne Hackborn90c52de2011-09-23 12:57:44 -07008415 if (secure) {
8416 b.append(mData.toSafeString());
Wink Savillea4288072010-10-12 12:36:38 -07008417 } else {
8418 b.append(mData);
8419 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07008420 }
8421 if (mType != null) {
8422 if (!first) {
8423 b.append(' ');
8424 }
8425 first = false;
8426 b.append("typ=").append(mType);
8427 }
8428 if (mFlags != 0) {
8429 if (!first) {
8430 b.append(' ');
8431 }
8432 first = false;
8433 b.append("flg=0x").append(Integer.toHexString(mFlags));
8434 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008435 if (mPackage != null) {
8436 if (!first) {
8437 b.append(' ');
8438 }
8439 first = false;
8440 b.append("pkg=").append(mPackage);
8441 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07008442 if (comp && mComponent != null) {
8443 if (!first) {
8444 b.append(' ');
8445 }
8446 first = false;
8447 b.append("cmp=").append(mComponent.flattenToShortString());
8448 }
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08008449 if (mSourceBounds != null) {
8450 if (!first) {
8451 b.append(' ');
8452 }
8453 first = false;
8454 b.append("bnds=").append(mSourceBounds.toShortString());
8455 }
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008456 if (mClipData != null) {
8457 if (!first) {
8458 b.append(' ');
8459 }
Dianne Hackbornae498722015-08-14 13:29:47 -07008460 b.append("clip={");
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008461 if (clip) {
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008462 mClipData.toShortString(b);
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008463 } else {
Dianne Hackbornae498722015-08-14 13:29:47 -07008464 if (mClipData.getDescription() != null) {
8465 first = !mClipData.getDescription().toShortStringTypesOnly(b);
8466 } else {
8467 first = true;
8468 }
8469 mClipData.toShortStringShortItems(b, first);
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008470 }
Dianne Hackbornae498722015-08-14 13:29:47 -07008471 first = false;
8472 b.append('}');
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008473 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07008474 if (extras && mExtras != null) {
8475 if (!first) {
8476 b.append(' ');
8477 }
8478 first = false;
8479 b.append("(has extras)");
8480 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008481 if (mContentUserHint != UserHandle.USER_CURRENT) {
8482 if (!first) {
8483 b.append(' ');
8484 }
8485 first = false;
8486 b.append("u=").append(mContentUserHint);
8487 }
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008488 if (mSelector != null) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008489 b.append(" sel=");
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008490 mSelector.toShortString(b, secure, comp, extras, clip);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008491 b.append("}");
8492 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008493 }
8494
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008495 /**
8496 * Call {@link #toUri} with 0 flags.
8497 * @deprecated Use {@link #toUri} instead.
8498 */
8499 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008500 public String toURI() {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008501 return toUri(0);
8502 }
8503
8504 /**
8505 * Convert this Intent into a String holding a URI representation of it.
8506 * The returned URI string has been properly URI encoded, so it can be
8507 * used with {@link Uri#parse Uri.parse(String)}. The URI contains the
8508 * Intent's data as the base URI, with an additional fragment describing
8509 * the action, categories, type, flags, package, component, and extras.
Tom Taylord4a47292009-12-21 13:59:18 -08008510 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008511 * <p>You can convert the returned string back to an Intent with
8512 * {@link #getIntent}.
Tom Taylord4a47292009-12-21 13:59:18 -08008513 *
Dianne Hackborn85d558c2014-11-04 10:31:54 -08008514 * @param flags Additional operating flags. Either 0,
8515 * {@link #URI_INTENT_SCHEME}, or {@link #URI_ANDROID_APP_SCHEME}.
Tom Taylord4a47292009-12-21 13:59:18 -08008516 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008517 * @return Returns a URI encoding URI string describing the entire contents
8518 * of the Intent.
8519 */
8520 public String toUri(int flags) {
Dianne Hackborn1d442e02009-04-20 18:14:05 -07008521 StringBuilder uri = new StringBuilder(128);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08008522 if ((flags&URI_ANDROID_APP_SCHEME) != 0) {
8523 if (mPackage == null) {
8524 throw new IllegalArgumentException(
8525 "Intent must include an explicit package name to build an android-app: "
8526 + this);
8527 }
8528 uri.append("android-app://");
8529 uri.append(mPackage);
8530 String scheme = null;
8531 if (mData != null) {
8532 scheme = mData.getScheme();
8533 if (scheme != null) {
8534 uri.append('/');
8535 uri.append(scheme);
8536 String authority = mData.getEncodedAuthority();
8537 if (authority != null) {
8538 uri.append('/');
8539 uri.append(authority);
8540 String path = mData.getEncodedPath();
8541 if (path != null) {
8542 uri.append(path);
8543 }
8544 String queryParams = mData.getEncodedQuery();
8545 if (queryParams != null) {
8546 uri.append('?');
8547 uri.append(queryParams);
8548 }
8549 String fragment = mData.getEncodedFragment();
8550 if (fragment != null) {
8551 uri.append('#');
8552 uri.append(fragment);
8553 }
8554 }
8555 }
8556 }
8557 toUriFragment(uri, null, scheme == null ? Intent.ACTION_MAIN : Intent.ACTION_VIEW,
8558 mPackage, flags);
8559 return uri.toString();
8560 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008561 String scheme = null;
8562 if (mData != null) {
8563 String data = mData.toString();
8564 if ((flags&URI_INTENT_SCHEME) != 0) {
8565 final int N = data.length();
8566 for (int i=0; i<N; i++) {
8567 char c = data.charAt(i);
8568 if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')
8569 || c == '.' || c == '-') {
8570 continue;
8571 }
8572 if (c == ':' && i > 0) {
8573 // Valid scheme.
8574 scheme = data.substring(0, i);
8575 uri.append("intent:");
8576 data = data.substring(i+1);
8577 break;
8578 }
Tom Taylord4a47292009-12-21 13:59:18 -08008579
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008580 // No scheme.
8581 break;
8582 }
8583 }
8584 uri.append(data);
Tom Taylord4a47292009-12-21 13:59:18 -08008585
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008586 } else if ((flags&URI_INTENT_SCHEME) != 0) {
8587 uri.append("intent:");
8588 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008589
Dianne Hackborn85d558c2014-11-04 10:31:54 -08008590 toUriFragment(uri, scheme, Intent.ACTION_VIEW, null, flags);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008591
Dianne Hackborn85d558c2014-11-04 10:31:54 -08008592 return uri.toString();
8593 }
8594
8595 private void toUriFragment(StringBuilder uri, String scheme, String defAction,
8596 String defPackage, int flags) {
8597 StringBuilder frag = new StringBuilder(128);
8598
8599 toUriInner(frag, scheme, defAction, defPackage, flags);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008600 if (mSelector != null) {
Dianne Hackborn80b1c562014-12-09 20:22:08 -08008601 frag.append("SEL;");
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008602 // Note that for now we are not going to try to handle the
8603 // data part; not clear how to represent this as a URI, and
8604 // not much utility in it.
Dianne Hackborn85d558c2014-11-04 10:31:54 -08008605 mSelector.toUriInner(frag, mSelector.mData != null ? mSelector.mData.getScheme() : null,
8606 null, null, flags);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008607 }
8608
Dianne Hackborn85d558c2014-11-04 10:31:54 -08008609 if (frag.length() > 0) {
8610 uri.append("#Intent;");
8611 uri.append(frag);
8612 uri.append("end");
8613 }
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008614 }
8615
Dianne Hackborn85d558c2014-11-04 10:31:54 -08008616 private void toUriInner(StringBuilder uri, String scheme, String defAction,
8617 String defPackage, int flags) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008618 if (scheme != null) {
8619 uri.append("scheme=").append(scheme).append(';');
8620 }
Dianne Hackborn85d558c2014-11-04 10:31:54 -08008621 if (mAction != null && !mAction.equals(defAction)) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008622 uri.append("action=").append(Uri.encode(mAction)).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008623 }
8624 if (mCategories != null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07008625 for (int i=0; i<mCategories.size(); i++) {
8626 uri.append("category=").append(Uri.encode(mCategories.valueAt(i))).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008627 }
8628 }
8629 if (mType != null) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008630 uri.append("type=").append(Uri.encode(mType, "/")).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008631 }
8632 if (mFlags != 0) {
8633 uri.append("launchFlags=0x").append(Integer.toHexString(mFlags)).append(';');
8634 }
Dianne Hackborn85d558c2014-11-04 10:31:54 -08008635 if (mPackage != null && !mPackage.equals(defPackage)) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008636 uri.append("package=").append(Uri.encode(mPackage)).append(';');
8637 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008638 if (mComponent != null) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008639 uri.append("component=").append(Uri.encode(
8640 mComponent.flattenToShortString(), "/")).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008641 }
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08008642 if (mSourceBounds != null) {
8643 uri.append("sourceBounds=")
8644 .append(Uri.encode(mSourceBounds.flattenToString()))
8645 .append(';');
8646 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008647 if (mExtras != null) {
8648 for (String key : mExtras.keySet()) {
8649 final Object value = mExtras.get(key);
8650 char entryType =
8651 value instanceof String ? 'S' :
8652 value instanceof Boolean ? 'B' :
8653 value instanceof Byte ? 'b' :
8654 value instanceof Character ? 'c' :
8655 value instanceof Double ? 'd' :
8656 value instanceof Float ? 'f' :
8657 value instanceof Integer ? 'i' :
8658 value instanceof Long ? 'l' :
8659 value instanceof Short ? 's' :
8660 '\0';
8661
8662 if (entryType != '\0') {
8663 uri.append(entryType);
8664 uri.append('.');
8665 uri.append(Uri.encode(key));
8666 uri.append('=');
8667 uri.append(Uri.encode(value.toString()));
8668 uri.append(';');
8669 }
8670 }
8671 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008672 }
The Android Open Source Project10592532009-03-18 17:39:46 -07008673
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008674 public int describeContents() {
8675 return (mExtras != null) ? mExtras.describeContents() : 0;
8676 }
8677
8678 public void writeToParcel(Parcel out, int flags) {
8679 out.writeString(mAction);
8680 Uri.writeToParcel(out, mData);
8681 out.writeString(mType);
8682 out.writeInt(mFlags);
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008683 out.writeString(mPackage);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008684 ComponentName.writeToParcel(mComponent, out);
8685
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08008686 if (mSourceBounds != null) {
8687 out.writeInt(1);
8688 mSourceBounds.writeToParcel(out, flags);
8689 } else {
8690 out.writeInt(0);
8691 }
8692
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008693 if (mCategories != null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07008694 final int N = mCategories.size();
8695 out.writeInt(N);
8696 for (int i=0; i<N; i++) {
8697 out.writeString(mCategories.valueAt(i));
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008698 }
8699 } else {
8700 out.writeInt(0);
8701 }
8702
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008703 if (mSelector != null) {
8704 out.writeInt(1);
8705 mSelector.writeToParcel(out, flags);
8706 } else {
8707 out.writeInt(0);
8708 }
8709
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008710 if (mClipData != null) {
8711 out.writeInt(1);
8712 mClipData.writeToParcel(out, flags);
8713 } else {
8714 out.writeInt(0);
8715 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008716 out.writeInt(mContentUserHint);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008717 out.writeBundle(mExtras);
8718 }
8719
8720 public static final Parcelable.Creator<Intent> CREATOR
8721 = new Parcelable.Creator<Intent>() {
8722 public Intent createFromParcel(Parcel in) {
8723 return new Intent(in);
8724 }
8725 public Intent[] newArray(int size) {
8726 return new Intent[size];
8727 }
8728 };
8729
Dianne Hackborneb034652009-09-07 00:49:58 -07008730 /** @hide */
8731 protected Intent(Parcel in) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008732 readFromParcel(in);
8733 }
8734
8735 public void readFromParcel(Parcel in) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08008736 setAction(in.readString());
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008737 mData = Uri.CREATOR.createFromParcel(in);
8738 mType = in.readString();
8739 mFlags = in.readInt();
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008740 mPackage = in.readString();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008741 mComponent = ComponentName.readFromParcel(in);
8742
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08008743 if (in.readInt() != 0) {
8744 mSourceBounds = Rect.CREATOR.createFromParcel(in);
8745 }
8746
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008747 int N = in.readInt();
8748 if (N > 0) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07008749 mCategories = new ArraySet<String>();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008750 int i;
8751 for (i=0; i<N; i++) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08008752 mCategories.add(in.readString().intern());
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008753 }
8754 } else {
8755 mCategories = null;
8756 }
8757
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008758 if (in.readInt() != 0) {
8759 mSelector = new Intent(in);
8760 }
8761
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008762 if (in.readInt() != 0) {
8763 mClipData = new ClipData(in);
8764 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008765 mContentUserHint = in.readInt();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008766 mExtras = in.readBundle();
8767 }
8768
8769 /**
8770 * Parses the "intent" element (and its children) from XML and instantiates
8771 * an Intent object. The given XML parser should be located at the tag
8772 * where parsing should start (often named "intent"), from which the
8773 * basic action, data, type, and package and class name will be
8774 * retrieved. The function will then parse in to any child elements,
8775 * looking for <category android:name="xxx"> tags to add categories and
8776 * <extra android:name="xxx" android:value="yyy"> to attach extra data
8777 * to the intent.
8778 *
8779 * @param resources The Resources to use when inflating resources.
8780 * @param parser The XML parser pointing at an "intent" tag.
8781 * @param attrs The AttributeSet interface for retrieving extended
8782 * attribute data at the current <var>parser</var> location.
8783 * @return An Intent object matching the XML data.
8784 * @throws XmlPullParserException If there was an XML parsing error.
8785 * @throws IOException If there was an I/O error.
8786 */
8787 public static Intent parseIntent(Resources resources, XmlPullParser parser, AttributeSet attrs)
8788 throws XmlPullParserException, IOException {
8789 Intent intent = new Intent();
8790
8791 TypedArray sa = resources.obtainAttributes(attrs,
8792 com.android.internal.R.styleable.Intent);
8793
8794 intent.setAction(sa.getString(com.android.internal.R.styleable.Intent_action));
8795
8796 String data = sa.getString(com.android.internal.R.styleable.Intent_data);
8797 String mimeType = sa.getString(com.android.internal.R.styleable.Intent_mimeType);
8798 intent.setDataAndType(data != null ? Uri.parse(data) : null, mimeType);
8799
8800 String packageName = sa.getString(com.android.internal.R.styleable.Intent_targetPackage);
8801 String className = sa.getString(com.android.internal.R.styleable.Intent_targetClass);
8802 if (packageName != null && className != null) {
8803 intent.setComponent(new ComponentName(packageName, className));
8804 }
8805
8806 sa.recycle();
8807
8808 int outerDepth = parser.getDepth();
8809 int type;
8810 while ((type=parser.next()) != XmlPullParser.END_DOCUMENT
8811 && (type != XmlPullParser.END_TAG || parser.getDepth() > outerDepth)) {
8812 if (type == XmlPullParser.END_TAG || type == XmlPullParser.TEXT) {
8813 continue;
8814 }
8815
8816 String nodeName = parser.getName();
Craig Mautner21d24a22014-04-23 11:45:37 -07008817 if (nodeName.equals(TAG_CATEGORIES)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008818 sa = resources.obtainAttributes(attrs,
8819 com.android.internal.R.styleable.IntentCategory);
8820 String cat = sa.getString(com.android.internal.R.styleable.IntentCategory_name);
8821 sa.recycle();
8822
8823 if (cat != null) {
8824 intent.addCategory(cat);
8825 }
8826 XmlUtils.skipCurrentTag(parser);
8827
Craig Mautner21d24a22014-04-23 11:45:37 -07008828 } else if (nodeName.equals(TAG_EXTRA)) {
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08008829 if (intent.mExtras == null) {
8830 intent.mExtras = new Bundle();
8831 }
Craig Mautner21d24a22014-04-23 11:45:37 -07008832 resources.parseBundleExtra(TAG_EXTRA, attrs, intent.mExtras);
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08008833 XmlUtils.skipCurrentTag(parser);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008834
8835 } else {
8836 XmlUtils.skipCurrentTag(parser);
8837 }
8838 }
8839
8840 return intent;
8841 }
Nick Pellyccae4122012-01-09 14:12:58 -08008842
Craig Mautner21d24a22014-04-23 11:45:37 -07008843 /** @hide */
8844 public void saveToXml(XmlSerializer out) throws IOException {
8845 if (mAction != null) {
8846 out.attribute(null, ATTR_ACTION, mAction);
8847 }
8848 if (mData != null) {
8849 out.attribute(null, ATTR_DATA, mData.toString());
8850 }
8851 if (mType != null) {
8852 out.attribute(null, ATTR_TYPE, mType);
8853 }
8854 if (mComponent != null) {
8855 out.attribute(null, ATTR_COMPONENT, mComponent.flattenToShortString());
8856 }
8857 out.attribute(null, ATTR_FLAGS, Integer.toHexString(getFlags()));
8858
8859 if (mCategories != null) {
8860 out.startTag(null, TAG_CATEGORIES);
8861 for (int categoryNdx = mCategories.size() - 1; categoryNdx >= 0; --categoryNdx) {
8862 out.attribute(null, ATTR_CATEGORY, mCategories.valueAt(categoryNdx));
8863 }
Craig Mautner43e52ed2014-06-16 17:18:52 -07008864 out.endTag(null, TAG_CATEGORIES);
Craig Mautner21d24a22014-04-23 11:45:37 -07008865 }
8866 }
8867
8868 /** @hide */
8869 public static Intent restoreFromXml(XmlPullParser in) throws IOException,
8870 XmlPullParserException {
8871 Intent intent = new Intent();
8872 final int outerDepth = in.getDepth();
8873
8874 int attrCount = in.getAttributeCount();
8875 for (int attrNdx = attrCount - 1; attrNdx >= 0; --attrNdx) {
8876 final String attrName = in.getAttributeName(attrNdx);
8877 final String attrValue = in.getAttributeValue(attrNdx);
8878 if (ATTR_ACTION.equals(attrName)) {
8879 intent.setAction(attrValue);
8880 } else if (ATTR_DATA.equals(attrName)) {
8881 intent.setData(Uri.parse(attrValue));
8882 } else if (ATTR_TYPE.equals(attrName)) {
8883 intent.setType(attrValue);
8884 } else if (ATTR_COMPONENT.equals(attrName)) {
8885 intent.setComponent(ComponentName.unflattenFromString(attrValue));
8886 } else if (ATTR_FLAGS.equals(attrName)) {
8887 intent.setFlags(Integer.valueOf(attrValue, 16));
8888 } else {
8889 Log.e("Intent", "restoreFromXml: unknown attribute=" + attrName);
8890 }
8891 }
8892
8893 int event;
8894 String name;
8895 while (((event = in.next()) != XmlPullParser.END_DOCUMENT) &&
8896 (event != XmlPullParser.END_TAG || in.getDepth() < outerDepth)) {
8897 if (event == XmlPullParser.START_TAG) {
8898 name = in.getName();
8899 if (TAG_CATEGORIES.equals(name)) {
8900 attrCount = in.getAttributeCount();
8901 for (int attrNdx = attrCount - 1; attrNdx >= 0; --attrNdx) {
8902 intent.addCategory(in.getAttributeValue(attrNdx));
8903 }
8904 } else {
8905 Log.w("Intent", "restoreFromXml: unknown name=" + name);
8906 XmlUtils.skipCurrentTag(in);
8907 }
8908 }
8909 }
8910
8911 return intent;
8912 }
8913
Nick Pellyccae4122012-01-09 14:12:58 -08008914 /**
8915 * Normalize a MIME data type.
8916 *
8917 * <p>A normalized MIME type has white-space trimmed,
8918 * content-type parameters removed, and is lower-case.
8919 * This aligns the type with Android best practices for
8920 * intent filtering.
8921 *
8922 * <p>For example, "text/plain; charset=utf-8" becomes "text/plain".
8923 * "text/x-vCard" becomes "text/x-vcard".
8924 *
8925 * <p>All MIME types received from outside Android (such as user input,
8926 * or external sources like Bluetooth, NFC, or the Internet) should
8927 * be normalized before they are used to create an Intent.
8928 *
8929 * @param type MIME data type to normalize
8930 * @return normalized MIME data type, or null if the input was null
John Spurlock125d1332013-11-25 11:58:37 -05008931 * @see #setType
8932 * @see #setTypeAndNormalize
Nick Pellyccae4122012-01-09 14:12:58 -08008933 */
8934 public static String normalizeMimeType(String type) {
8935 if (type == null) {
8936 return null;
8937 }
8938
Elliott Hughescb64d432013-08-02 10:00:44 -07008939 type = type.trim().toLowerCase(Locale.ROOT);
Nick Pellyccae4122012-01-09 14:12:58 -08008940
8941 final int semicolonIndex = type.indexOf(';');
8942 if (semicolonIndex != -1) {
8943 type = type.substring(0, semicolonIndex);
8944 }
8945 return type;
8946 }
Jeff Sharkey678d04f2012-03-23 15:41:58 -07008947
8948 /**
Jeff Sharkeya14acd22013-04-02 18:27:45 -07008949 * Prepare this {@link Intent} to leave an app process.
8950 *
8951 * @hide
8952 */
Jeff Sharkey344744b2016-01-28 19:03:30 -07008953 public void prepareToLeaveProcess(Context context) {
8954 final boolean leavingPackage = (mComponent == null)
8955 || !Objects.equals(mComponent.getPackageName(), context.getPackageName());
8956 prepareToLeaveProcess(leavingPackage);
8957 }
8958
8959 /**
8960 * Prepare this {@link Intent} to leave an app process.
8961 *
8962 * @hide
8963 */
8964 public void prepareToLeaveProcess(boolean leavingPackage) {
Jeff Sharkeya14acd22013-04-02 18:27:45 -07008965 setAllowFds(false);
8966
8967 if (mSelector != null) {
Jeff Sharkey344744b2016-01-28 19:03:30 -07008968 mSelector.prepareToLeaveProcess(leavingPackage);
Jeff Sharkeya14acd22013-04-02 18:27:45 -07008969 }
8970 if (mClipData != null) {
Jeff Sharkey344744b2016-01-28 19:03:30 -07008971 mClipData.prepareToLeaveProcess(leavingPackage);
Jeff Sharkeya14acd22013-04-02 18:27:45 -07008972 }
8973
Jeff Sharkeya8b42782016-01-30 17:58:09 -07008974 if (mAction != null && mData != null && StrictMode.vmFileUriExposureEnabled()
8975 && leavingPackage) {
Jeff Sharkey344744b2016-01-28 19:03:30 -07008976 switch (mAction) {
8977 case ACTION_MEDIA_REMOVED:
8978 case ACTION_MEDIA_UNMOUNTED:
8979 case ACTION_MEDIA_CHECKING:
8980 case ACTION_MEDIA_NOFS:
8981 case ACTION_MEDIA_MOUNTED:
8982 case ACTION_MEDIA_SHARED:
8983 case ACTION_MEDIA_UNSHARED:
8984 case ACTION_MEDIA_BAD_REMOVAL:
8985 case ACTION_MEDIA_UNMOUNTABLE:
8986 case ACTION_MEDIA_EJECT:
8987 case ACTION_MEDIA_SCANNER_STARTED:
8988 case ACTION_MEDIA_SCANNER_FINISHED:
8989 case ACTION_MEDIA_SCANNER_SCAN_FILE:
Jeff Sharkey37355a92016-02-05 16:19:10 -07008990 case ACTION_PACKAGE_NEEDS_VERIFICATION:
8991 case ACTION_PACKAGE_VERIFIED:
Jeff Sharkey344744b2016-01-28 19:03:30 -07008992 // Ignore legacy actions
8993 break;
8994 default:
8995 mData.checkFileUriExposed("Intent.getData()");
Jeff Sharkeya14acd22013-04-02 18:27:45 -07008996 }
8997 }
8998 }
8999
9000 /**
Nicolas Prevotd85fc722014-04-16 19:52:08 +01009001 * @hide
9002 */
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009003 public void prepareToEnterProcess() {
Jeff Sharkeyd136e512016-03-09 22:30:56 -07009004 // We just entered destination process, so we should be able to read all
9005 // parcelables inside.
9006 setDefusable(true);
9007
9008 if (mSelector != null) {
9009 mSelector.prepareToEnterProcess();
9010 }
9011 if (mClipData != null) {
9012 mClipData.prepareToEnterProcess();
9013 }
9014
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009015 if (mContentUserHint != UserHandle.USER_CURRENT) {
Nicolas Prevotc4fc00a2014-10-31 12:01:32 +00009016 if (UserHandle.getAppId(Process.myUid()) != Process.SYSTEM_UID) {
9017 fixUris(mContentUserHint);
9018 mContentUserHint = UserHandle.USER_CURRENT;
9019 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009020 }
9021 }
9022
9023 /**
9024 * @hide
9025 */
9026 public void fixUris(int contentUserHint) {
Nicolas Prevotd85fc722014-04-16 19:52:08 +01009027 Uri data = getData();
9028 if (data != null) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009029 mData = maybeAddUserId(data, contentUserHint);
Nicolas Prevotd85fc722014-04-16 19:52:08 +01009030 }
9031 if (mClipData != null) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009032 mClipData.fixUris(contentUserHint);
Nicolas Prevotd85fc722014-04-16 19:52:08 +01009033 }
9034 String action = getAction();
9035 if (ACTION_SEND.equals(action)) {
9036 final Uri stream = getParcelableExtra(EXTRA_STREAM);
9037 if (stream != null) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009038 putExtra(EXTRA_STREAM, maybeAddUserId(stream, contentUserHint));
Nicolas Prevotd85fc722014-04-16 19:52:08 +01009039 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009040 } else if (ACTION_SEND_MULTIPLE.equals(action)) {
Nicolas Prevotd85fc722014-04-16 19:52:08 +01009041 final ArrayList<Uri> streams = getParcelableArrayListExtra(EXTRA_STREAM);
9042 if (streams != null) {
9043 ArrayList<Uri> newStreams = new ArrayList<Uri>();
9044 for (int i = 0; i < streams.size(); i++) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009045 newStreams.add(maybeAddUserId(streams.get(i), contentUserHint));
Nicolas Prevotd85fc722014-04-16 19:52:08 +01009046 }
9047 putParcelableArrayListExtra(EXTRA_STREAM, newStreams);
9048 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009049 } else if (MediaStore.ACTION_IMAGE_CAPTURE.equals(action)
9050 || MediaStore.ACTION_IMAGE_CAPTURE_SECURE.equals(action)
9051 || MediaStore.ACTION_VIDEO_CAPTURE.equals(action)) {
9052 final Uri output = getParcelableExtra(MediaStore.EXTRA_OUTPUT);
9053 if (output != null) {
9054 putExtra(MediaStore.EXTRA_OUTPUT, maybeAddUserId(output, contentUserHint));
9055 }
Nicolas Prevotd85fc722014-04-16 19:52:08 +01009056 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009057 }
Nicolas Prevotd85fc722014-04-16 19:52:08 +01009058
9059 /**
Jeff Sharkey678d04f2012-03-23 15:41:58 -07009060 * Migrate any {@link #EXTRA_STREAM} in {@link #ACTION_SEND} and
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009061 * {@link #ACTION_SEND_MULTIPLE} to {@link ClipData}. Also inspects nested
9062 * intents in {@link #ACTION_CHOOSER}.
Jeff Sharkey678d04f2012-03-23 15:41:58 -07009063 *
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009064 * @return Whether any contents were migrated.
Jeff Sharkey678d04f2012-03-23 15:41:58 -07009065 * @hide
9066 */
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009067 public boolean migrateExtraStreamToClipData() {
Jeff Sharkey678d04f2012-03-23 15:41:58 -07009068 // Refuse to touch if extras already parcelled
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009069 if (mExtras != null && mExtras.isParcelled()) return false;
Jeff Sharkey678d04f2012-03-23 15:41:58 -07009070
9071 // Bail when someone already gave us ClipData
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009072 if (getClipData() != null) return false;
Jeff Sharkey678d04f2012-03-23 15:41:58 -07009073
9074 final String action = getAction();
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009075 if (ACTION_CHOOSER.equals(action)) {
Jeff Sharkeyc004eef2014-09-23 16:40:50 -07009076 // Inspect contained intents to see if we need to migrate extras. We
9077 // don't promote ClipData to the parent, since ChooserActivity will
9078 // already start the picked item as the caller, and we can't combine
9079 // the flags in a safe way.
9080
9081 boolean migrated = false;
Jeff Sharkey1c297002012-05-18 13:55:47 -07009082 try {
Jeff Sharkeyc004eef2014-09-23 16:40:50 -07009083 final Intent intent = getParcelableExtra(EXTRA_INTENT);
9084 if (intent != null) {
9085 migrated |= intent.migrateExtraStreamToClipData();
Jeff Sharkey1c297002012-05-18 13:55:47 -07009086 }
9087 } catch (ClassCastException e) {
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009088 }
Jeff Sharkeyc004eef2014-09-23 16:40:50 -07009089 try {
9090 final Parcelable[] intents = getParcelableArrayExtra(EXTRA_INITIAL_INTENTS);
9091 if (intents != null) {
9092 for (int i = 0; i < intents.length; i++) {
9093 final Intent intent = (Intent) intents[i];
9094 if (intent != null) {
9095 migrated |= intent.migrateExtraStreamToClipData();
9096 }
9097 }
9098 }
9099 } catch (ClassCastException e) {
9100 }
9101 return migrated;
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009102
9103 } else if (ACTION_SEND.equals(action)) {
Jeff Sharkeyf27ea662012-03-27 10:34:24 -07009104 try {
Jeff Sharkeydd471e62012-05-01 13:07:01 -07009105 final Uri stream = getParcelableExtra(EXTRA_STREAM);
9106 final CharSequence text = getCharSequenceExtra(EXTRA_TEXT);
9107 final String htmlText = getStringExtra(EXTRA_HTML_TEXT);
9108 if (stream != null || text != null || htmlText != null) {
9109 final ClipData clipData = new ClipData(
9110 null, new String[] { getType() },
9111 new ClipData.Item(text, htmlText, null, stream));
9112 setClipData(clipData);
9113 addFlags(FLAG_GRANT_READ_URI_PERMISSION);
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009114 return true;
Jeff Sharkeydd471e62012-05-01 13:07:01 -07009115 }
Jeff Sharkeyf27ea662012-03-27 10:34:24 -07009116 } catch (ClassCastException e) {
Jeff Sharkeyf27ea662012-03-27 10:34:24 -07009117 }
Jeff Sharkey678d04f2012-03-23 15:41:58 -07009118
9119 } else if (ACTION_SEND_MULTIPLE.equals(action)) {
Jeff Sharkeyf27ea662012-03-27 10:34:24 -07009120 try {
Jeff Sharkeydd471e62012-05-01 13:07:01 -07009121 final ArrayList<Uri> streams = getParcelableArrayListExtra(EXTRA_STREAM);
9122 final ArrayList<CharSequence> texts = getCharSequenceArrayListExtra(EXTRA_TEXT);
9123 final ArrayList<String> htmlTexts = getStringArrayListExtra(EXTRA_HTML_TEXT);
9124 int num = -1;
9125 if (streams != null) {
9126 num = streams.size();
9127 }
9128 if (texts != null) {
9129 if (num >= 0 && num != texts.size()) {
9130 // Wha...! F- you.
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009131 return false;
Jeff Sharkeydd471e62012-05-01 13:07:01 -07009132 }
9133 num = texts.size();
9134 }
9135 if (htmlTexts != null) {
9136 if (num >= 0 && num != htmlTexts.size()) {
9137 // Wha...! F- you.
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009138 return false;
Jeff Sharkeydd471e62012-05-01 13:07:01 -07009139 }
9140 num = htmlTexts.size();
9141 }
9142 if (num > 0) {
9143 final ClipData clipData = new ClipData(
9144 null, new String[] { getType() },
9145 makeClipItem(streams, texts, htmlTexts, 0));
9146
9147 for (int i = 1; i < num; i++) {
9148 clipData.addItem(makeClipItem(streams, texts, htmlTexts, i));
9149 }
9150
9151 setClipData(clipData);
9152 addFlags(FLAG_GRANT_READ_URI_PERMISSION);
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009153 return true;
Jeff Sharkeydd471e62012-05-01 13:07:01 -07009154 }
Jeff Sharkeyf27ea662012-03-27 10:34:24 -07009155 } catch (ClassCastException e) {
Jeff Sharkeyf27ea662012-03-27 10:34:24 -07009156 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009157 } else if (MediaStore.ACTION_IMAGE_CAPTURE.equals(action)
9158 || MediaStore.ACTION_IMAGE_CAPTURE_SECURE.equals(action)
9159 || MediaStore.ACTION_VIDEO_CAPTURE.equals(action)) {
9160 final Uri output;
9161 try {
9162 output = getParcelableExtra(MediaStore.EXTRA_OUTPUT);
9163 } catch (ClassCastException e) {
9164 return false;
9165 }
9166 if (output != null) {
9167 setClipData(ClipData.newRawUri("", output));
9168 addFlags(FLAG_GRANT_WRITE_URI_PERMISSION|FLAG_GRANT_READ_URI_PERMISSION);
9169 return true;
9170 }
Jeff Sharkey678d04f2012-03-23 15:41:58 -07009171 }
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009172
9173 return false;
Jeff Sharkey678d04f2012-03-23 15:41:58 -07009174 }
Dianne Hackbornac4243f2012-04-13 17:32:18 -07009175
9176 private static ClipData.Item makeClipItem(ArrayList<Uri> streams, ArrayList<CharSequence> texts,
9177 ArrayList<String> htmlTexts, int which) {
9178 Uri uri = streams != null ? streams.get(which) : null;
9179 CharSequence text = texts != null ? texts.get(which) : null;
9180 String htmlText = htmlTexts != null ? htmlTexts.get(which) : null;
9181 return new ClipData.Item(text, htmlText, null, uri);
9182 }
Craig Mautnerd00f4742014-03-12 14:17:26 -07009183
9184 /** @hide */
9185 public boolean isDocument() {
9186 return (mFlags & FLAG_ACTIVITY_NEW_DOCUMENT) == FLAG_ACTIVITY_NEW_DOCUMENT;
9187 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009188}