blob: f62621b42d998daf661773c2ca83ddec5e5c8d1b [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 Sharkey179d6b32017-03-12 17:27:47 -060043import android.os.storage.StorageManager;
Jeff Sharkeybd3b9022013-08-20 15:20:04 -070044import android.provider.DocumentsContract;
Jeff Sharkeyadef88a2013-10-15 13:54:44 -070045import android.provider.DocumentsProvider;
Jason Monk2f68e8a2016-02-23 17:57:28 -050046import android.provider.MediaStore;
Jeff Sharkeyadef88a2013-10-15 13:54:44 -070047import android.provider.OpenableColumns;
Jason Monk2f68e8a2016-02-23 17:57:28 -050048import android.util.ArraySet;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070049import android.util.AttributeSet;
50import android.util.Log;
Dianne Hackborn2269d1572010-02-24 19:54:22 -080051import com.android.internal.util.XmlUtils;
Jason Monk2f68e8a2016-02-23 17:57:28 -050052import org.xmlpull.v1.XmlPullParser;
53import org.xmlpull.v1.XmlPullParserException;
Craig Mautner21d24a22014-04-23 11:45:37 -070054import org.xmlpull.v1.XmlSerializer;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070055
56import java.io.IOException;
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -080057import java.io.PrintWriter;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070058import java.io.Serializable;
Tor Norbyed9273d62013-05-30 15:59:53 -070059import java.lang.annotation.Retention;
60import java.lang.annotation.RetentionPolicy;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070061import java.net.URISyntaxException;
62import java.util.ArrayList;
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -080063import java.util.HashSet;
Dianne Hackborn221ea892013-08-04 16:50:16 -070064import java.util.List;
Nick Pellyccae4122012-01-09 14:12:58 -080065import java.util.Locale;
Christopher Tate63d9ae12014-06-19 19:07:26 -070066import java.util.Objects;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070067import java.util.Set;
68
Jason Monk2f68e8a2016-02-23 17:57:28 -050069import static android.content.ContentProvider.maybeAddUserId;
70
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070071/**
72 * An intent is an abstract description of an operation to be performed. It
73 * can be used with {@link Context#startActivity(Intent) startActivity} to
74 * launch an {@link android.app.Activity},
75 * {@link android.content.Context#sendBroadcast(Intent) broadcastIntent} to
76 * send it to any interested {@link BroadcastReceiver BroadcastReceiver} components,
77 * and {@link android.content.Context#startService} or
78 * {@link android.content.Context#bindService} to communicate with a
79 * background {@link android.app.Service}.
80 *
Joe Fernandezb54e7a32011-10-03 15:09:50 -070081 * <p>An Intent provides a facility for performing late runtime binding between the code in
82 * different applications. Its most significant use is in the launching of activities, where it
Daniel Lehmanna5b58df2011-10-12 16:24:22 -070083 * can be thought of as the glue between activities. It is basically a passive data structure
84 * holding an abstract description of an action to be performed.</p>
Joe Fernandezb54e7a32011-10-03 15:09:50 -070085 *
86 * <div class="special reference">
87 * <h3>Developer Guides</h3>
88 * <p>For information about how to create and resolve intents, read the
89 * <a href="{@docRoot}guide/topics/intents/intents-filters.html">Intents and Intent Filters</a>
90 * developer guide.</p>
91 * </div>
92 *
93 * <a name="IntentStructure"></a>
94 * <h3>Intent Structure</h3>
95 * <p>The primary pieces of information in an intent are:</p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070096 *
97 * <ul>
98 * <li> <p><b>action</b> -- The general action to be performed, such as
99 * {@link #ACTION_VIEW}, {@link #ACTION_EDIT}, {@link #ACTION_MAIN},
100 * etc.</p>
101 * </li>
102 * <li> <p><b>data</b> -- The data to operate on, such as a person record
103 * in the contacts database, expressed as a {@link android.net.Uri}.</p>
104 * </li>
105 * </ul>
106 *
107 *
108 * <p>Some examples of action/data pairs are:</p>
109 *
110 * <ul>
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700111 * <li> <p><b>{@link #ACTION_VIEW} <i>content://contacts/people/1</i></b> -- Display
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700112 * information about the person whose identifier is "1".</p>
113 * </li>
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700114 * <li> <p><b>{@link #ACTION_DIAL} <i>content://contacts/people/1</i></b> -- Display
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700115 * the phone dialer with the person filled in.</p>
116 * </li>
117 * <li> <p><b>{@link #ACTION_VIEW} <i>tel:123</i></b> -- Display
118 * the phone dialer with the given number filled in. Note how the
Trevor Johns682c24e2016-04-12 10:13:47 -0700119 * VIEW action does what is considered the most reasonable thing for
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700120 * a particular URI.</p>
121 * </li>
122 * <li> <p><b>{@link #ACTION_DIAL} <i>tel:123</i></b> -- Display
123 * the phone dialer with the given number filled in.</p>
124 * </li>
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700125 * <li> <p><b>{@link #ACTION_EDIT} <i>content://contacts/people/1</i></b> -- Edit
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700126 * information about the person whose identifier is "1".</p>
127 * </li>
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700128 * <li> <p><b>{@link #ACTION_VIEW} <i>content://contacts/people/</i></b> -- Display
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700129 * a list of people, which the user can browse through. This example is a
130 * typical top-level entry into the Contacts application, showing you the
131 * list of people. Selecting a particular person to view would result in a
Kevin Hufnagleaedfd752016-09-08 21:56:25 -0700132 * new intent { <b>{@link #ACTION_VIEW} <i>content://contacts/people/N</i></b> }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700133 * being used to start an activity to display that person.</p>
134 * </li>
135 * </ul>
136 *
137 * <p>In addition to these primary attributes, there are a number of secondary
138 * attributes that you can also include with an intent:</p>
139 *
140 * <ul>
141 * <li> <p><b>category</b> -- Gives additional information about the action
142 * to execute. For example, {@link #CATEGORY_LAUNCHER} means it should
143 * appear in the Launcher as a top-level application, while
144 * {@link #CATEGORY_ALTERNATIVE} means it should be included in a list
145 * of alternative actions the user can perform on a piece of data.</p>
146 * <li> <p><b>type</b> -- Specifies an explicit type (a MIME type) of the
147 * intent data. Normally the type is inferred from the data itself.
148 * By setting this attribute, you disable that evaluation and force
149 * an explicit type.</p>
150 * <li> <p><b>component</b> -- Specifies an explicit name of a component
151 * class to use for the intent. Normally this is determined by looking
152 * at the other information in the intent (the action, data/type, and
153 * categories) and matching that with a component that can handle it.
154 * If this attribute is set then none of the evaluation is performed,
155 * and this component is used exactly as is. By specifying this attribute,
156 * all of the other Intent attributes become optional.</p>
157 * <li> <p><b>extras</b> -- This is a {@link Bundle} of any additional information.
158 * This can be used to provide extended information to the component.
159 * For example, if we have a action to send an e-mail message, we could
160 * also include extra pieces of data here to supply a subject, body,
161 * etc.</p>
162 * </ul>
163 *
164 * <p>Here are some examples of other operations you can specify as intents
165 * using these additional parameters:</p>
166 *
167 * <ul>
168 * <li> <p><b>{@link #ACTION_MAIN} with category {@link #CATEGORY_HOME}</b> --
169 * Launch the home screen.</p>
170 * </li>
171 * <li> <p><b>{@link #ACTION_GET_CONTENT} with MIME type
172 * <i>{@link android.provider.Contacts.Phones#CONTENT_URI
173 * vnd.android.cursor.item/phone}</i></b>
174 * -- Display the list of people's phone numbers, allowing the user to
175 * browse through them and pick one and return it to the parent activity.</p>
176 * </li>
177 * <li> <p><b>{@link #ACTION_GET_CONTENT} with MIME type
178 * <i>*{@literal /}*</i> and category {@link #CATEGORY_OPENABLE}</b>
179 * -- Display all pickers for data that can be opened with
180 * {@link ContentResolver#openInputStream(Uri) ContentResolver.openInputStream()},
181 * allowing the user to pick one of them and then some data inside of it
182 * and returning the resulting URI to the caller. This can be used,
183 * for example, in an e-mail application to allow the user to pick some
184 * data to include as an attachment.</p>
185 * </li>
186 * </ul>
187 *
188 * <p>There are a variety of standard Intent action and category constants
189 * defined in the Intent class, but applications can also define their own.
Trevor Johns682c24e2016-04-12 10:13:47 -0700190 * These strings use Java-style scoping, to ensure they are unique -- for
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700191 * example, the standard {@link #ACTION_VIEW} is called
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700192 * "android.intent.action.VIEW".</p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700193 *
194 * <p>Put together, the set of actions, data types, categories, and extra data
195 * defines a language for the system allowing for the expression of phrases
196 * such as "call john smith's cell". As applications are added to the system,
197 * they can extend this language by adding new actions, types, and categories, or
198 * they can modify the behavior of existing phrases by supplying their own
199 * activities that handle them.</p>
200 *
201 * <a name="IntentResolution"></a>
202 * <h3>Intent Resolution</h3>
203 *
204 * <p>There are two primary forms of intents you will use.
205 *
206 * <ul>
207 * <li> <p><b>Explicit Intents</b> have specified a component (via
208 * {@link #setComponent} or {@link #setClass}), which provides the exact
209 * class to be run. Often these will not include any other information,
210 * simply being a way for an application to launch various internal
211 * activities it has as the user interacts with the application.
212 *
213 * <li> <p><b>Implicit Intents</b> have not specified a component;
214 * instead, they must include enough information for the system to
215 * determine which of the available components is best to run for that
216 * intent.
217 * </ul>
218 *
219 * <p>When using implicit intents, given such an arbitrary intent we need to
220 * know what to do with it. This is handled by the process of <em>Intent
221 * resolution</em>, which maps an Intent to an {@link android.app.Activity},
222 * {@link BroadcastReceiver}, or {@link android.app.Service} (or sometimes two or
223 * more activities/receivers) that can handle it.</p>
224 *
225 * <p>The intent resolution mechanism basically revolves around matching an
226 * Intent against all of the &lt;intent-filter&gt; descriptions in the
227 * installed application packages. (Plus, in the case of broadcasts, any {@link BroadcastReceiver}
228 * objects explicitly registered with {@link Context#registerReceiver}.) More
229 * details on this can be found in the documentation on the {@link
230 * IntentFilter} class.</p>
231 *
232 * <p>There are three pieces of information in the Intent that are used for
233 * resolution: the action, type, and category. Using this information, a query
234 * is done on the {@link PackageManager} for a component that can handle the
235 * intent. The appropriate component is determined based on the intent
236 * information supplied in the <code>AndroidManifest.xml</code> file as
237 * follows:</p>
238 *
239 * <ul>
240 * <li> <p>The <b>action</b>, if given, must be listed by the component as
241 * one it handles.</p>
242 * <li> <p>The <b>type</b> is retrieved from the Intent's data, if not
243 * already supplied in the Intent. Like the action, if a type is
244 * included in the intent (either explicitly or implicitly in its
245 * data), then this must be listed by the component as one it handles.</p>
246 * <li> For data that is not a <code>content:</code> URI and where no explicit
247 * type is included in the Intent, instead the <b>scheme</b> of the
248 * intent data (such as <code>http:</code> or <code>mailto:</code>) is
249 * considered. Again like the action, if we are matching a scheme it
250 * must be listed by the component as one it can handle.
251 * <li> <p>The <b>categories</b>, if supplied, must <em>all</em> be listed
252 * by the activity as categories it handles. That is, if you include
253 * the categories {@link #CATEGORY_LAUNCHER} and
254 * {@link #CATEGORY_ALTERNATIVE}, then you will only resolve to components
255 * with an intent that lists <em>both</em> of those categories.
256 * Activities will very often need to support the
257 * {@link #CATEGORY_DEFAULT} so that they can be found by
258 * {@link Context#startActivity Context.startActivity()}.</p>
259 * </ul>
260 *
261 * <p>For example, consider the Note Pad sample application that
262 * allows user to browse through a list of notes data and view details about
263 * individual items. Text in italics indicate places were you would replace a
264 * name with one specific to your own package.</p>
265 *
266 * <pre> &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
267 * package="<i>com.android.notepad</i>"&gt;
268 * &lt;application android:icon="@drawable/app_notes"
269 * android:label="@string/app_name"&gt;
270 *
271 * &lt;provider class=".NotePadProvider"
272 * android:authorities="<i>com.google.provider.NotePad</i>" /&gt;
273 *
274 * &lt;activity class=".NotesList" android:label="@string/title_notes_list"&gt;
275 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700276 * &lt;action android:name="android.intent.action.MAIN" /&gt;
277 * &lt;category android:name="android.intent.category.LAUNCHER" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700278 * &lt;/intent-filter&gt;
279 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700280 * &lt;action android:name="android.intent.action.VIEW" /&gt;
281 * &lt;action android:name="android.intent.action.EDIT" /&gt;
282 * &lt;action android:name="android.intent.action.PICK" /&gt;
283 * &lt;category android:name="android.intent.category.DEFAULT" /&gt;
284 * &lt;data android:mimeType="vnd.android.cursor.dir/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700285 * &lt;/intent-filter&gt;
286 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700287 * &lt;action android:name="android.intent.action.GET_CONTENT" /&gt;
288 * &lt;category android:name="android.intent.category.DEFAULT" /&gt;
289 * &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700290 * &lt;/intent-filter&gt;
291 * &lt;/activity&gt;
292 *
293 * &lt;activity class=".NoteEditor" android:label="@string/title_note"&gt;
294 * &lt;intent-filter android:label="@string/resolve_edit"&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700295 * &lt;action android:name="android.intent.action.VIEW" /&gt;
296 * &lt;action android:name="android.intent.action.EDIT" /&gt;
297 * &lt;category android:name="android.intent.category.DEFAULT" /&gt;
298 * &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700299 * &lt;/intent-filter&gt;
300 *
301 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700302 * &lt;action android:name="android.intent.action.INSERT" /&gt;
303 * &lt;category android:name="android.intent.category.DEFAULT" /&gt;
304 * &lt;data android:mimeType="vnd.android.cursor.dir/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700305 * &lt;/intent-filter&gt;
306 *
307 * &lt;/activity&gt;
308 *
309 * &lt;activity class=".TitleEditor" android:label="@string/title_edit_title"
310 * android:theme="@android:style/Theme.Dialog"&gt;
311 * &lt;intent-filter android:label="@string/resolve_title"&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700312 * &lt;action android:name="<i>com.android.notepad.action.EDIT_TITLE</i>" /&gt;
313 * &lt;category android:name="android.intent.category.DEFAULT" /&gt;
314 * &lt;category android:name="android.intent.category.ALTERNATIVE" /&gt;
315 * &lt;category android:name="android.intent.category.SELECTED_ALTERNATIVE" /&gt;
316 * &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700317 * &lt;/intent-filter&gt;
318 * &lt;/activity&gt;
319 *
320 * &lt;/application&gt;
321 * &lt;/manifest&gt;</pre>
322 *
323 * <p>The first activity,
324 * <code>com.android.notepad.NotesList</code>, serves as our main
325 * entry into the app. It can do three things as described by its three intent
326 * templates:
327 * <ol>
328 * <li><pre>
329 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700330 * &lt;action android:name="{@link #ACTION_MAIN android.intent.action.MAIN}" /&gt;
331 * &lt;category android:name="{@link #CATEGORY_LAUNCHER android.intent.category.LAUNCHER}" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700332 * &lt;/intent-filter&gt;</pre>
333 * <p>This provides a top-level entry into the NotePad application: the standard
334 * MAIN action is a main entry point (not requiring any other information in
335 * the Intent), and the LAUNCHER category says that this entry point should be
336 * listed in the application launcher.</p>
337 * <li><pre>
338 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700339 * &lt;action android:name="{@link #ACTION_VIEW android.intent.action.VIEW}" /&gt;
340 * &lt;action android:name="{@link #ACTION_EDIT android.intent.action.EDIT}" /&gt;
341 * &lt;action android:name="{@link #ACTION_PICK android.intent.action.PICK}" /&gt;
342 * &lt;category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /&gt;
Trevor Johns682c24e2016-04-12 10:13:47 -0700343 * &lt;data android:mimeType="vnd.android.cursor.dir/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700344 * &lt;/intent-filter&gt;</pre>
345 * <p>This declares the things that the activity can do on a directory of
346 * notes. The type being supported is given with the &lt;type&gt; tag, where
347 * <code>vnd.android.cursor.dir/vnd.google.note</code> is a URI from which
348 * a Cursor of zero or more items (<code>vnd.android.cursor.dir</code>) can
349 * be retrieved which holds our note pad data (<code>vnd.google.note</code>).
350 * The activity allows the user to view or edit the directory of data (via
351 * the VIEW and EDIT actions), or to pick a particular note and return it
352 * to the caller (via the PICK action). Note also the DEFAULT category
353 * supplied here: this is <em>required</em> for the
354 * {@link Context#startActivity Context.startActivity} method to resolve your
355 * activity when its component name is not explicitly specified.</p>
356 * <li><pre>
357 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700358 * &lt;action android:name="{@link #ACTION_GET_CONTENT android.intent.action.GET_CONTENT}" /&gt;
359 * &lt;category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /&gt;
360 * &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700361 * &lt;/intent-filter&gt;</pre>
Trevor Johns682c24e2016-04-12 10:13:47 -0700362 * <p>This filter describes the ability to return to the caller a note selected by
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700363 * the user without needing to know where it came from. The data type
364 * <code>vnd.android.cursor.item/vnd.google.note</code> is a URI from which
365 * a Cursor of exactly one (<code>vnd.android.cursor.item</code>) item can
366 * be retrieved which contains our note pad data (<code>vnd.google.note</code>).
367 * The GET_CONTENT action is similar to the PICK action, where the activity
368 * will return to its caller a piece of data selected by the user. Here,
369 * however, the caller specifies the type of data they desire instead of
370 * the type of data the user will be picking from.</p>
371 * </ol>
372 *
373 * <p>Given these capabilities, the following intents will resolve to the
374 * NotesList activity:</p>
375 *
376 * <ul>
377 * <li> <p><b>{ action=android.app.action.MAIN }</b> matches all of the
378 * activities that can be used as top-level entry points into an
379 * application.</p>
380 * <li> <p><b>{ action=android.app.action.MAIN,
381 * category=android.app.category.LAUNCHER }</b> is the actual intent
382 * used by the Launcher to populate its top-level list.</p>
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700383 * <li> <p><b>{ action=android.intent.action.VIEW
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700384 * data=content://com.google.provider.NotePad/notes }</b>
385 * displays a list of all the notes under
386 * "content://com.google.provider.NotePad/notes", which
387 * the user can browse through and see the details on.</p>
388 * <li> <p><b>{ action=android.app.action.PICK
389 * data=content://com.google.provider.NotePad/notes }</b>
390 * provides a list of the notes under
391 * "content://com.google.provider.NotePad/notes", from which
392 * the user can pick a note whose data URL is returned back to the caller.</p>
393 * <li> <p><b>{ action=android.app.action.GET_CONTENT
394 * type=vnd.android.cursor.item/vnd.google.note }</b>
395 * is similar to the pick action, but allows the caller to specify the
396 * kind of data they want back so that the system can find the appropriate
397 * activity to pick something of that data type.</p>
398 * </ul>
399 *
400 * <p>The second activity,
401 * <code>com.android.notepad.NoteEditor</code>, shows the user a single
402 * note entry and allows them to edit it. It can do two things as described
403 * by its two intent templates:
404 * <ol>
405 * <li><pre>
406 * &lt;intent-filter android:label="@string/resolve_edit"&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700407 * &lt;action android:name="{@link #ACTION_VIEW android.intent.action.VIEW}" /&gt;
408 * &lt;action android:name="{@link #ACTION_EDIT android.intent.action.EDIT}" /&gt;
409 * &lt;category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /&gt;
410 * &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700411 * &lt;/intent-filter&gt;</pre>
412 * <p>The first, primary, purpose of this activity is to let the user interact
413 * with a single note, as decribed by the MIME type
414 * <code>vnd.android.cursor.item/vnd.google.note</code>. The activity can
415 * either VIEW a note or allow the user to EDIT it. Again we support the
416 * DEFAULT category to allow the activity to be launched without explicitly
417 * specifying its component.</p>
418 * <li><pre>
419 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700420 * &lt;action android:name="{@link #ACTION_INSERT android.intent.action.INSERT}" /&gt;
421 * &lt;category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /&gt;
422 * &lt;data android:mimeType="vnd.android.cursor.dir/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700423 * &lt;/intent-filter&gt;</pre>
424 * <p>The secondary use of this activity is to insert a new note entry into
425 * an existing directory of notes. This is used when the user creates a new
426 * note: the INSERT action is executed on the directory of notes, causing
427 * this activity to run and have the user create the new note data which
428 * it then adds to the content provider.</p>
429 * </ol>
430 *
431 * <p>Given these capabilities, the following intents will resolve to the
432 * NoteEditor activity:</p>
433 *
434 * <ul>
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700435 * <li> <p><b>{ action=android.intent.action.VIEW
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700436 * data=content://com.google.provider.NotePad/notes/<var>{ID}</var> }</b>
437 * shows the user the content of note <var>{ID}</var>.</p>
438 * <li> <p><b>{ action=android.app.action.EDIT
439 * data=content://com.google.provider.NotePad/notes/<var>{ID}</var> }</b>
440 * allows the user to edit the content of note <var>{ID}</var>.</p>
441 * <li> <p><b>{ action=android.app.action.INSERT
442 * data=content://com.google.provider.NotePad/notes }</b>
443 * creates a new, empty note in the notes list at
444 * "content://com.google.provider.NotePad/notes"
445 * and allows the user to edit it. If they keep their changes, the URI
446 * of the newly created note is returned to the caller.</p>
447 * </ul>
448 *
449 * <p>The last activity,
450 * <code>com.android.notepad.TitleEditor</code>, allows the user to
451 * edit the title of a note. This could be implemented as a class that the
452 * application directly invokes (by explicitly setting its component in
453 * the Intent), but here we show a way you can publish alternative
454 * operations on existing data:</p>
455 *
456 * <pre>
457 * &lt;intent-filter android:label="@string/resolve_title"&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700458 * &lt;action android:name="<i>com.android.notepad.action.EDIT_TITLE</i>" /&gt;
459 * &lt;category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /&gt;
460 * &lt;category android:name="{@link #CATEGORY_ALTERNATIVE android.intent.category.ALTERNATIVE}" /&gt;
461 * &lt;category android:name="{@link #CATEGORY_SELECTED_ALTERNATIVE android.intent.category.SELECTED_ALTERNATIVE}" /&gt;
462 * &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700463 * &lt;/intent-filter&gt;</pre>
464 *
465 * <p>In the single intent template here, we
466 * have created our own private action called
467 * <code>com.android.notepad.action.EDIT_TITLE</code> which means to
468 * edit the title of a note. It must be invoked on a specific note
469 * (data type <code>vnd.android.cursor.item/vnd.google.note</code>) like the previous
470 * view and edit actions, but here displays and edits the title contained
471 * in the note data.
472 *
473 * <p>In addition to supporting the default category as usual, our title editor
474 * also supports two other standard categories: ALTERNATIVE and
475 * SELECTED_ALTERNATIVE. Implementing
476 * these categories allows others to find the special action it provides
477 * without directly knowing about it, through the
478 * {@link android.content.pm.PackageManager#queryIntentActivityOptions} method, or
479 * more often to build dynamic menu items with
480 * {@link android.view.Menu#addIntentOptions}. Note that in the intent
481 * template here was also supply an explicit name for the template
482 * (via <code>android:label="@string/resolve_title"</code>) to better control
483 * what the user sees when presented with this activity as an alternative
484 * action to the data they are viewing.
485 *
486 * <p>Given these capabilities, the following intent will resolve to the
487 * TitleEditor activity:</p>
488 *
489 * <ul>
490 * <li> <p><b>{ action=com.android.notepad.action.EDIT_TITLE
491 * data=content://com.google.provider.NotePad/notes/<var>{ID}</var> }</b>
492 * displays and allows the user to edit the title associated
493 * with note <var>{ID}</var>.</p>
494 * </ul>
495 *
496 * <h3>Standard Activity Actions</h3>
497 *
498 * <p>These are the current standard actions that Intent defines for launching
499 * activities (usually through {@link Context#startActivity}. The most
500 * important, and by far most frequently used, are {@link #ACTION_MAIN} and
501 * {@link #ACTION_EDIT}.
502 *
503 * <ul>
504 * <li> {@link #ACTION_MAIN}
505 * <li> {@link #ACTION_VIEW}
506 * <li> {@link #ACTION_ATTACH_DATA}
507 * <li> {@link #ACTION_EDIT}
508 * <li> {@link #ACTION_PICK}
509 * <li> {@link #ACTION_CHOOSER}
510 * <li> {@link #ACTION_GET_CONTENT}
511 * <li> {@link #ACTION_DIAL}
512 * <li> {@link #ACTION_CALL}
513 * <li> {@link #ACTION_SEND}
514 * <li> {@link #ACTION_SENDTO}
515 * <li> {@link #ACTION_ANSWER}
516 * <li> {@link #ACTION_INSERT}
517 * <li> {@link #ACTION_DELETE}
518 * <li> {@link #ACTION_RUN}
519 * <li> {@link #ACTION_SYNC}
520 * <li> {@link #ACTION_PICK_ACTIVITY}
521 * <li> {@link #ACTION_SEARCH}
522 * <li> {@link #ACTION_WEB_SEARCH}
523 * <li> {@link #ACTION_FACTORY_TEST}
524 * </ul>
525 *
526 * <h3>Standard Broadcast Actions</h3>
527 *
528 * <p>These are the current standard actions that Intent defines for receiving
529 * broadcasts (usually through {@link Context#registerReceiver} or a
530 * &lt;receiver&gt; tag in a manifest).
531 *
532 * <ul>
533 * <li> {@link #ACTION_TIME_TICK}
534 * <li> {@link #ACTION_TIME_CHANGED}
535 * <li> {@link #ACTION_TIMEZONE_CHANGED}
536 * <li> {@link #ACTION_BOOT_COMPLETED}
537 * <li> {@link #ACTION_PACKAGE_ADDED}
538 * <li> {@link #ACTION_PACKAGE_CHANGED}
539 * <li> {@link #ACTION_PACKAGE_REMOVED}
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800540 * <li> {@link #ACTION_PACKAGE_RESTARTED}
541 * <li> {@link #ACTION_PACKAGE_DATA_CLEARED}
Andrei Stingaceanu69d5ebc2016-01-14 12:59:03 +0000542 * <li> {@link #ACTION_PACKAGES_SUSPENDED}
543 * <li> {@link #ACTION_PACKAGES_UNSUSPENDED}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700544 * <li> {@link #ACTION_UID_REMOVED}
545 * <li> {@link #ACTION_BATTERY_CHANGED}
Cliff Spradlinfda6fae2008-10-22 20:29:16 -0700546 * <li> {@link #ACTION_POWER_CONNECTED}
Romain Guy4969af72009-06-17 10:53:19 -0700547 * <li> {@link #ACTION_POWER_DISCONNECTED}
548 * <li> {@link #ACTION_SHUTDOWN}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700549 * </ul>
550 *
551 * <h3>Standard Categories</h3>
552 *
553 * <p>These are the current standard categories that can be used to further
554 * clarify an Intent via {@link #addCategory}.
555 *
556 * <ul>
557 * <li> {@link #CATEGORY_DEFAULT}
558 * <li> {@link #CATEGORY_BROWSABLE}
559 * <li> {@link #CATEGORY_TAB}
560 * <li> {@link #CATEGORY_ALTERNATIVE}
561 * <li> {@link #CATEGORY_SELECTED_ALTERNATIVE}
562 * <li> {@link #CATEGORY_LAUNCHER}
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800563 * <li> {@link #CATEGORY_INFO}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700564 * <li> {@link #CATEGORY_HOME}
565 * <li> {@link #CATEGORY_PREFERENCE}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700566 * <li> {@link #CATEGORY_TEST}
Mike Lockwood9092ab42009-09-16 13:01:32 -0400567 * <li> {@link #CATEGORY_CAR_DOCK}
568 * <li> {@link #CATEGORY_DESK_DOCK}
Praveen Bharathi21e941b2010-10-06 15:23:14 -0500569 * <li> {@link #CATEGORY_LE_DESK_DOCK}
570 * <li> {@link #CATEGORY_HE_DESK_DOCK}
Bernd Holzheyaea4b672010-03-31 09:46:13 +0200571 * <li> {@link #CATEGORY_CAR_MODE}
Patrick Dubroy6dabe242010-08-30 10:43:47 -0700572 * <li> {@link #CATEGORY_APP_MARKET}
Zak Cohendb6ca492017-01-26 14:09:00 -0800573 * <li> {@link #CATEGORY_VR_HOME}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700574 * </ul>
575 *
576 * <h3>Standard Extra Data</h3>
577 *
578 * <p>These are the current standard fields that can be used as extra data via
579 * {@link #putExtra}.
580 *
581 * <ul>
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800582 * <li> {@link #EXTRA_ALARM_COUNT}
583 * <li> {@link #EXTRA_BCC}
584 * <li> {@link #EXTRA_CC}
585 * <li> {@link #EXTRA_CHANGED_COMPONENT_NAME}
586 * <li> {@link #EXTRA_DATA_REMOVED}
587 * <li> {@link #EXTRA_DOCK_STATE}
Praveen Bharathi21e941b2010-10-06 15:23:14 -0500588 * <li> {@link #EXTRA_DOCK_STATE_HE_DESK}
589 * <li> {@link #EXTRA_DOCK_STATE_LE_DESK}
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800590 * <li> {@link #EXTRA_DOCK_STATE_CAR}
591 * <li> {@link #EXTRA_DOCK_STATE_DESK}
592 * <li> {@link #EXTRA_DOCK_STATE_UNDOCKED}
593 * <li> {@link #EXTRA_DONT_KILL_APP}
594 * <li> {@link #EXTRA_EMAIL}
595 * <li> {@link #EXTRA_INITIAL_INTENTS}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700596 * <li> {@link #EXTRA_INTENT}
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800597 * <li> {@link #EXTRA_KEY_EVENT}
rich cannings706e8ba2012-08-20 13:20:14 -0700598 * <li> {@link #EXTRA_ORIGINATING_URI}
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800599 * <li> {@link #EXTRA_PHONE_NUMBER}
rich cannings368ed012012-06-07 15:37:57 -0700600 * <li> {@link #EXTRA_REFERRER}
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800601 * <li> {@link #EXTRA_REMOTE_INTENT_TOKEN}
602 * <li> {@link #EXTRA_REPLACING}
603 * <li> {@link #EXTRA_SHORTCUT_ICON}
604 * <li> {@link #EXTRA_SHORTCUT_ICON_RESOURCE}
605 * <li> {@link #EXTRA_SHORTCUT_INTENT}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700606 * <li> {@link #EXTRA_STREAM}
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800607 * <li> {@link #EXTRA_SHORTCUT_NAME}
608 * <li> {@link #EXTRA_SUBJECT}
609 * <li> {@link #EXTRA_TEMPLATE}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700610 * <li> {@link #EXTRA_TEXT}
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800611 * <li> {@link #EXTRA_TITLE}
612 * <li> {@link #EXTRA_UID}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700613 * </ul>
614 *
615 * <h3>Flags</h3>
616 *
617 * <p>These are the possible flags that can be used in the Intent via
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800618 * {@link #setFlags} and {@link #addFlags}. See {@link #setFlags} for a list
619 * of all possible flags.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700620 */
Dianne Hackbornee0511d2009-12-21 18:08:13 -0800621public class Intent implements Parcelable, Cloneable {
Craig Mautner21d24a22014-04-23 11:45:37 -0700622 private static final String ATTR_ACTION = "action";
623 private static final String TAG_CATEGORIES = "categories";
624 private static final String ATTR_CATEGORY = "category";
625 private static final String TAG_EXTRA = "extra";
626 private static final String ATTR_TYPE = "type";
627 private static final String ATTR_COMPONENT = "component";
628 private static final String ATTR_DATA = "data";
629 private static final String ATTR_FLAGS = "flags";
630
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700631 // ---------------------------------------------------------------------
632 // ---------------------------------------------------------------------
633 // Standard intent activity actions (see action variable).
634
635 /**
636 * Activity Action: Start as a main entry point, does not expect to
637 * receive data.
638 * <p>Input: nothing
639 * <p>Output: nothing
640 */
641 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
642 public static final String ACTION_MAIN = "android.intent.action.MAIN";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800643
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700644 /**
645 * Activity Action: Display the data to the user. This is the most common
646 * action performed on data -- it is the generic action you can use on
647 * a piece of data to get the most reasonable thing to occur. For example,
648 * when used on a contacts entry it will view the entry; when used on a
649 * mailto: URI it will bring up a compose window filled with the information
650 * supplied by the URI; when used with a tel: URI it will invoke the
651 * dialer.
652 * <p>Input: {@link #getData} is URI from which to retrieve data.
653 * <p>Output: nothing.
654 */
655 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
656 public static final String ACTION_VIEW = "android.intent.action.VIEW";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800657
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700658 /**
659 * A synonym for {@link #ACTION_VIEW}, the "standard" action that is
660 * performed on a piece of data.
661 */
662 public static final String ACTION_DEFAULT = ACTION_VIEW;
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800663
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700664 /**
Tomasz Mikolajewski319fb492016-01-20 12:24:01 +0900665 * Activity Action: Quick view the data. Launches a quick viewer for
666 * a URI or a list of URIs.
Tomasz Mikolajewskife023132016-03-10 17:42:35 +0900667 * <p>Activities handling this intent action should handle the vast majority of
668 * MIME types rather than only specific ones.
Tomasz Mikolajewski319fb492016-01-20 12:24:01 +0900669 * <p>Input: {@link #getData} is a mandatory content URI of the item to
670 * preview. {@link #getClipData} contains an optional list of content URIs
671 * if there is more than one item to preview. {@link #EXTRA_INDEX} is an
672 * optional index of the URI in the clip data to show first.
Tomasz Mikolajewski17c50da2017-02-16 14:38:04 +0900673 * <p>By default quick viewers are supposed to be lightweight and focus on
674 * previewing the content only. They should not expose features such as printing,
675 * opening in an external app, deleting, rotating, casting, etc.
676 * However, if {@link #EXTRA_QUICK_VIEW_ADVANCED} is true, then the quick viewer
677 * may show advanced UI which includes convenience actions suitable for the passed
678 * Uris.
Steve McKayc78bcb82015-07-31 14:35:22 -0700679 * <p>Output: nothing.
Tomasz Mikolajewski17c50da2017-02-16 14:38:04 +0900680 * @see #EXTRA_QUICK_VIEW_ADVANCED
Tomasz Mikolajewski867addf2017-02-01 14:16:39 +0900681 * @see #EXTRA_INDEX
Steve McKayc78bcb82015-07-31 14:35:22 -0700682 */
683 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
684 public static final String ACTION_QUICK_VIEW = "android.intent.action.QUICK_VIEW";
685
686 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700687 * Used to indicate that some piece of data should be attached to some other
688 * place. For example, image data could be attached to a contact. It is up
689 * to the recipient to decide where the data should be attached; the intent
690 * does not specify the ultimate destination.
691 * <p>Input: {@link #getData} is URI of data to be attached.
692 * <p>Output: nothing.
693 */
694 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
695 public static final String ACTION_ATTACH_DATA = "android.intent.action.ATTACH_DATA";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800696
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700697 /**
698 * Activity Action: Provide explicit editable access to the given data.
699 * <p>Input: {@link #getData} is URI of data to be edited.
700 * <p>Output: nothing.
701 */
702 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
703 public static final String ACTION_EDIT = "android.intent.action.EDIT";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800704
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700705 /**
706 * Activity Action: Pick an existing item, or insert a new item, and then edit it.
707 * <p>Input: {@link #getType} is the desired MIME type of the item to create or edit.
708 * The extras can contain type specific data to pass through to the editing/creating
709 * activity.
710 * <p>Output: The URI of the item that was picked. This must be a content:
711 * URI so that any receiver can access it.
712 */
713 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
714 public static final String ACTION_INSERT_OR_EDIT = "android.intent.action.INSERT_OR_EDIT";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800715
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700716 /**
717 * Activity Action: Pick an item from the data, returning what was selected.
718 * <p>Input: {@link #getData} is URI containing a directory of data
719 * (vnd.android.cursor.dir/*) from which to pick an item.
720 * <p>Output: The URI of the item that was picked.
721 */
722 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
723 public static final String ACTION_PICK = "android.intent.action.PICK";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800724
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700725 /**
726 * Activity Action: Creates a shortcut.
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800727 * <p>Input: Nothing.</p>
Sunny Goyala6be88a2017-01-12 16:27:58 -0800728 * <p>Output: An Intent representing the {@link android.content.pm.ShortcutInfo} result.</p>
729 * <p>For compatibility with older versions of android the intent may also contain three
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700730 * extras: SHORTCUT_INTENT (value: Intent), SHORTCUT_NAME (value: String),
731 * and SHORTCUT_ICON (value: Bitmap) or SHORTCUT_ICON_RESOURCE
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800732 * (value: ShortcutIconResource).</p>
733 *
Sunny Goyala6be88a2017-01-12 16:27:58 -0800734 * @see android.content.pm.ShortcutManager#createShortcutResultIntent
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700735 * @see #EXTRA_SHORTCUT_INTENT
736 * @see #EXTRA_SHORTCUT_NAME
737 * @see #EXTRA_SHORTCUT_ICON
738 * @see #EXTRA_SHORTCUT_ICON_RESOURCE
739 * @see android.content.Intent.ShortcutIconResource
740 */
741 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
742 public static final String ACTION_CREATE_SHORTCUT = "android.intent.action.CREATE_SHORTCUT";
743
744 /**
745 * The name of the extra used to define the Intent of a shortcut.
746 *
747 * @see #ACTION_CREATE_SHORTCUT
Sunny Goyala6be88a2017-01-12 16:27:58 -0800748 * @deprecated Replaced with {@link android.content.pm.ShortcutManager#createShortcutResultIntent}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700749 */
Sunny Goyala6be88a2017-01-12 16:27:58 -0800750 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700751 public static final String EXTRA_SHORTCUT_INTENT = "android.intent.extra.shortcut.INTENT";
752 /**
753 * The name of the extra used to define the name of a shortcut.
754 *
755 * @see #ACTION_CREATE_SHORTCUT
Sunny Goyala6be88a2017-01-12 16:27:58 -0800756 * @deprecated Replaced with {@link android.content.pm.ShortcutManager#createShortcutResultIntent}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700757 */
Sunny Goyala6be88a2017-01-12 16:27:58 -0800758 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700759 public static final String EXTRA_SHORTCUT_NAME = "android.intent.extra.shortcut.NAME";
760 /**
761 * The name of the extra used to define the icon, as a Bitmap, of a shortcut.
762 *
763 * @see #ACTION_CREATE_SHORTCUT
Sunny Goyala6be88a2017-01-12 16:27:58 -0800764 * @deprecated Replaced with {@link android.content.pm.ShortcutManager#createShortcutResultIntent}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700765 */
Sunny Goyala6be88a2017-01-12 16:27:58 -0800766 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700767 public static final String EXTRA_SHORTCUT_ICON = "android.intent.extra.shortcut.ICON";
768 /**
769 * The name of the extra used to define the icon, as a ShortcutIconResource, of a shortcut.
770 *
771 * @see #ACTION_CREATE_SHORTCUT
772 * @see android.content.Intent.ShortcutIconResource
Sunny Goyala6be88a2017-01-12 16:27:58 -0800773 * @deprecated Replaced with {@link android.content.pm.ShortcutManager#createShortcutResultIntent}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700774 */
Sunny Goyala6be88a2017-01-12 16:27:58 -0800775 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700776 public static final String EXTRA_SHORTCUT_ICON_RESOURCE =
777 "android.intent.extra.shortcut.ICON_RESOURCE";
778
779 /**
Jason Monk2f68e8a2016-02-23 17:57:28 -0500780 * An activity that provides a user interface for adjusting application preferences.
781 * Optional but recommended settings for all applications which have settings.
782 */
783 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
784 public static final String ACTION_APPLICATION_PREFERENCES
785 = "android.intent.action.APPLICATION_PREFERENCES";
786
787 /**
Sudheer Shanka80b66412016-04-06 18:31:10 -0700788 * Activity Action: Launch an activity showing the app information.
789 * For applications which install other applications (such as app stores), it is recommended
790 * to handle this action for providing the app information to the user.
791 *
792 * <p>Input: {@link #EXTRA_PACKAGE_NAME} specifies the package whose information needs
793 * to be displayed.
794 * <p>Output: Nothing.
795 */
796 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
797 public static final String ACTION_SHOW_APP_INFO
798 = "android.intent.action.SHOW_APP_INFO";
799
800 /**
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800801 * Represents a shortcut/live folder icon resource.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700802 *
803 * @see Intent#ACTION_CREATE_SHORTCUT
804 * @see Intent#EXTRA_SHORTCUT_ICON_RESOURCE
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800805 * @see android.provider.LiveFolders#ACTION_CREATE_LIVE_FOLDER
806 * @see android.provider.LiveFolders#EXTRA_LIVE_FOLDER_ICON
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700807 */
808 public static class ShortcutIconResource implements Parcelable {
809 /**
810 * The package name of the application containing the icon.
811 */
812 public String packageName;
813
814 /**
815 * The resource name of the icon, including package, name and type.
816 */
817 public String resourceName;
818
819 /**
820 * Creates a new ShortcutIconResource for the specified context and resource
821 * identifier.
822 *
823 * @param context The context of the application.
Tor Norbye7b9c9122013-05-30 16:48:33 -0700824 * @param resourceId The resource identifier for the icon.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700825 * @return A new ShortcutIconResource with the specified's context package name
Tor Norbye7b9c9122013-05-30 16:48:33 -0700826 * and icon resource identifier.``
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700827 */
Tor Norbye7b9c9122013-05-30 16:48:33 -0700828 public static ShortcutIconResource fromContext(Context context, @AnyRes int resourceId) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700829 ShortcutIconResource icon = new ShortcutIconResource();
830 icon.packageName = context.getPackageName();
831 icon.resourceName = context.getResources().getResourceName(resourceId);
832 return icon;
833 }
834
835 /**
836 * Used to read a ShortcutIconResource from a Parcel.
837 */
838 public static final Parcelable.Creator<ShortcutIconResource> CREATOR =
839 new Parcelable.Creator<ShortcutIconResource>() {
840
841 public ShortcutIconResource createFromParcel(Parcel source) {
842 ShortcutIconResource icon = new ShortcutIconResource();
843 icon.packageName = source.readString();
844 icon.resourceName = source.readString();
845 return icon;
846 }
847
848 public ShortcutIconResource[] newArray(int size) {
849 return new ShortcutIconResource[size];
850 }
851 };
852
853 /**
854 * No special parcel contents.
855 */
856 public int describeContents() {
857 return 0;
858 }
859
860 public void writeToParcel(Parcel dest, int flags) {
861 dest.writeString(packageName);
862 dest.writeString(resourceName);
863 }
864
865 @Override
866 public String toString() {
867 return resourceName;
868 }
869 }
870
871 /**
872 * Activity Action: Display an activity chooser, allowing the user to pick
873 * what they want to before proceeding. This can be used as an alternative
874 * to the standard activity picker that is displayed by the system when
875 * you try to start an activity with multiple possible matches, with these
876 * differences in behavior:
877 * <ul>
878 * <li>You can specify the title that will appear in the activity chooser.
879 * <li>The user does not have the option to make one of the matching
880 * activities a preferred activity, and all possible activities will
881 * always be shown even if one of them is currently marked as the
882 * preferred activity.
883 * </ul>
884 * <p>
885 * This action should be used when the user will naturally expect to
886 * select an activity in order to proceed. An example if when not to use
887 * it is when the user clicks on a "mailto:" link. They would naturally
888 * expect to go directly to their mail app, so startActivity() should be
889 * called directly: it will
890 * either launch the current preferred app, or put up a dialog allowing the
891 * user to pick an app to use and optionally marking that as preferred.
892 * <p>
893 * In contrast, if the user is selecting a menu item to send a picture
894 * they are viewing to someone else, there are many different things they
895 * may want to do at this point: send it through e-mail, upload it to a
896 * web service, etc. In this case the CHOOSER action should be used, to
897 * always present to the user a list of the things they can do, with a
898 * nice title given by the caller such as "Send this photo with:".
899 * <p>
Dianne Hackborne302a162012-05-15 14:58:32 -0700900 * If you need to grant URI permissions through a chooser, you must specify
901 * the permissions to be granted on the ACTION_CHOOSER Intent
902 * <em>in addition</em> to the EXTRA_INTENT inside. This means using
903 * {@link #setClipData} to specify the URIs to be granted as well as
904 * {@link #FLAG_GRANT_READ_URI_PERMISSION} and/or
905 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION} as appropriate.
906 * <p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700907 * As a convenience, an Intent of this form can be created with the
908 * {@link #createChooser} function.
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -0700909 * <p>
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -0700910 * Input: No data should be specified. get*Extra must have
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700911 * a {@link #EXTRA_INTENT} field containing the Intent being executed,
912 * and can optionally have a {@link #EXTRA_TITLE} field containing the
913 * title text to display in the chooser.
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -0700914 * <p>
915 * Output: Depends on the protocol of {@link #EXTRA_INTENT}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700916 */
917 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
918 public static final String ACTION_CHOOSER = "android.intent.action.CHOOSER";
919
920 /**
921 * Convenience function for creating a {@link #ACTION_CHOOSER} Intent.
922 *
Dianne Hackborne302a162012-05-15 14:58:32 -0700923 * <p>Builds a new {@link #ACTION_CHOOSER} Intent that wraps the given
924 * target intent, also optionally supplying a title. If the target
925 * intent has specified {@link #FLAG_GRANT_READ_URI_PERMISSION} or
926 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, then these flags will also be
927 * set in the returned chooser intent, with its ClipData set appropriately:
928 * either a direct reflection of {@link #getClipData()} if that is non-null,
John Spurlock33900182014-01-02 11:04:18 -0500929 * or a new ClipData built from {@link #getData()}.
Dianne Hackborne302a162012-05-15 14:58:32 -0700930 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700931 * @param target The Intent that the user will be selecting an activity
932 * to perform.
933 * @param title Optional title that will be displayed in the chooser.
934 * @return Return a new Intent object that you can hand to
935 * {@link Context#startActivity(Intent) Context.startActivity()} and
936 * related methods.
937 */
938 public static Intent createChooser(Intent target, CharSequence title) {
Adam Powell0b3c1122014-10-09 12:50:14 -0700939 return createChooser(target, title, null);
940 }
941
942 /**
943 * Convenience function for creating a {@link #ACTION_CHOOSER} Intent.
944 *
945 * <p>Builds a new {@link #ACTION_CHOOSER} Intent that wraps the given
946 * target intent, also optionally supplying a title. If the target
947 * intent has specified {@link #FLAG_GRANT_READ_URI_PERMISSION} or
948 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, then these flags will also be
949 * set in the returned chooser intent, with its ClipData set appropriately:
950 * either a direct reflection of {@link #getClipData()} if that is non-null,
951 * or a new ClipData built from {@link #getData()}.</p>
952 *
953 * <p>The caller may optionally supply an {@link IntentSender} to receive a callback
954 * when the user makes a choice. This can be useful if the calling application wants
955 * to remember the last chosen target and surface it as a more prominent or one-touch
956 * affordance elsewhere in the UI for next time.</p>
957 *
958 * @param target The Intent that the user will be selecting an activity
959 * to perform.
960 * @param title Optional title that will be displayed in the chooser.
961 * @param sender Optional IntentSender to be called when a choice is made.
962 * @return Return a new Intent object that you can hand to
963 * {@link Context#startActivity(Intent) Context.startActivity()} and
964 * related methods.
965 */
966 public static Intent createChooser(Intent target, CharSequence title, IntentSender sender) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700967 Intent intent = new Intent(ACTION_CHOOSER);
968 intent.putExtra(EXTRA_INTENT, target);
969 if (title != null) {
970 intent.putExtra(EXTRA_TITLE, title);
971 }
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -0700972
Adam Powell0b3c1122014-10-09 12:50:14 -0700973 if (sender != null) {
974 intent.putExtra(EXTRA_CHOSEN_COMPONENT_INTENT_SENDER, sender);
975 }
976
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -0700977 // Migrate any clip data and flags from target.
Jeff Sharkey846318a2014-04-04 12:12:41 -0700978 int permFlags = target.getFlags() & (FLAG_GRANT_READ_URI_PERMISSION
979 | FLAG_GRANT_WRITE_URI_PERMISSION | FLAG_GRANT_PERSISTABLE_URI_PERMISSION
980 | FLAG_GRANT_PREFIX_URI_PERMISSION);
Dianne Hackborne302a162012-05-15 14:58:32 -0700981 if (permFlags != 0) {
982 ClipData targetClipData = target.getClipData();
983 if (targetClipData == null && target.getData() != null) {
984 ClipData.Item item = new ClipData.Item(target.getData());
985 String[] mimeTypes;
986 if (target.getType() != null) {
987 mimeTypes = new String[] { target.getType() };
988 } else {
989 mimeTypes = new String[] { };
990 }
991 targetClipData = new ClipData(null, mimeTypes, item);
992 }
993 if (targetClipData != null) {
994 intent.setClipData(targetClipData);
995 intent.addFlags(permFlags);
996 }
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -0700997 }
Dianne Hackborne302a162012-05-15 14:58:32 -0700998
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700999 return intent;
1000 }
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07001001
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001002 /**
1003 * Activity Action: Allow the user to select a particular kind of data and
1004 * return it. This is different than {@link #ACTION_PICK} in that here we
1005 * just say what kind of data is desired, not a URI of existing data from
Dianne Hackbornfdb3f092013-01-28 15:10:48 -08001006 * which the user can pick. An ACTION_GET_CONTENT could allow the user to
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001007 * create the data as it runs (for example taking a picture or recording a
Ken Wakasaf76a50c2012-03-09 19:56:35 +09001008 * sound), let them browse over the web and download the desired data,
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001009 * etc.
1010 * <p>
Ken Wakasaf76a50c2012-03-09 19:56:35 +09001011 * 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 -07001012 * of data, such as a person contact, you set the MIME type to the kind of
1013 * data you want and launch it with {@link Context#startActivity(Intent)}.
1014 * The system will then launch the best application to select that kind
1015 * of data for you.
1016 * <p>
1017 * You may also be interested in any of a set of types of content the user
1018 * can pick. For example, an e-mail application that wants to allow the
1019 * user to add an attachment to an e-mail message can use this action to
1020 * bring up a list of all of the types of content the user can attach.
1021 * <p>
1022 * In this case, you should wrap the GET_CONTENT intent with a chooser
1023 * (through {@link #createChooser}), which will give the proper interface
1024 * for the user to pick how to send your data and allow you to specify
1025 * a prompt indicating what they are doing. You will usually specify a
1026 * broad MIME type (such as image/* or {@literal *}/*), resulting in a
1027 * broad range of content types the user can select from.
1028 * <p>
Ken Wakasaf76a50c2012-03-09 19:56:35 +09001029 * When using such a broad GET_CONTENT action, it is often desirable to
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001030 * only pick from data that can be represented as a stream. This is
1031 * accomplished by requiring the {@link #CATEGORY_OPENABLE} in the Intent.
1032 * <p>
Dianne Hackbornc4d0e6f2011-01-25 14:55:06 -08001033 * Callers can optionally specify {@link #EXTRA_LOCAL_ONLY} to request that
Ken Wakasaf76a50c2012-03-09 19:56:35 +09001034 * the launched content chooser only returns results representing data that
Dianne Hackbornc4d0e6f2011-01-25 14:55:06 -08001035 * is locally available on the device. For example, if this extra is set
1036 * to true then an image picker should not show any pictures that are available
1037 * from a remote server but not already on the local device (thus requiring
1038 * they be downloaded when opened).
1039 * <p>
Dianne Hackbornfdb3f092013-01-28 15:10:48 -08001040 * If the caller can handle multiple returned items (the user performing
1041 * multiple selection), then it can specify {@link #EXTRA_ALLOW_MULTIPLE}
1042 * to indicate this.
1043 * <p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001044 * Input: {@link #getType} is the desired MIME type to retrieve. Note
1045 * that no URI is supplied in the intent, as there are no constraints on
1046 * where the returned data originally comes from. You may also include the
1047 * {@link #CATEGORY_OPENABLE} if you can only accept data that can be
Dianne Hackbornc4d0e6f2011-01-25 14:55:06 -08001048 * opened as a stream. You may use {@link #EXTRA_LOCAL_ONLY} to limit content
Dianne Hackbornfdb3f092013-01-28 15:10:48 -08001049 * selection to local data. You may use {@link #EXTRA_ALLOW_MULTIPLE} to
1050 * allow the user to select multiple items.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001051 * <p>
1052 * Output: The URI of the item that was picked. This must be a content:
1053 * URI so that any receiver can access it.
1054 */
1055 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1056 public static final String ACTION_GET_CONTENT = "android.intent.action.GET_CONTENT";
1057 /**
1058 * Activity Action: Dial a number as specified by the data. This shows a
1059 * UI with the number being dialed, allowing the user to explicitly
1060 * initiate the call.
1061 * <p>Input: If nothing, an empty dialer is started; else {@link #getData}
1062 * is URI of a phone number to be dialed or a tel: URI of an explicit phone
1063 * number.
1064 * <p>Output: nothing.
1065 */
1066 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1067 public static final String ACTION_DIAL = "android.intent.action.DIAL";
1068 /**
1069 * Activity Action: Perform a call to someone specified by the data.
1070 * <p>Input: If nothing, an empty dialer is started; else {@link #getData}
1071 * is URI of a phone number to be dialed or a tel: URI of an explicit phone
1072 * number.
1073 * <p>Output: nothing.
1074 *
1075 * <p>Note: there will be restrictions on which applications can initiate a
1076 * call; most applications should use the {@link #ACTION_DIAL}.
1077 * <p>Note: this Intent <strong>cannot</strong> be used to call emergency
1078 * numbers. Applications can <strong>dial</strong> emergency numbers using
1079 * {@link #ACTION_DIAL}, however.
Svetoslav7008b512015-06-24 18:47:07 -07001080 *
Dianne Hackborn0e3de6c2015-07-29 15:20:21 -07001081 * <p>Note: if you app targets {@link android.os.Build.VERSION_CODES#M M}
Svetoslav7008b512015-06-24 18:47:07 -07001082 * and above and declares as using the {@link android.Manifest.permission#CALL_PHONE}
Svet Ganov7121e182015-07-13 22:38:12 -07001083 * permission which is not granted, then attempting to use this action will
Svetoslav7008b512015-06-24 18:47:07 -07001084 * result in a {@link java.lang.SecurityException}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001085 */
1086 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1087 public static final String ACTION_CALL = "android.intent.action.CALL";
1088 /**
1089 * Activity Action: Perform a call to an emergency number specified by the
1090 * data.
1091 * <p>Input: {@link #getData} is URI of a phone number to be dialed or a
1092 * tel: URI of an explicit phone number.
1093 * <p>Output: nothing.
1094 * @hide
1095 */
1096 public static final String ACTION_CALL_EMERGENCY = "android.intent.action.CALL_EMERGENCY";
1097 /**
1098 * Activity action: Perform a call to any number (emergency or not)
1099 * specified by the data.
1100 * <p>Input: {@link #getData} is URI of a phone number to be dialed or a
1101 * tel: URI of an explicit phone number.
1102 * <p>Output: nothing.
1103 * @hide
1104 */
1105 public static final String ACTION_CALL_PRIVILEGED = "android.intent.action.CALL_PRIVILEGED";
1106 /**
Santos Cordon15a13782015-03-31 18:32:31 -07001107 * Activity action: Activate the current SIM card. If SIM cards do not require activation,
1108 * sending this intent is a no-op.
1109 * <p>Input: No data should be specified. get*Extra may have an optional
1110 * {@link #EXTRA_SIM_ACTIVATION_RESPONSE} field containing a PendingIntent through which to
1111 * send the activation result.
1112 * <p>Output: nothing.
1113 * @hide
1114 */
1115 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1116 public static final String ACTION_SIM_ACTIVATION_REQUEST =
1117 "android.intent.action.SIM_ACTIVATION_REQUEST";
1118 /**
fionaxuadfe7002017-02-17 17:20:46 -08001119 * Activity Action: Main entry point for carrier setup apps.
1120 * <p>Carrier apps that provide an implementation for this action may be invoked to configure
1121 * carrier service and typically require
1122 * {@link android.telephony.TelephonyManager#hasCarrierPrivileges() carrier privileges} to
1123 * fulfill their duties.
1124 */
1125 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1126 public static final String ACTION_CARRIER_SETUP = "android.intent.action.CARRIER_SETUP";
1127 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001128 * Activity Action: Send a message to someone specified by the data.
1129 * <p>Input: {@link #getData} is URI describing the target.
1130 * <p>Output: nothing.
1131 */
1132 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1133 public static final String ACTION_SENDTO = "android.intent.action.SENDTO";
1134 /**
1135 * Activity Action: Deliver some data to someone else. Who the data is
1136 * being delivered to is not specified; it is up to the receiver of this
1137 * action to ask the user where the data should be sent.
1138 * <p>
1139 * When launching a SEND intent, you should usually wrap it in a chooser
1140 * (through {@link #createChooser}), which will give the proper interface
1141 * for the user to pick how to send your data and allow you to specify
1142 * a prompt indicating what they are doing.
1143 * <p>
1144 * Input: {@link #getType} is the MIME type of the data being sent.
1145 * get*Extra can have either a {@link #EXTRA_TEXT}
1146 * or {@link #EXTRA_STREAM} field, containing the data to be sent. If
1147 * using EXTRA_TEXT, the MIME type should be "text/plain"; otherwise it
1148 * should be the MIME type of the data in EXTRA_STREAM. Use {@literal *}/*
1149 * if the MIME type is unknown (this will only allow senders that can
Dianne Hackbornacb69bb2012-04-13 15:36:06 -07001150 * handle generic data streams). If using {@link #EXTRA_TEXT}, you can
1151 * also optionally supply {@link #EXTRA_HTML_TEXT} for clients to retrieve
1152 * your text with HTML formatting.
1153 * <p>
1154 * As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN}, the data
1155 * being sent can be supplied through {@link #setClipData(ClipData)}. This
1156 * allows you to use {@link #FLAG_GRANT_READ_URI_PERMISSION} when sharing
1157 * content: URIs and other advanced features of {@link ClipData}. If
1158 * using this approach, you still must supply the same data through the
1159 * {@link #EXTRA_TEXT} or {@link #EXTRA_STREAM} fields described below
1160 * for compatibility with old applications. If you don't set a ClipData,
1161 * it will be copied there for you when calling {@link Context#startActivity(Intent)}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001162 * <p>
Tomasz Mikolajewskid8a2e192016-12-15 16:10:46 +09001163 * Starting from {@link android.os.Build.VERSION_CODES#O}, if
1164 * {@link #CATEGORY_TYPED_OPENABLE} is passed, then the Uris passed in
1165 * either {@link #EXTRA_STREAM} or via {@link #setClipData(ClipData)} may
1166 * be openable only as asset typed files using
1167 * {@link ContentResolver#openTypedAssetFileDescriptor(Uri, String, Bundle)}.
1168 * <p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001169 * Optional standard extras, which may be interpreted by some recipients as
1170 * appropriate, are: {@link #EXTRA_EMAIL}, {@link #EXTRA_CC},
1171 * {@link #EXTRA_BCC}, {@link #EXTRA_SUBJECT}.
1172 * <p>
1173 * Output: nothing.
1174 */
1175 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1176 public static final String ACTION_SEND = "android.intent.action.SEND";
1177 /**
Wu-cheng Li649f99e2009-06-17 14:29:57 +08001178 * Activity Action: Deliver multiple data to someone else.
1179 * <p>
Dianne Hackbornacb69bb2012-04-13 15:36:06 -07001180 * Like {@link #ACTION_SEND}, except the data is multiple.
Wu-cheng Li649f99e2009-06-17 14:29:57 +08001181 * <p>
1182 * Input: {@link #getType} is the MIME type of the data being sent.
1183 * get*ArrayListExtra can have either a {@link #EXTRA_TEXT} or {@link
Dianne Hackbornacb69bb2012-04-13 15:36:06 -07001184 * #EXTRA_STREAM} field, containing the data to be sent. If using
1185 * {@link #EXTRA_TEXT}, you can also optionally supply {@link #EXTRA_HTML_TEXT}
1186 * for clients to retrieve your text with HTML formatting.
Wu-cheng Li649f99e2009-06-17 14:29:57 +08001187 * <p>
Chih-Chung Chang5962d272009-09-04 14:36:01 +08001188 * Multiple types are supported, and receivers should handle mixed types
1189 * whenever possible. The right way for the receiver to check them is to
1190 * use the content resolver on each URI. The intent sender should try to
1191 * put the most concrete mime type in the intent type, but it can fall
1192 * back to {@literal <type>/*} or {@literal *}/* as needed.
1193 * <p>
1194 * e.g. if you are sending image/jpg and image/jpg, the intent's type can
1195 * be image/jpg, but if you are sending image/jpg and image/png, then the
1196 * intent's type should be image/*.
1197 * <p>
Dianne Hackbornacb69bb2012-04-13 15:36:06 -07001198 * As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN}, the data
1199 * being sent can be supplied through {@link #setClipData(ClipData)}. This
1200 * allows you to use {@link #FLAG_GRANT_READ_URI_PERMISSION} when sharing
1201 * content: URIs and other advanced features of {@link ClipData}. If
1202 * using this approach, you still must supply the same data through the
1203 * {@link #EXTRA_TEXT} or {@link #EXTRA_STREAM} fields described below
1204 * for compatibility with old applications. If you don't set a ClipData,
1205 * it will be copied there for you when calling {@link Context#startActivity(Intent)}.
1206 * <p>
Tomasz Mikolajewskid8a2e192016-12-15 16:10:46 +09001207 * Starting from {@link android.os.Build.VERSION_CODES#O}, if
1208 * {@link #CATEGORY_TYPED_OPENABLE} is passed, then the Uris passed in
1209 * either {@link #EXTRA_STREAM} or via {@link #setClipData(ClipData)} may
1210 * be openable only as asset typed files using
1211 * {@link ContentResolver#openTypedAssetFileDescriptor(Uri, String, Bundle)}.
1212 * <p>
Wu-cheng Li649f99e2009-06-17 14:29:57 +08001213 * Optional standard extras, which may be interpreted by some recipients as
1214 * appropriate, are: {@link #EXTRA_EMAIL}, {@link #EXTRA_CC},
1215 * {@link #EXTRA_BCC}, {@link #EXTRA_SUBJECT}.
1216 * <p>
1217 * Output: nothing.
1218 */
1219 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1220 public static final String ACTION_SEND_MULTIPLE = "android.intent.action.SEND_MULTIPLE";
1221 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001222 * Activity Action: Handle an incoming phone call.
1223 * <p>Input: nothing.
1224 * <p>Output: nothing.
1225 */
1226 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1227 public static final String ACTION_ANSWER = "android.intent.action.ANSWER";
1228 /**
1229 * Activity Action: Insert an empty item into the given container.
1230 * <p>Input: {@link #getData} is URI of the directory (vnd.android.cursor.dir/*)
1231 * in which to place the data.
1232 * <p>Output: URI of the new data that was created.
1233 */
1234 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1235 public static final String ACTION_INSERT = "android.intent.action.INSERT";
1236 /**
Dianne Hackborn23fdaf62010-08-06 12:16:55 -07001237 * Activity Action: Create a new item in the given container, initializing it
1238 * from the current contents of the clipboard.
1239 * <p>Input: {@link #getData} is URI of the directory (vnd.android.cursor.dir/*)
1240 * in which to place the data.
1241 * <p>Output: URI of the new data that was created.
1242 */
1243 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1244 public static final String ACTION_PASTE = "android.intent.action.PASTE";
1245 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001246 * Activity Action: Delete the given data from its container.
1247 * <p>Input: {@link #getData} is URI of data to be deleted.
1248 * <p>Output: nothing.
1249 */
1250 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1251 public static final String ACTION_DELETE = "android.intent.action.DELETE";
1252 /**
1253 * Activity Action: Run the data, whatever that means.
1254 * <p>Input: ? (Note: this is currently specific to the test harness.)
1255 * <p>Output: nothing.
1256 */
1257 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1258 public static final String ACTION_RUN = "android.intent.action.RUN";
1259 /**
1260 * Activity Action: Perform a data synchronization.
1261 * <p>Input: ?
1262 * <p>Output: ?
1263 */
1264 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1265 public static final String ACTION_SYNC = "android.intent.action.SYNC";
1266 /**
1267 * Activity Action: Pick an activity given an intent, returning the class
1268 * selected.
1269 * <p>Input: get*Extra field {@link #EXTRA_INTENT} is an Intent
1270 * used with {@link PackageManager#queryIntentActivities} to determine the
1271 * set of activities from which to pick.
1272 * <p>Output: Class name of the activity that was selected.
1273 */
1274 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1275 public static final String ACTION_PICK_ACTIVITY = "android.intent.action.PICK_ACTIVITY";
1276 /**
1277 * Activity Action: Perform a search.
1278 * <p>Input: {@link android.app.SearchManager#QUERY getStringExtra(SearchManager.QUERY)}
1279 * is the text to search for. If empty, simply
1280 * enter your search results Activity with the search UI activated.
1281 * <p>Output: nothing.
1282 */
1283 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1284 public static final String ACTION_SEARCH = "android.intent.action.SEARCH";
1285 /**
Jim Miller7e4ad352009-03-25 18:16:41 -07001286 * Activity Action: Start the platform-defined tutorial
1287 * <p>Input: {@link android.app.SearchManager#QUERY getStringExtra(SearchManager.QUERY)}
1288 * is the text to search for. If empty, simply
1289 * enter your search results Activity with the search UI activated.
1290 * <p>Output: nothing.
1291 */
1292 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1293 public static final String ACTION_SYSTEM_TUTORIAL = "android.intent.action.SYSTEM_TUTORIAL";
1294 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001295 * Activity Action: Perform a web search.
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08001296 * <p>
1297 * Input: {@link android.app.SearchManager#QUERY
1298 * getStringExtra(SearchManager.QUERY)} is the text to search for. If it is
1299 * a url starts with http or https, the site will be opened. If it is plain
1300 * text, Google search will be applied.
1301 * <p>
1302 * Output: nothing.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001303 */
1304 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1305 public static final String ACTION_WEB_SEARCH = "android.intent.action.WEB_SEARCH";
Dianne Hackbornf9c5e0f2013-01-23 14:39:13 -08001306
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001307 /**
Jim Miller07994402012-05-02 14:22:27 -07001308 * Activity Action: Perform assist action.
1309 * <p>
Adam Skory7140a252013-09-11 12:04:58 +01001310 * Input: {@link #EXTRA_ASSIST_PACKAGE}, {@link #EXTRA_ASSIST_CONTEXT}, can provide
1311 * additional optional contextual information about where the user was when they
Dianne Hackborna3acdb32015-06-08 17:07:40 -07001312 * requested the assist; {@link #EXTRA_REFERRER} may be set with additional referrer
1313 * information.
Jim Miller07994402012-05-02 14:22:27 -07001314 * Output: nothing.
1315 */
1316 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1317 public static final String ACTION_ASSIST = "android.intent.action.ASSIST";
Dianne Hackbornf9c5e0f2013-01-23 14:39:13 -08001318
1319 /**
Bjorn Bringertbc086862013-03-01 12:59:24 +00001320 * Activity Action: Perform voice assist action.
1321 * <p>
Adam Skory7140a252013-09-11 12:04:58 +01001322 * Input: {@link #EXTRA_ASSIST_PACKAGE}, {@link #EXTRA_ASSIST_CONTEXT}, can provide
1323 * additional optional contextual information about where the user was when they
Adam Skorydfc7fd72013-08-05 19:23:41 -07001324 * requested the voice assist.
Bjorn Bringertbc086862013-03-01 12:59:24 +00001325 * Output: nothing.
Adam Skory7140a252013-09-11 12:04:58 +01001326 * @hide
Bjorn Bringertbc086862013-03-01 12:59:24 +00001327 */
Amith Yamasani16452032017-03-03 10:15:57 -08001328 @SystemApi
Bjorn Bringertbc086862013-03-01 12:59:24 +00001329 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1330 public static final String ACTION_VOICE_ASSIST = "android.intent.action.VOICE_ASSIST";
1331
1332 /**
Adam Skory7140a252013-09-11 12:04:58 +01001333 * An optional field on {@link #ACTION_ASSIST} containing the name of the current foreground
1334 * application package at the time the assist was invoked.
Dianne Hackbornf9c5e0f2013-01-23 14:39:13 -08001335 */
1336 public static final String EXTRA_ASSIST_PACKAGE
1337 = "android.intent.extra.ASSIST_PACKAGE";
1338
1339 /**
Dianne Hackborna83ce1d2015-03-11 15:16:13 -07001340 * An optional field on {@link #ACTION_ASSIST} containing the uid of the current foreground
1341 * application package at the time the assist was invoked.
1342 */
1343 public static final String EXTRA_ASSIST_UID
1344 = "android.intent.extra.ASSIST_UID";
1345
1346 /**
Adam Skory7140a252013-09-11 12:04:58 +01001347 * An optional field on {@link #ACTION_ASSIST} and containing additional contextual
1348 * information supplied by the current foreground app at the time of the assist request.
1349 * This is a {@link Bundle} of additional data.
Dianne Hackbornf9c5e0f2013-01-23 14:39:13 -08001350 */
1351 public static final String EXTRA_ASSIST_CONTEXT
1352 = "android.intent.extra.ASSIST_CONTEXT";
1353
Jim Miller07994402012-05-02 14:22:27 -07001354 /**
Michael Wright8ab940a2014-09-01 11:01:27 -07001355 * An optional field on {@link #ACTION_ASSIST} suggesting that the user will likely use a
1356 * keyboard as the primary input device for assistance.
1357 */
1358 public static final String EXTRA_ASSIST_INPUT_HINT_KEYBOARD =
1359 "android.intent.extra.ASSIST_INPUT_HINT_KEYBOARD";
1360
1361 /**
Tim Kilbourn0e5f1102015-06-05 16:18:09 -07001362 * An optional field on {@link #ACTION_ASSIST} containing the InputDevice id
1363 * that was used to invoke the assist.
1364 */
1365 public static final String EXTRA_ASSIST_INPUT_DEVICE_ID =
1366 "android.intent.extra.ASSIST_INPUT_DEVICE_ID";
1367
1368 /**
Trevor Johns682c24e2016-04-12 10:13:47 -07001369 * Activity Action: List all available applications.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001370 * <p>Input: Nothing.
1371 * <p>Output: nothing.
1372 */
1373 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1374 public static final String ACTION_ALL_APPS = "android.intent.action.ALL_APPS";
1375 /**
Trevor Johns682c24e2016-04-12 10:13:47 -07001376 * Activity Action: Show settings for choosing wallpaper.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001377 * <p>Input: Nothing.
1378 * <p>Output: Nothing.
1379 */
1380 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1381 public static final String ACTION_SET_WALLPAPER = "android.intent.action.SET_WALLPAPER";
1382
1383 /**
1384 * Activity Action: Show activity for reporting a bug.
1385 * <p>Input: Nothing.
1386 * <p>Output: Nothing.
1387 */
1388 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1389 public static final String ACTION_BUG_REPORT = "android.intent.action.BUG_REPORT";
1390
1391 /**
1392 * Activity Action: Main entry point for factory tests. Only used when
1393 * the device is booting in factory test node. The implementing package
1394 * must be installed in the system image.
1395 * <p>Input: nothing
1396 * <p>Output: nothing
1397 */
1398 public static final String ACTION_FACTORY_TEST = "android.intent.action.FACTORY_TEST";
1399
1400 /**
1401 * Activity Action: The user pressed the "call" button to go to the dialer
1402 * or other appropriate UI for placing a call.
1403 * <p>Input: Nothing.
1404 * <p>Output: Nothing.
1405 */
1406 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1407 public static final String ACTION_CALL_BUTTON = "android.intent.action.CALL_BUTTON";
1408
1409 /**
1410 * Activity Action: Start Voice Command.
1411 * <p>Input: Nothing.
1412 * <p>Output: Nothing.
1413 */
1414 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1415 public static final String ACTION_VOICE_COMMAND = "android.intent.action.VOICE_COMMAND";
The Android Open Source Projectba87e3e2009-03-13 13:04:22 -07001416
1417 /**
1418 * Activity Action: Start action associated with long pressing on the
1419 * search key.
1420 * <p>Input: Nothing.
1421 * <p>Output: Nothing.
1422 */
1423 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1424 public static final String ACTION_SEARCH_LONG_PRESS = "android.intent.action.SEARCH_LONG_PRESS";
The Android Open Source Project10592532009-03-18 17:39:46 -07001425
Jacek Surazski86b6c532009-05-13 14:38:28 +02001426 /**
1427 * Activity Action: The user pressed the "Report" button in the crash/ANR dialog.
1428 * This intent is delivered to the package which installed the application, usually
Dirk Dougherty4d7bc6552012-01-27 17:56:49 -08001429 * Google Play.
Jacek Surazski86b6c532009-05-13 14:38:28 +02001430 * <p>Input: No data is specified. The bug report is passed in using
1431 * an {@link #EXTRA_BUG_REPORT} field.
1432 * <p>Output: Nothing.
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001433 *
1434 * @see #EXTRA_BUG_REPORT
Jacek Surazski86b6c532009-05-13 14:38:28 +02001435 */
1436 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1437 public static final String ACTION_APP_ERROR = "android.intent.action.APP_ERROR";
Dianne Hackborn3d74bb42009-06-19 10:35:21 -07001438
1439 /**
1440 * Activity Action: Show power usage information to the user.
1441 * <p>Input: Nothing.
1442 * <p>Output: Nothing.
1443 */
1444 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1445 public static final String ACTION_POWER_USAGE_SUMMARY = "android.intent.action.POWER_USAGE_SUMMARY";
Tom Taylord4a47292009-12-21 13:59:18 -08001446
Dianne Hackbornd7cd29d2009-07-01 11:22:45 -07001447 /**
1448 * Activity Action: Setup wizard to launch after a platform update. This
1449 * activity should have a string meta-data field associated with it,
1450 * {@link #METADATA_SETUP_VERSION}, which defines the current version of
1451 * the platform for setup. The activity will be launched only if
1452 * {@link android.provider.Settings.Secure#LAST_SETUP_SHOWN} is not the
1453 * same value.
1454 * <p>Input: Nothing.
1455 * <p>Output: Nothing.
1456 * @hide
1457 */
1458 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1459 public static final String ACTION_UPGRADE_SETUP = "android.intent.action.UPGRADE_SETUP";
Tom Taylord4a47292009-12-21 13:59:18 -08001460
Dianne Hackbornd7cd29d2009-07-01 11:22:45 -07001461 /**
Clara Bayarrieb3c2d32016-04-01 14:37:32 +01001462 * Activity Action: Start the Keyboard Shortcuts Helper screen.
1463 * <p>Input: Nothing.
1464 * <p>Output: Nothing.
1465 * @hide
1466 */
1467 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1468 public static final String ACTION_SHOW_KEYBOARD_SHORTCUTS =
Clara Bayarri847d8682017-03-06 16:48:44 +00001469 "com.android.intent.action.SHOW_KEYBOARD_SHORTCUTS";
Clara Bayarrieb3c2d32016-04-01 14:37:32 +01001470
1471 /**
Andrei Stingaceanu0bf096f2016-04-14 18:11:57 +01001472 * Activity Action: Dismiss the Keyboard Shortcuts Helper screen.
1473 * <p>Input: Nothing.
1474 * <p>Output: Nothing.
1475 * @hide
1476 */
1477 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1478 public static final String ACTION_DISMISS_KEYBOARD_SHORTCUTS =
Clara Bayarri847d8682017-03-06 16:48:44 +00001479 "com.android.intent.action.DISMISS_KEYBOARD_SHORTCUTS";
Andrei Stingaceanu0bf096f2016-04-14 18:11:57 +01001480
1481 /**
Jeff Sharkey7f868272011-06-05 16:05:02 -07001482 * Activity Action: Show settings for managing network data usage of a
1483 * specific application. Applications should define an activity that offers
1484 * options to control data usage.
1485 */
1486 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1487 public static final String ACTION_MANAGE_NETWORK_USAGE =
1488 "android.intent.action.MANAGE_NETWORK_USAGE";
1489
1490 /**
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001491 * Activity Action: Launch application installer.
1492 * <p>
Todd Kennedy9cc589a2016-08-18 16:23:17 -07001493 * Input: The data must be a content: URI at which the application
Dianne Hackborneba784ff2012-09-19 12:42:37 -07001494 * can be retrieved. As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN_MR1},
1495 * you can also use "package:<package-name>" to install an application for the
1496 * current user that is already installed for another user. You can optionally supply
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001497 * {@link #EXTRA_INSTALLER_PACKAGE_NAME}, {@link #EXTRA_NOT_UNKNOWN_SOURCE},
1498 * {@link #EXTRA_ALLOW_REPLACE}, and {@link #EXTRA_RETURN_RESULT}.
1499 * <p>
1500 * Output: If {@link #EXTRA_RETURN_RESULT}, returns whether the install
1501 * succeeded.
Svet Ganov86877e42015-05-28 08:19:48 -07001502 * <p>
1503 * <strong>Note:</strong>If your app is targeting API level higher than 22 you
1504 * need to hold {@link android.Manifest.permission#REQUEST_INSTALL_PACKAGES}
1505 * in order to launch the application installer.
1506 * </p>
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001507 *
1508 * @see #EXTRA_INSTALLER_PACKAGE_NAME
1509 * @see #EXTRA_NOT_UNKNOWN_SOURCE
1510 * @see #EXTRA_RETURN_RESULT
1511 */
1512 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1513 public static final String ACTION_INSTALL_PACKAGE = "android.intent.action.INSTALL_PACKAGE";
1514
1515 /**
Todd Kennedyb8a279e2015-11-18 09:59:47 -08001516 * Activity Action: Launch ephemeral installer.
1517 * <p>
1518 * Input: The data must be a http: URI that the ephemeral application is registered
1519 * to handle.
1520 * <p class="note">
1521 * This is a protected intent that can only be sent by the system.
1522 * </p>
1523 *
1524 * @hide
1525 */
Todd Kennedyb8a279e2015-11-18 09:59:47 -08001526 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1527 public static final String ACTION_INSTALL_EPHEMERAL_PACKAGE
1528 = "android.intent.action.INSTALL_EPHEMERAL_PACKAGE";
1529
1530 /**
1531 * Service Action: Resolve ephemeral application.
1532 * <p>
1533 * The system will have a persistent connection to this service.
1534 * This is a protected intent that can only be sent by the system.
1535 * </p>
1536 *
1537 * @hide
1538 */
Todd Kennedyb8a279e2015-11-18 09:59:47 -08001539 @SdkConstant(SdkConstantType.SERVICE_ACTION)
1540 public static final String ACTION_RESOLVE_EPHEMERAL_PACKAGE
1541 = "android.intent.action.RESOLVE_EPHEMERAL_PACKAGE";
1542
1543 /**
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001544 * Used as a string extra field with {@link #ACTION_INSTALL_PACKAGE} to install a
1545 * package. Specifies the installer package name; this package will receive the
1546 * {@link #ACTION_APP_ERROR} intent.
1547 */
1548 public static final String EXTRA_INSTALLER_PACKAGE_NAME
1549 = "android.intent.extra.INSTALLER_PACKAGE_NAME";
1550
1551 /**
1552 * Used as a boolean extra field with {@link #ACTION_INSTALL_PACKAGE} to install a
1553 * package. Specifies that the application being installed should not be
1554 * treated as coming from an unknown source, but as coming from the app
1555 * invoking the Intent. For this to work you must start the installer with
1556 * startActivityForResult().
1557 */
1558 public static final String EXTRA_NOT_UNKNOWN_SOURCE
1559 = "android.intent.extra.NOT_UNKNOWN_SOURCE";
1560
1561 /**
rich cannings706e8ba2012-08-20 13:20:14 -07001562 * Used as a URI extra field with {@link #ACTION_INSTALL_PACKAGE} and
1563 * {@link #ACTION_VIEW} to indicate the URI from which the local APK in the Intent
rich cannings368ed012012-06-07 15:37:57 -07001564 * data field originated from.
1565 */
rich cannings706e8ba2012-08-20 13:20:14 -07001566 public static final String EXTRA_ORIGINATING_URI
1567 = "android.intent.extra.ORIGINATING_URI";
rich cannings368ed012012-06-07 15:37:57 -07001568
1569 /**
Dianne Hackborn85d558c2014-11-04 10:31:54 -08001570 * This extra can be used with any Intent used to launch an activity, supplying information
1571 * about who is launching that activity. This field contains a {@link android.net.Uri}
1572 * object, typically an http: or https: URI of the web site that the referral came from;
1573 * it can also use the {@link #URI_ANDROID_APP_SCHEME android-app:} scheme to identify
1574 * a native application that it came from.
1575 *
1576 * <p>To retrieve this value in a client, use {@link android.app.Activity#getReferrer}
1577 * instead of directly retrieving the extra. It is also valid for applications to
1578 * instead supply {@link #EXTRA_REFERRER_NAME} for cases where they can only create
1579 * a string, not a Uri; the field here, if supplied, will always take precedence,
1580 * however.</p>
1581 *
1582 * @see #EXTRA_REFERRER_NAME
rich cannings368ed012012-06-07 15:37:57 -07001583 */
1584 public static final String EXTRA_REFERRER
1585 = "android.intent.extra.REFERRER";
1586
1587 /**
Dianne Hackborn85d558c2014-11-04 10:31:54 -08001588 * Alternate version of {@link #EXTRA_REFERRER} that supplies the URI as a String rather
1589 * than a {@link android.net.Uri} object. Only for use in cases where Uri objects can
1590 * not be created, in particular when Intent extras are supplied through the
1591 * {@link #URI_INTENT_SCHEME intent:} or {@link #URI_ANDROID_APP_SCHEME android-app:}
1592 * schemes.
1593 *
1594 * @see #EXTRA_REFERRER
1595 */
1596 public static final String EXTRA_REFERRER_NAME
1597 = "android.intent.extra.REFERRER_NAME";
1598
1599 /**
Ben Gruver37d83a32012-09-27 13:02:06 -07001600 * Used as an int extra field with {@link #ACTION_INSTALL_PACKAGE} and
Gina Dimino98ad8882016-05-31 17:25:48 -07001601 * {@link #ACTION_VIEW} to indicate the uid of the package that initiated the install
Ben Gruver37d83a32012-09-27 13:02:06 -07001602 * @hide
1603 */
Svet Ganovae0e03a2016-02-25 18:22:10 -08001604 @SystemApi
Ben Gruver37d83a32012-09-27 13:02:06 -07001605 public static final String EXTRA_ORIGINATING_UID
1606 = "android.intent.extra.ORIGINATING_UID";
1607
1608 /**
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001609 * Used as a boolean extra field with {@link #ACTION_INSTALL_PACKAGE} to install a
1610 * package. Tells the installer UI to skip the confirmation with the user
1611 * if the .apk is replacing an existing one.
Dianne Hackborn0e128bb2012-05-01 14:40:15 -07001612 * @deprecated As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN}, Android
1613 * will no longer show an interstitial message about updating existing
1614 * applications so this is no longer needed.
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001615 */
Dianne Hackborn0e128bb2012-05-01 14:40:15 -07001616 @Deprecated
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001617 public static final String EXTRA_ALLOW_REPLACE
1618 = "android.intent.extra.ALLOW_REPLACE";
1619
1620 /**
1621 * Used as a boolean extra field with {@link #ACTION_INSTALL_PACKAGE} or
1622 * {@link #ACTION_UNINSTALL_PACKAGE}. Specifies that the installer UI should
1623 * return to the application the result code of the install/uninstall. The returned result
1624 * code will be {@link android.app.Activity#RESULT_OK} on success or
1625 * {@link android.app.Activity#RESULT_FIRST_USER} on failure.
1626 */
1627 public static final String EXTRA_RETURN_RESULT
1628 = "android.intent.extra.RETURN_RESULT";
1629
1630 /**
1631 * Package manager install result code. @hide because result codes are not
1632 * yet ready to be exposed.
1633 */
1634 public static final String EXTRA_INSTALL_RESULT
1635 = "android.intent.extra.INSTALL_RESULT";
1636
1637 /**
1638 * Activity Action: Launch application uninstaller.
1639 * <p>
1640 * Input: The data must be a package: URI whose scheme specific part is
1641 * the package name of the current installed package to be uninstalled.
1642 * You can optionally supply {@link #EXTRA_RETURN_RESULT}.
1643 * <p>
1644 * Output: If {@link #EXTRA_RETURN_RESULT}, returns whether the install
1645 * succeeded.
1646 */
1647 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1648 public static final String ACTION_UNINSTALL_PACKAGE = "android.intent.action.UNINSTALL_PACKAGE";
1649
1650 /**
msnider3c191b82017-01-23 14:23:16 -08001651 * Activity Action: Launch application uninstaller.
1652 * <p>
1653 * Input: The data must be a package: URI whose scheme specific part is
1654 * the package name of the current installed package to be uninstalled.
1655 * You can optionally supply {@link #EXTRA_RETURN_RESULT}.
1656 * <p>
1657 * Output: Nothing.
1658 * </p>
1659 */
1660 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1661 public static final String ACTION_CLEAR_PACKAGE = "android.intent.action.CLEAR_PACKAGE";
1662
1663 /**
Dianne Hackborn6d235d82012-09-16 18:25:40 -07001664 * Specify whether the package should be uninstalled for all users.
1665 * @hide because these should not be part of normal application flow.
1666 */
1667 public static final String EXTRA_UNINSTALL_ALL_USERS
1668 = "android.intent.extra.UNINSTALL_ALL_USERS";
1669
1670 /**
Dianne Hackbornd7cd29d2009-07-01 11:22:45 -07001671 * A string associated with a {@link #ACTION_UPGRADE_SETUP} activity
1672 * describing the last run version of the platform that was setup.
1673 * @hide
1674 */
1675 public static final String METADATA_SETUP_VERSION = "android.SETUP_VERSION";
1676
Svet Ganov3695b8a2015-03-24 16:30:25 -07001677 /**
1678 * Activity action: Launch UI to manage the permissions of an app.
1679 * <p>
1680 * Input: {@link #EXTRA_PACKAGE_NAME} specifies the package whose permissions
1681 * will be managed by the launched UI.
1682 * </p>
1683 * <p>
1684 * Output: Nothing.
1685 * </p>
1686 *
1687 * @see #EXTRA_PACKAGE_NAME
1688 *
1689 * @hide
1690 */
Svet Ganovae0e03a2016-02-25 18:22:10 -08001691 @SystemApi
Svet Ganov3695b8a2015-03-24 16:30:25 -07001692 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1693 public static final String ACTION_MANAGE_APP_PERMISSIONS =
1694 "android.intent.action.MANAGE_APP_PERMISSIONS";
1695
1696 /**
Svet Ganov321f0152015-05-16 22:51:50 -07001697 * Activity action: Launch UI to manage permissions.
1698 * <p>
1699 * Input: Nothing.
1700 * </p>
1701 * <p>
1702 * Output: Nothing.
1703 * </p>
1704 *
1705 * @hide
1706 */
Svet Ganovae0e03a2016-02-25 18:22:10 -08001707 @SystemApi
Svet Ganov321f0152015-05-16 22:51:50 -07001708 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1709 public static final String ACTION_MANAGE_PERMISSIONS =
1710 "android.intent.action.MANAGE_PERMISSIONS";
1711
1712 /**
Svet Ganov9c165d72015-12-01 19:52:26 -08001713 * Activity action: Launch UI to review permissions for an app.
1714 * The system uses this intent if permission review for apps not
1715 * supporting the new runtime permissions model is enabled. In
1716 * this mode a permission review is required before any of the
1717 * app components can run.
1718 * <p>
1719 * Input: {@link #EXTRA_PACKAGE_NAME} specifies the package whose
1720 * permissions will be reviewed (mandatory).
1721 * </p>
1722 * <p>
1723 * Input: {@link #EXTRA_INTENT} specifies a pending intent to
1724 * be fired after the permission review (optional).
1725 * </p>
1726 * <p>
1727 * Input: {@link #EXTRA_REMOTE_CALLBACK} specifies a callback to
1728 * be invoked after the permission review (optional).
1729 * </p>
1730 * <p>
1731 * Input: {@link #EXTRA_RESULT_NEEDED} specifies whether the intent
1732 * passed via {@link #EXTRA_INTENT} needs a result (optional).
1733 * </p>
1734 * <p>
1735 * Output: Nothing.
1736 * </p>
1737 *
1738 * @see #EXTRA_PACKAGE_NAME
1739 * @see #EXTRA_INTENT
1740 * @see #EXTRA_REMOTE_CALLBACK
1741 * @see #EXTRA_RESULT_NEEDED
1742 *
1743 * @hide
1744 */
Svet Ganovae0e03a2016-02-25 18:22:10 -08001745 @SystemApi
Svet Ganov9c165d72015-12-01 19:52:26 -08001746 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1747 public static final String ACTION_REVIEW_PERMISSIONS =
1748 "android.intent.action.REVIEW_PERMISSIONS";
1749
1750 /**
1751 * Intent extra: A callback for reporting remote result as a bundle.
1752 * <p>
1753 * Type: IRemoteCallback
1754 * </p>
1755 *
1756 * @hide
1757 */
Svet Ganovae0e03a2016-02-25 18:22:10 -08001758 @SystemApi
Svet Ganov9c165d72015-12-01 19:52:26 -08001759 public static final String EXTRA_REMOTE_CALLBACK = "android.intent.extra.REMOTE_CALLBACK";
1760
1761 /**
Svet Ganov3695b8a2015-03-24 16:30:25 -07001762 * Intent extra: An app package name.
1763 * <p>
1764 * Type: String
Svet Ganov0b316702015-05-23 13:25:11 -07001765 * </p>
Svet Ganov3695b8a2015-03-24 16:30:25 -07001766 *
Svet Ganov3695b8a2015-03-24 16:30:25 -07001767 */
Svet Ganov3695b8a2015-03-24 16:30:25 -07001768 public static final String EXTRA_PACKAGE_NAME = "android.intent.extra.PACKAGE_NAME";
1769
1770 /**
Todd Kennedye5195dd2016-10-19 15:29:19 -07001771 * Intent extra: An app split name.
1772 * <p>
1773 * Type: String
1774 * </p>
1775 * @hide
1776 */
1777 @SystemApi
1778 public static final String EXTRA_SPLIT_NAME = "android.intent.extra.SPLIT_NAME";
1779
1780 /**
Svet Ganov9c165d72015-12-01 19:52:26 -08001781 * Intent extra: An extra for specifying whether a result is needed.
1782 * <p>
1783 * Type: boolean
1784 * </p>
1785 *
1786 * @hide
1787 */
Svet Ganovae0e03a2016-02-25 18:22:10 -08001788 @SystemApi
Svet Ganov9c165d72015-12-01 19:52:26 -08001789 public static final String EXTRA_RESULT_NEEDED = "android.intent.extra.RESULT_NEEDED";
1790
1791 /**
Svet Ganov3695b8a2015-03-24 16:30:25 -07001792 * Activity action: Launch UI to manage which apps have a given permission.
1793 * <p>
1794 * Input: {@link #EXTRA_PERMISSION_NAME} specifies the permission access
1795 * to which will be managed by the launched UI.
1796 * </p>
1797 * <p>
1798 * Output: Nothing.
1799 * </p>
1800 *
1801 * @see #EXTRA_PERMISSION_NAME
1802 *
1803 * @hide
1804 */
Svet Ganovae0e03a2016-02-25 18:22:10 -08001805 @SystemApi
Svet Ganov3695b8a2015-03-24 16:30:25 -07001806 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1807 public static final String ACTION_MANAGE_PERMISSION_APPS =
1808 "android.intent.action.MANAGE_PERMISSION_APPS";
1809
1810 /**
1811 * Intent extra: The name of a permission.
1812 * <p>
1813 * Type: String
1814 * </p>
1815 *
1816 * @hide
1817 */
1818 @SystemApi
1819 public static final String EXTRA_PERMISSION_NAME = "android.intent.extra.PERMISSION_NAME";
1820
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001821 // ---------------------------------------------------------------------
1822 // ---------------------------------------------------------------------
1823 // Standard intent broadcast actions (see action variable).
1824
1825 /**
Jeff Brown037c33e2014-04-09 00:31:55 -07001826 * Broadcast Action: Sent when the device goes to sleep and becomes non-interactive.
1827 * <p>
1828 * For historical reasons, the name of this broadcast action refers to the power
1829 * state of the screen but it is actually sent in response to changes in the
1830 * overall interactive state of the device.
1831 * </p><p>
1832 * This broadcast is sent when the device becomes non-interactive which may have
1833 * nothing to do with the screen turning off. To determine the
1834 * actual state of the screen, use {@link android.view.Display#getState}.
1835 * </p><p>
1836 * See {@link android.os.PowerManager#isInteractive} for details.
1837 * </p>
Casey Hodbf6785c2015-03-17 15:59:39 -07001838 * You <em>cannot</em> receive this through components declared in
1839 * manifests, only by explicitly registering for it with
1840 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
1841 * Context.registerReceiver()}.
Tom Taylord4a47292009-12-21 13:59:18 -08001842 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001843 * <p class="note">This is a protected intent that can only be sent
1844 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001845 */
1846 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1847 public static final String ACTION_SCREEN_OFF = "android.intent.action.SCREEN_OFF";
Jeff Brown037c33e2014-04-09 00:31:55 -07001848
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001849 /**
Jeff Brown037c33e2014-04-09 00:31:55 -07001850 * Broadcast Action: Sent when the device wakes up and becomes interactive.
1851 * <p>
1852 * For historical reasons, the name of this broadcast action refers to the power
1853 * state of the screen but it is actually sent in response to changes in the
1854 * overall interactive state of the device.
1855 * </p><p>
1856 * This broadcast is sent when the device becomes interactive which may have
1857 * nothing to do with the screen turning on. To determine the
1858 * actual state of the screen, use {@link android.view.Display#getState}.
1859 * </p><p>
1860 * See {@link android.os.PowerManager#isInteractive} for details.
1861 * </p>
Casey Hodbf6785c2015-03-17 15:59:39 -07001862 * You <em>cannot</em> receive this through components declared in
1863 * manifests, only by explicitly registering for it with
1864 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
1865 * Context.registerReceiver()}.
Tom Taylord4a47292009-12-21 13:59:18 -08001866 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001867 * <p class="note">This is a protected intent that can only be sent
1868 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001869 */
1870 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1871 public static final String ACTION_SCREEN_ON = "android.intent.action.SCREEN_ON";
The Android Open Source Projectb2a3dd82009-03-09 11:52:12 -07001872
1873 /**
Dianne Hackbornbe87e2f2012-09-28 16:31:34 -07001874 * Broadcast Action: Sent after the system stops dreaming.
1875 *
1876 * <p class="note">This is a protected intent that can only be sent by the system.
1877 * It is only sent to registered receivers.</p>
1878 */
1879 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1880 public static final String ACTION_DREAMING_STOPPED = "android.intent.action.DREAMING_STOPPED";
1881
1882 /**
1883 * Broadcast Action: Sent after the system starts dreaming.
1884 *
1885 * <p class="note">This is a protected intent that can only be sent by the system.
1886 * It is only sent to registered receivers.</p>
1887 */
1888 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1889 public static final String ACTION_DREAMING_STARTED = "android.intent.action.DREAMING_STARTED";
1890
1891 /**
The Android Open Source Project10592532009-03-18 17:39:46 -07001892 * 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 -07001893 * keyguard is gone).
Tom Taylord4a47292009-12-21 13:59:18 -08001894 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001895 * <p class="note">This is a protected intent that can only be sent
1896 * by the system.
The Android Open Source Projectb2a3dd82009-03-09 11:52:12 -07001897 */
1898 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Dianne Hackborn1c633fc2009-12-08 19:45:14 -08001899 public static final String ACTION_USER_PRESENT = "android.intent.action.USER_PRESENT";
The Android Open Source Projectb2a3dd82009-03-09 11:52:12 -07001900
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001901 /**
1902 * Broadcast Action: The current time has changed. Sent every
Casey Hodbf6785c2015-03-17 15:59:39 -07001903 * minute. You <em>cannot</em> receive this through components declared
John Spurlock6098c5d2013-06-17 10:32:46 -04001904 * in manifests, only by explicitly registering for it with
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001905 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
1906 * Context.registerReceiver()}.
Tom Taylord4a47292009-12-21 13:59:18 -08001907 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001908 * <p class="note">This is a protected intent that can only be sent
1909 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001910 */
1911 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1912 public static final String ACTION_TIME_TICK = "android.intent.action.TIME_TICK";
1913 /**
1914 * Broadcast Action: The time was set.
1915 */
1916 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1917 public static final String ACTION_TIME_CHANGED = "android.intent.action.TIME_SET";
1918 /**
1919 * Broadcast Action: The date has changed.
1920 */
1921 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1922 public static final String ACTION_DATE_CHANGED = "android.intent.action.DATE_CHANGED";
1923 /**
1924 * Broadcast Action: The timezone has changed. The intent will have the following extra values:</p>
1925 * <ul>
1926 * <li><em>time-zone</em> - The java.util.TimeZone.getID() value identifying the new time zone.</li>
1927 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08001928 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001929 * <p class="note">This is a protected intent that can only be sent
1930 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001931 */
1932 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1933 public static final String ACTION_TIMEZONE_CHANGED = "android.intent.action.TIMEZONE_CHANGED";
1934 /**
Robert Greenwalt03595d02010-11-02 14:08:23 -07001935 * Clear DNS Cache Action: This is broadcast when networks have changed and old
1936 * DNS entries should be tossed.
1937 * @hide
1938 */
1939 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1940 public static final String ACTION_CLEAR_DNS_CACHE = "android.intent.action.CLEAR_DNS_CACHE";
1941 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001942 * Alarm Changed Action: This is broadcast when the AlarmClock
1943 * application's alarm is set or unset. It is used by the
1944 * AlarmClock application and the StatusBar service.
1945 * @hide
1946 */
1947 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1948 public static final String ACTION_ALARM_CHANGED = "android.intent.action.ALARM_CHANGED";
Jeff Sharkeybedbaa92015-12-02 16:42:25 -07001949
1950 /**
Jeff Sharkeycf3f0a12016-03-17 19:57:58 -06001951 * Broadcast Action: This is broadcast once, after the user has finished
1952 * booting, but while still in the "locked" state. It can be used to perform
1953 * application-specific initialization, such as installing alarms. You must
1954 * hold the {@link android.Manifest.permission#RECEIVE_BOOT_COMPLETED}
1955 * permission in order to receive this broadcast.
Jeff Sharkeybedbaa92015-12-02 16:42:25 -07001956 * <p>
Jeff Sharkeycf3f0a12016-03-17 19:57:58 -06001957 * This broadcast is sent immediately at boot by all devices (regardless of
1958 * direct boot support) running {@link android.os.Build.VERSION_CODES#N} or
1959 * higher. Upon receipt of this broadcast, the user is still locked and only
1960 * device-protected storage can be accessed safely. If you want to access
1961 * credential-protected storage, you need to wait for the user to be
1962 * unlocked (typically by entering their lock pattern or PIN for the first
1963 * time), after which the {@link #ACTION_USER_UNLOCKED} and
1964 * {@link #ACTION_BOOT_COMPLETED} broadcasts are sent.
1965 * <p>
1966 * To receive this broadcast, your receiver component must be marked as
1967 * being {@link ComponentInfo#directBootAware}.
Jeff Sharkeybedbaa92015-12-02 16:42:25 -07001968 * <p class="note">
1969 * This is a protected intent that can only be sent by the system.
Jeff Sharkeycf3f0a12016-03-17 19:57:58 -06001970 *
1971 * @see Context#createDeviceProtectedStorageContext()
Jeff Sharkeybedbaa92015-12-02 16:42:25 -07001972 */
1973 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1974 public static final String ACTION_LOCKED_BOOT_COMPLETED = "android.intent.action.LOCKED_BOOT_COMPLETED";
1975
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001976 /**
Jeff Sharkeycf3f0a12016-03-17 19:57:58 -06001977 * Broadcast Action: This is broadcast once, after the user has finished
1978 * booting. It can be used to perform application-specific initialization,
1979 * such as installing alarms. You must hold the
1980 * {@link android.Manifest.permission#RECEIVE_BOOT_COMPLETED} permission in
1981 * order to receive this broadcast.
1982 * <p>
1983 * This broadcast is sent at boot by all devices (both with and without
1984 * direct boot support). Upon receipt of this broadcast, the user is
1985 * unlocked and both device-protected and credential-protected storage can
1986 * accessed safely.
1987 * <p>
1988 * If you need to run while the user is still locked (before they've entered
1989 * their lock pattern or PIN for the first time), you can listen for the
1990 * {@link #ACTION_LOCKED_BOOT_COMPLETED} broadcast.
1991 * <p class="note">
1992 * This is a protected intent that can only be sent by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001993 */
1994 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1995 public static final String ACTION_BOOT_COMPLETED = "android.intent.action.BOOT_COMPLETED";
Jeff Sharkeybedbaa92015-12-02 16:42:25 -07001996
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001997 /**
1998 * Broadcast Action: This is broadcast when a user action should request a
1999 * temporary system dialog to dismiss. Some examples of temporary system
2000 * dialogs are the notification window-shade and the recent tasks dialog.
2001 */
2002 public static final String ACTION_CLOSE_SYSTEM_DIALOGS = "android.intent.action.CLOSE_SYSTEM_DIALOGS";
2003 /**
2004 * Broadcast Action: Trigger the download and eventual installation
2005 * of a package.
2006 * <p>Input: {@link #getData} is the URI of the package file to download.
Tom Taylord4a47292009-12-21 13:59:18 -08002007 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002008 * <p class="note">This is a protected intent that can only be sent
2009 * by the system.
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07002010 *
2011 * @deprecated This constant has never been used.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002012 */
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07002013 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002014 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2015 public static final String ACTION_PACKAGE_INSTALL = "android.intent.action.PACKAGE_INSTALL";
2016 /**
2017 * Broadcast Action: A new application package has been installed on the
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07002018 * device. The data contains the name of the package. Note that the
2019 * newly installed package does <em>not</em> receive this broadcast.
Jeff Sharkeyd0c6ccb2012-09-14 16:26:37 -07002020 * <p>May include the following extras:
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002021 * <ul>
2022 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the new package.
2023 * <li> {@link #EXTRA_REPLACING} is set to true if this is following
2024 * an {@link #ACTION_PACKAGE_REMOVED} broadcast for the same package.
2025 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002026 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002027 * <p class="note">This is a protected intent that can only be sent
2028 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002029 */
2030 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2031 public static final String ACTION_PACKAGE_ADDED = "android.intent.action.PACKAGE_ADDED";
2032 /**
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07002033 * Broadcast Action: A new version of an application package has been
2034 * installed, replacing an existing version that was previously installed.
2035 * The data contains the name of the package.
Jeff Sharkeyd0c6ccb2012-09-14 16:26:37 -07002036 * <p>May include the following extras:
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07002037 * <ul>
2038 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the new package.
2039 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002040 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002041 * <p class="note">This is a protected intent that can only be sent
2042 * by the system.
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07002043 */
2044 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2045 public static final String ACTION_PACKAGE_REPLACED = "android.intent.action.PACKAGE_REPLACED";
2046 /**
Dianne Hackborne7f97212011-02-24 14:40:20 -08002047 * Broadcast Action: A new version of your application has been installed
2048 * over an existing one. This is only sent to the application that was
2049 * replaced. It does not contain any additional data; to receive it, just
2050 * use an intent filter for this action.
2051 *
2052 * <p class="note">This is a protected intent that can only be sent
2053 * by the system.
2054 */
2055 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2056 public static final String ACTION_MY_PACKAGE_REPLACED = "android.intent.action.MY_PACKAGE_REPLACED";
2057 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002058 * Broadcast Action: An existing application package has been removed from
2059 * the device. The data contains the name of the package. The package
Trevor Johns682c24e2016-04-12 10:13:47 -07002060 * that is being removed does <em>not</em> receive this Intent.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002061 * <ul>
2062 * <li> {@link #EXTRA_UID} containing the integer uid previously assigned
2063 * to the package.
2064 * <li> {@link #EXTRA_DATA_REMOVED} is set to true if the entire
2065 * application -- data and code -- is being removed.
2066 * <li> {@link #EXTRA_REPLACING} is set to true if this will be followed
2067 * by an {@link #ACTION_PACKAGE_ADDED} broadcast for the same package.
2068 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002069 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002070 * <p class="note">This is a protected intent that can only be sent
2071 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002072 */
2073 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2074 public static final String ACTION_PACKAGE_REMOVED = "android.intent.action.PACKAGE_REMOVED";
2075 /**
Dianne Hackbornf9abb402011-08-10 15:00:59 -07002076 * Broadcast Action: An existing application package has been completely
2077 * removed from the device. The data contains the name of the package.
2078 * This is like {@link #ACTION_PACKAGE_REMOVED}, but only set when
2079 * {@link #EXTRA_DATA_REMOVED} is true and
2080 * {@link #EXTRA_REPLACING} is false of that broadcast.
2081 *
2082 * <ul>
2083 * <li> {@link #EXTRA_UID} containing the integer uid previously assigned
2084 * to the package.
2085 * </ul>
2086 *
2087 * <p class="note">This is a protected intent that can only be sent
2088 * by the system.
2089 */
2090 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2091 public static final String ACTION_PACKAGE_FULLY_REMOVED
2092 = "android.intent.action.PACKAGE_FULLY_REMOVED";
2093 /**
Trevor Johns682c24e2016-04-12 10:13:47 -07002094 * Broadcast Action: An existing application package has been changed (for
2095 * example, a component has been enabled or disabled). The data contains
2096 * the name of the package.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002097 * <ul>
2098 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
Dianne Hackborn86a72da2009-11-11 20:12:41 -08002099 * <li> {@link #EXTRA_CHANGED_COMPONENT_NAME_LIST} containing the class name
Dianne Hackbornfd7aded2013-01-22 17:10:23 -08002100 * of the changed components (or the package name itself).
Dianne Hackborn86a72da2009-11-11 20:12:41 -08002101 * <li> {@link #EXTRA_DONT_KILL_APP} containing boolean field to override the
2102 * default action of restarting the application.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002103 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002104 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002105 * <p class="note">This is a protected intent that can only be sent
2106 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002107 */
2108 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2109 public static final String ACTION_PACKAGE_CHANGED = "android.intent.action.PACKAGE_CHANGED";
2110 /**
Dianne Hackborn21f1bd12010-02-19 17:02:21 -08002111 * @hide
2112 * Broadcast Action: Ask system services if there is any reason to
2113 * restart the given package. The data contains the name of the
2114 * package.
2115 * <ul>
2116 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
2117 * <li> {@link #EXTRA_PACKAGES} String array of all packages to check.
2118 * </ul>
2119 *
2120 * <p class="note">This is a protected intent that can only be sent
2121 * by the system.
2122 */
Soonil Nagarkar0e8fd092015-02-10 10:37:36 -08002123 @SystemApi
Dianne Hackborn21f1bd12010-02-19 17:02:21 -08002124 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2125 public static final String ACTION_QUERY_PACKAGE_RESTART = "android.intent.action.QUERY_PACKAGE_RESTART";
2126 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002127 * Broadcast Action: The user has restarted a package, and all of its
2128 * processes have been killed. All runtime state
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002129 * associated with it (processes, alarms, notifications, etc) should
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07002130 * be removed. Note that the restarted package does <em>not</em>
2131 * receive this broadcast.
2132 * The data contains the name of the package.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002133 * <ul>
2134 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
2135 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002136 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002137 * <p class="note">This is a protected intent that can only be sent
2138 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002139 */
2140 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2141 public static final String ACTION_PACKAGE_RESTARTED = "android.intent.action.PACKAGE_RESTARTED";
2142 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002143 * Broadcast Action: The user has cleared the data of a package. This should
2144 * be preceded by {@link #ACTION_PACKAGE_RESTARTED}, after which all of
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07002145 * its persistent data is erased and this broadcast sent.
2146 * Note that the cleared package does <em>not</em>
2147 * receive this broadcast. The data contains the name of the package.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002148 * <ul>
2149 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
2150 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002151 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002152 * <p class="note">This is a protected intent that can only be sent
2153 * by the system.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002154 */
2155 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2156 public static final String ACTION_PACKAGE_DATA_CLEARED = "android.intent.action.PACKAGE_DATA_CLEARED";
2157 /**
Andrei Stingaceanu69d5ebc2016-01-14 12:59:03 +00002158 * Broadcast Action: Packages have been suspended.
2159 * <p>Includes the following extras:
2160 * <ul>
2161 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages which have been suspended
2162 * </ul>
2163 *
2164 * <p class="note">This is a protected intent that can only be sent
2165 * by the system. It is only sent to registered receivers.
2166 */
2167 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2168 public static final String ACTION_PACKAGES_SUSPENDED = "android.intent.action.PACKAGES_SUSPENDED";
2169 /**
2170 * Broadcast Action: Packages have been unsuspended.
2171 * <p>Includes the following extras:
2172 * <ul>
2173 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages which have been unsuspended
2174 * </ul>
2175 *
2176 * <p class="note">This is a protected intent that can only be sent
2177 * by the system. It is only sent to registered receivers.
2178 */
2179 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2180 public static final String ACTION_PACKAGES_UNSUSPENDED = "android.intent.action.PACKAGES_UNSUSPENDED";
2181 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002182 * Broadcast Action: A user ID has been removed from the system. The user
2183 * ID number is stored in the extra data under {@link #EXTRA_UID}.
Tom Taylord4a47292009-12-21 13:59:18 -08002184 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002185 * <p class="note">This is a protected intent that can only be sent
2186 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002187 */
2188 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2189 public static final String ACTION_UID_REMOVED = "android.intent.action.UID_REMOVED";
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002190
2191 /**
Trevor Johns682c24e2016-04-12 10:13:47 -07002192 * Broadcast Action: Sent to the installer package of an application when
2193 * that application is first launched (that is the first time it is moved
2194 * out of the stopped state). The data contains the name of the package.
Dianne Hackborne7f97212011-02-24 14:40:20 -08002195 *
2196 * <p class="note">This is a protected intent that can only be sent
2197 * by the system.
2198 */
2199 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2200 public static final String ACTION_PACKAGE_FIRST_LAUNCH = "android.intent.action.PACKAGE_FIRST_LAUNCH";
2201
2202 /**
Kenny Root5ab21572011-07-27 11:11:19 -07002203 * Broadcast Action: Sent to the system package verifier when a package
2204 * needs to be verified. The data contains the package URI.
2205 * <p class="note">
2206 * This is a protected intent that can only be sent by the system.
2207 * </p>
Kenny Root5ab21572011-07-27 11:11:19 -07002208 */
2209 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2210 public static final String ACTION_PACKAGE_NEEDS_VERIFICATION = "android.intent.action.PACKAGE_NEEDS_VERIFICATION";
2211
2212 /**
rich canningsd1b5cfc2012-08-29 14:49:51 -07002213 * Broadcast Action: Sent to the system package verifier when a package is
2214 * verified. The data contains the package URI.
2215 * <p class="note">
2216 * This is a protected intent that can only be sent by the system.
2217 */
2218 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2219 public static final String ACTION_PACKAGE_VERIFIED = "android.intent.action.PACKAGE_VERIFIED";
2220
2221 /**
Trevor Johns682c24e2016-04-12 10:13:47 -07002222 * Broadcast Action: Sent to the system intent filter verifier when an
2223 * intent filter needs to be verified. The data contains the filter data
2224 * hosts to be verified against.
Fabrice Di Meglio1c1b4712014-11-19 17:12:32 -08002225 * <p class="note">
2226 * This is a protected intent that can only be sent by the system.
2227 * </p>
2228 *
2229 * @hide
2230 */
2231 @SystemApi
2232 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2233 public static final String ACTION_INTENT_FILTER_NEEDS_VERIFICATION = "android.intent.action.INTENT_FILTER_NEEDS_VERIFICATION";
2234
2235 /**
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002236 * Broadcast Action: Resources for a set of packages (which were
2237 * previously unavailable) are currently
2238 * available since the media on which they exist is available.
2239 * The extra data {@link #EXTRA_CHANGED_PACKAGE_LIST} contains a
2240 * list of packages whose availability changed.
2241 * The extra data {@link #EXTRA_CHANGED_UID_LIST} contains a
2242 * list of uids of packages whose availability changed.
2243 * Note that the
2244 * packages in this list do <em>not</em> receive this broadcast.
2245 * The specified set of packages are now available on the system.
2246 * <p>Includes the following extras:
2247 * <ul>
2248 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages
2249 * whose resources(were previously unavailable) are currently available.
2250 * {@link #EXTRA_CHANGED_UID_LIST} is the set of uids of the
2251 * packages whose resources(were previously unavailable)
2252 * are currently available.
2253 * </ul>
2254 *
2255 * <p class="note">This is a protected intent that can only be sent
2256 * by the system.
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002257 */
2258 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08002259 public static final String ACTION_EXTERNAL_APPLICATIONS_AVAILABLE =
2260 "android.intent.action.EXTERNAL_APPLICATIONS_AVAILABLE";
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002261
2262 /**
2263 * Broadcast Action: Resources for a set of packages are currently
2264 * unavailable since the media on which they exist is unavailable.
2265 * The extra data {@link #EXTRA_CHANGED_PACKAGE_LIST} contains a
2266 * list of packages whose availability changed.
2267 * The extra data {@link #EXTRA_CHANGED_UID_LIST} contains a
2268 * list of uids of packages whose availability changed.
2269 * The specified set of packages can no longer be
2270 * launched and are practically unavailable on the system.
2271 * <p>Inclues the following extras:
2272 * <ul>
2273 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages
2274 * whose resources are no longer available.
2275 * {@link #EXTRA_CHANGED_UID_LIST} is the set of packages
2276 * whose resources are no longer available.
2277 * </ul>
2278 *
2279 * <p class="note">This is a protected intent that can only be sent
2280 * by the system.
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002281 */
2282 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08002283 public static final String ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE =
Joe Onorato8a051a42010-03-04 15:54:50 -05002284 "android.intent.action.EXTERNAL_APPLICATIONS_UNAVAILABLE";
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002285
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002286 /**
Makoto Onuki10305202016-07-14 18:14:08 -07002287 * Broadcast Action: preferred activities have changed *explicitly*.
2288 *
2289 * <p>Note there are cases where a preferred activity is invalidated *implicitly*, e.g.
2290 * when an app is installed or uninstalled, but in such cases this broadcast will *not*
2291 * be sent.
2292 *
2293 * {@link #EXTRA_USER_HANDLE} contains the user ID in question.
2294 *
2295 * @hide
2296 */
2297 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2298 public static final String ACTION_PREFERRED_ACTIVITY_CHANGED =
2299 "android.intent.action.ACTION_PREFERRED_ACTIVITY_CHANGED";
2300
2301
2302 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002303 * Broadcast Action: The current system wallpaper has changed. See
Scott Main8b2e0002009-09-29 18:17:31 -07002304 * {@link android.app.WallpaperManager} for retrieving the new wallpaper.
Dianne Hackbornc5bf7582012-04-25 19:12:07 -07002305 * This should <em>only</em> be used to determine when the wallpaper
2306 * has changed to show the new wallpaper to the user. You should certainly
2307 * never, in response to this, change the wallpaper or other attributes of
2308 * it such as the suggested size. That would be crazy, right? You'd cause
2309 * all kinds of loops, especially if other apps are doing similar things,
2310 * right? Of course. So please don't do this.
2311 *
2312 * @deprecated Modern applications should use
2313 * {@link android.view.WindowManager.LayoutParams#FLAG_SHOW_WALLPAPER
2314 * WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER} to have the wallpaper
2315 * shown behind their UI, rather than watching for this broadcast and
2316 * rendering the wallpaper on their own.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002317 */
Dianne Hackbornc5bf7582012-04-25 19:12:07 -07002318 @Deprecated @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002319 public static final String ACTION_WALLPAPER_CHANGED = "android.intent.action.WALLPAPER_CHANGED";
2320 /**
2321 * Broadcast Action: The current device {@link android.content.res.Configuration}
2322 * (orientation, locale, etc) has changed. When such a change happens, the
2323 * UIs (view hierarchy) will need to be rebuilt based on this new
2324 * information; for the most part, applications don't need to worry about
2325 * this, because the system will take care of stopping and restarting the
2326 * application to make sure it sees the new changes. Some system code that
2327 * can not be restarted will need to watch for this action and handle it
2328 * appropriately.
Tom Taylord4a47292009-12-21 13:59:18 -08002329 *
Dianne Hackborn362d5b92009-11-11 18:04:39 -08002330 * <p class="note">
Casey Hodbf6785c2015-03-17 15:59:39 -07002331 * You <em>cannot</em> receive this through components declared
Dianne Hackborn362d5b92009-11-11 18:04:39 -08002332 * in manifests, only by explicitly registering for it with
2333 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
2334 * Context.registerReceiver()}.
Tom Taylord4a47292009-12-21 13:59:18 -08002335 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002336 * <p class="note">This is a protected intent that can only be sent
2337 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002338 *
2339 * @see android.content.res.Configuration
2340 */
2341 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2342 public static final String ACTION_CONFIGURATION_CHANGED = "android.intent.action.CONFIGURATION_CHANGED";
2343 /**
Dianne Hackborn362d5b92009-11-11 18:04:39 -08002344 * Broadcast Action: The current device's locale has changed.
Tom Taylord4a47292009-12-21 13:59:18 -08002345 *
Dianne Hackborn362d5b92009-11-11 18:04:39 -08002346 * <p class="note">This is a protected intent that can only be sent
2347 * by the system.
2348 */
2349 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2350 public static final String ACTION_LOCALE_CHANGED = "android.intent.action.LOCALE_CHANGED";
2351 /**
Dianne Hackbornedd93162009-09-19 14:03:05 -07002352 * Broadcast Action: This is a <em>sticky broadcast</em> containing the
2353 * charging state, level, and other information about the battery.
2354 * See {@link android.os.BatteryManager} for documentation on the
2355 * contents of the Intent.
The Android Open Source Project10592532009-03-18 17:39:46 -07002356 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002357 * <p class="note">
Casey Hodbf6785c2015-03-17 15:59:39 -07002358 * You <em>cannot</em> receive this through components declared
Dianne Hackborn854060af2009-07-09 18:14:31 -07002359 * in manifests, only by explicitly registering for it with
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002360 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
Dianne Hackbornedd93162009-09-19 14:03:05 -07002361 * Context.registerReceiver()}. See {@link #ACTION_BATTERY_LOW},
2362 * {@link #ACTION_BATTERY_OKAY}, {@link #ACTION_POWER_CONNECTED},
2363 * and {@link #ACTION_POWER_DISCONNECTED} for distinct battery-related
2364 * broadcasts that are sent and can be received through manifest
2365 * receivers.
Tom Taylord4a47292009-12-21 13:59:18 -08002366 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002367 * <p class="note">This is a protected intent that can only be sent
2368 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002369 */
2370 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2371 public static final String ACTION_BATTERY_CHANGED = "android.intent.action.BATTERY_CHANGED";
2372 /**
2373 * Broadcast Action: Indicates low battery condition on the device.
2374 * This broadcast corresponds to the "Low battery warning" system dialog.
Tom Taylord4a47292009-12-21 13:59:18 -08002375 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002376 * <p class="note">This is a protected intent that can only be sent
2377 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002378 */
2379 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2380 public static final String ACTION_BATTERY_LOW = "android.intent.action.BATTERY_LOW";
2381 /**
Dianne Hackborn1dac2772009-06-26 18:16:48 -07002382 * Broadcast Action: Indicates the battery is now okay after being low.
2383 * This will be sent after {@link #ACTION_BATTERY_LOW} once the battery has
2384 * gone back up to an okay state.
Tom Taylord4a47292009-12-21 13:59:18 -08002385 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002386 * <p class="note">This is a protected intent that can only be sent
2387 * by the system.
Dianne Hackborn1dac2772009-06-26 18:16:48 -07002388 */
2389 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2390 public static final String ACTION_BATTERY_OKAY = "android.intent.action.BATTERY_OKAY";
2391 /**
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002392 * Broadcast Action: External power has been connected to the device.
2393 * This is intended for applications that wish to register specifically to this notification.
2394 * Unlike ACTION_BATTERY_CHANGED, applications will be woken for this and so do not have to
2395 * stay active to receive this notification. This action can be used to implement actions
2396 * that wait until power is available to trigger.
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.
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002400 */
2401 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Dianne Hackbornfe240ec2009-08-27 12:51:11 -07002402 public static final String ACTION_POWER_CONNECTED = "android.intent.action.ACTION_POWER_CONNECTED";
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002403 /**
2404 * Broadcast Action: External power has been removed from the device.
2405 * This is intended for applications that wish to register specifically to this notification.
2406 * Unlike ACTION_BATTERY_CHANGED, applications will be woken for this and so do not have to
2407 * stay active to receive this notification. This action can be used to implement actions
Romain Guy4969af72009-06-17 10:53:19 -07002408 * that wait until power is available to trigger.
Tom Taylord4a47292009-12-21 13:59:18 -08002409 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002410 * <p class="note">This is a protected intent that can only be sent
2411 * by the system.
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002412 */
2413 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jean-Baptiste Queru1ef45642008-10-24 11:49:25 -07002414 public static final String ACTION_POWER_DISCONNECTED =
Dianne Hackbornfe240ec2009-08-27 12:51:11 -07002415 "android.intent.action.ACTION_POWER_DISCONNECTED";
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002416 /**
Dianne Hackborn55280a92009-05-07 15:53:46 -07002417 * Broadcast Action: Device is shutting down.
2418 * This is broadcast when the device is being shut down (completely turned
2419 * off, not sleeping). Once the broadcast is complete, the final shutdown
2420 * will proceed and all unsaved data lost. Apps will not normally need
Dianne Hackbornfe240ec2009-08-27 12:51:11 -07002421 * to handle this, since the foreground activity will be paused as well.
Tom Taylord4a47292009-12-21 13:59:18 -08002422 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002423 * <p class="note">This is a protected intent that can only be sent
2424 * by the system.
Dianne Hackborn57a7f592013-07-22 18:21:32 -07002425 * <p>May include the following extras:
2426 * <ul>
2427 * <li> {@link #EXTRA_SHUTDOWN_USERSPACE_ONLY} a boolean that is set to true if this
2428 * shutdown is only for userspace processes. If not set, assumed to be false.
2429 * </ul>
Dianne Hackborn55280a92009-05-07 15:53:46 -07002430 */
2431 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Romain Guy4969af72009-06-17 10:53:19 -07002432 public static final String ACTION_SHUTDOWN = "android.intent.action.ACTION_SHUTDOWN";
Dianne Hackborn55280a92009-05-07 15:53:46 -07002433 /**
Mike Lockwoodbad80e02009-07-30 01:21:08 -07002434 * Activity Action: Start this activity to request system shutdown.
2435 * The optional boolean extra field {@link #EXTRA_KEY_CONFIRM} can be set to true
Yusuke Sato705ffd12015-07-21 15:52:11 -07002436 * to request confirmation from the user before shutting down. The optional boolean
2437 * extra field {@link #EXTRA_USER_REQUESTED_SHUTDOWN} can be set to true to
2438 * indicate that the shutdown is requested by the user.
Mike Lockwoodbad80e02009-07-30 01:21:08 -07002439 *
2440 * <p class="note">This is a protected intent that can only be sent
2441 * by the system.
2442 *
2443 * {@hide}
2444 */
2445 public static final String ACTION_REQUEST_SHUTDOWN = "android.intent.action.ACTION_REQUEST_SHUTDOWN";
2446 /**
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002447 * Broadcast Action: A sticky broadcast that indicates low storage space
Dianne Hackbornedd93162009-09-19 14:03:05 -07002448 * condition on the device
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002449 * <p class="note">
2450 * This is a protected intent that can only be sent by the system.
Tom Taylord4a47292009-12-21 13:59:18 -08002451 *
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002452 * @deprecated if your app targets {@link android.os.Build.VERSION_CODES#O}
2453 * or above, this broadcast will no longer be delivered to any
2454 * {@link BroadcastReceiver} defined in your manifest. Instead,
2455 * apps are strongly encouraged to use the improved
2456 * {@link Context#getCacheDir()} behavior so the system can
2457 * automatically free up storage when needed.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002458 */
2459 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002460 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002461 public static final String ACTION_DEVICE_STORAGE_LOW = "android.intent.action.DEVICE_STORAGE_LOW";
2462 /**
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002463 * Broadcast Action: Indicates low storage space condition on the device no
2464 * longer exists
2465 * <p class="note">
2466 * This is a protected intent that can only be sent by the system.
Tom Taylord4a47292009-12-21 13:59:18 -08002467 *
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002468 * @deprecated if your app targets {@link android.os.Build.VERSION_CODES#O}
2469 * or above, this broadcast will no longer be delivered to any
2470 * {@link BroadcastReceiver} defined in your manifest. Instead,
2471 * apps are strongly encouraged to use the improved
2472 * {@link Context#getCacheDir()} behavior so the system can
2473 * automatically free up storage when needed.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002474 */
2475 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002476 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002477 public static final String ACTION_DEVICE_STORAGE_OK = "android.intent.action.DEVICE_STORAGE_OK";
2478 /**
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002479 * Broadcast Action: A sticky broadcast that indicates a storage space full
2480 * condition on the device. This is intended for activities that want to be
2481 * able to fill the data partition completely, leaving only enough free
2482 * space to prevent system-wide SQLite failures.
2483 * <p class="note">
2484 * This is a protected intent that can only be sent by the system.
Jake Hambybb371632010-08-23 18:16:48 -07002485 *
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002486 * @deprecated if your app targets {@link android.os.Build.VERSION_CODES#O}
2487 * or above, this broadcast will no longer be delivered to any
2488 * {@link BroadcastReceiver} defined in your manifest. Instead,
2489 * apps are strongly encouraged to use the improved
2490 * {@link Context#getCacheDir()} behavior so the system can
2491 * automatically free up storage when needed.
2492 * @hide
Jake Hambybb371632010-08-23 18:16:48 -07002493 */
2494 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002495 @Deprecated
Jake Hambybb371632010-08-23 18:16:48 -07002496 public static final String ACTION_DEVICE_STORAGE_FULL = "android.intent.action.DEVICE_STORAGE_FULL";
2497 /**
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002498 * Broadcast Action: Indicates storage space full condition on the device no
2499 * longer exists.
2500 * <p class="note">
2501 * This is a protected intent that can only be sent by the system.
Jake Hambybb371632010-08-23 18:16:48 -07002502 *
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002503 * @deprecated if your app targets {@link android.os.Build.VERSION_CODES#O}
2504 * or above, this broadcast will no longer be delivered to any
2505 * {@link BroadcastReceiver} defined in your manifest. Instead,
2506 * apps are strongly encouraged to use the improved
2507 * {@link Context#getCacheDir()} behavior so the system can
2508 * automatically free up storage when needed.
2509 * @hide
Jake Hambybb371632010-08-23 18:16:48 -07002510 */
2511 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002512 @Deprecated
Jake Hambybb371632010-08-23 18:16:48 -07002513 public static final String ACTION_DEVICE_STORAGE_NOT_FULL = "android.intent.action.DEVICE_STORAGE_NOT_FULL";
2514 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002515 * Broadcast Action: Indicates low memory condition notification acknowledged by user
2516 * and package management should be started.
2517 * This is triggered by the user from the ACTION_DEVICE_STORAGE_LOW
2518 * notification.
2519 */
2520 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2521 public static final String ACTION_MANAGE_PACKAGE_STORAGE = "android.intent.action.MANAGE_PACKAGE_STORAGE";
2522 /**
2523 * Broadcast Action: The device has entered USB Mass Storage mode.
2524 * This is used mainly for the USB Settings panel.
2525 * Apps should listen for ACTION_MEDIA_MOUNTED and ACTION_MEDIA_UNMOUNTED broadcasts to be notified
2526 * when the SD card file system is mounted or unmounted
Mike Lockwood7e4db372011-06-07 11:23:44 -07002527 * @deprecated replaced by android.os.storage.StorageEventListener
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002528 */
Mike Lockwoodda85e522011-06-07 09:08:34 -07002529 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002530 public static final String ACTION_UMS_CONNECTED = "android.intent.action.UMS_CONNECTED";
2531
2532 /**
2533 * Broadcast Action: The device has exited USB Mass Storage mode.
2534 * This is used mainly for the USB Settings panel.
2535 * Apps should listen for ACTION_MEDIA_MOUNTED and ACTION_MEDIA_UNMOUNTED broadcasts to be notified
2536 * when the SD card file system is mounted or unmounted
Mike Lockwood7e4db372011-06-07 11:23:44 -07002537 * @deprecated replaced by android.os.storage.StorageEventListener
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002538 */
Mike Lockwoodda85e522011-06-07 09:08:34 -07002539 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002540 public static final String ACTION_UMS_DISCONNECTED = "android.intent.action.UMS_DISCONNECTED";
2541
2542 /**
2543 * Broadcast Action: External media has been removed.
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_REMOVED = "android.intent.action.MEDIA_REMOVED";
2548
2549 /**
2550 * Broadcast Action: External media is present, but not mounted at its mount point.
suyi Yuanbe7af832013-01-04 21:21:59 +08002551 * 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 -07002552 */
2553 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2554 public static final String ACTION_MEDIA_UNMOUNTED = "android.intent.action.MEDIA_UNMOUNTED";
2555
2556 /**
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08002557 * Broadcast Action: External media is present, and being disk-checked
2558 * 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 -08002559 */
2560 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2561 public static final String ACTION_MEDIA_CHECKING = "android.intent.action.MEDIA_CHECKING";
2562
2563 /**
2564 * Broadcast Action: External media is present, but is using an incompatible fs (or is blank)
2565 * 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 -08002566 */
2567 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2568 public static final String ACTION_MEDIA_NOFS = "android.intent.action.MEDIA_NOFS";
2569
2570 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002571 * Broadcast Action: External media is present and mounted at its mount point.
suyi Yuanbe7af832013-01-04 21:21:59 +08002572 * 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 -07002573 * The Intent contains an extra with name "read-only" and Boolean value to indicate if the
2574 * media was mounted read only.
2575 */
2576 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2577 public static final String ACTION_MEDIA_MOUNTED = "android.intent.action.MEDIA_MOUNTED";
2578
2579 /**
2580 * Broadcast Action: External media is unmounted because it is being shared via USB mass storage.
Mike Lockwoodbf2dd442010-03-03 06:16:52 -05002581 * 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 -07002582 */
2583 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2584 public static final String ACTION_MEDIA_SHARED = "android.intent.action.MEDIA_SHARED";
2585
2586 /**
Mike Lockwoodbf2dd442010-03-03 06:16:52 -05002587 * Broadcast Action: External media is no longer being shared via USB mass storage.
2588 * The path to the mount point for the previously shared media is contained in the Intent.mData field.
2589 *
2590 * @hide
2591 */
2592 public static final String ACTION_MEDIA_UNSHARED = "android.intent.action.MEDIA_UNSHARED";
2593
2594 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002595 * Broadcast Action: External media was removed from SD card slot, but mount point was not unmounted.
2596 * The path to the mount point for the removed media is contained in the Intent.mData field.
2597 */
2598 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2599 public static final String ACTION_MEDIA_BAD_REMOVAL = "android.intent.action.MEDIA_BAD_REMOVAL";
2600
2601 /**
2602 * Broadcast Action: External media is present but cannot be mounted.
suyi Yuanbe7af832013-01-04 21:21:59 +08002603 * 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 -07002604 */
2605 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2606 public static final String ACTION_MEDIA_UNMOUNTABLE = "android.intent.action.MEDIA_UNMOUNTABLE";
2607
2608 /**
2609 * Broadcast Action: User has expressed the desire to remove the external storage media.
2610 * Applications should close all files they have open within the mount point when they receive this intent.
2611 * The path to the mount point for the media to be ejected is contained in the Intent.mData field.
2612 */
2613 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2614 public static final String ACTION_MEDIA_EJECT = "android.intent.action.MEDIA_EJECT";
2615
2616 /**
2617 * Broadcast Action: The media scanner has started scanning a directory.
2618 * The path to the directory being scanned is contained in the Intent.mData field.
2619 */
2620 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2621 public static final String ACTION_MEDIA_SCANNER_STARTED = "android.intent.action.MEDIA_SCANNER_STARTED";
2622
2623 /**
2624 * Broadcast Action: The media scanner has finished scanning a directory.
2625 * The path to the scanned directory is contained in the Intent.mData field.
2626 */
2627 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2628 public static final String ACTION_MEDIA_SCANNER_FINISHED = "android.intent.action.MEDIA_SCANNER_FINISHED";
2629
2630 /**
2631 * Broadcast Action: Request the media scanner to scan a file and add it to the media database.
2632 * The path to the file is contained in the Intent.mData field.
2633 */
2634 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2635 public static final String ACTION_MEDIA_SCANNER_SCAN_FILE = "android.intent.action.MEDIA_SCANNER_SCAN_FILE";
2636
2637 /**
2638 * Broadcast Action: The "Media Button" was pressed. Includes a single
2639 * extra field, {@link #EXTRA_KEY_EVENT}, containing the key event that
2640 * caused the broadcast.
2641 */
2642 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2643 public static final String ACTION_MEDIA_BUTTON = "android.intent.action.MEDIA_BUTTON";
2644
2645 /**
2646 * Broadcast Action: The "Camera Button" was pressed. Includes a single
2647 * extra field, {@link #EXTRA_KEY_EVENT}, containing the key event that
2648 * caused the broadcast.
2649 */
2650 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2651 public static final String ACTION_CAMERA_BUTTON = "android.intent.action.CAMERA_BUTTON";
2652
2653 // *** NOTE: @todo(*) The following really should go into a more domain-specific
2654 // location; they are not general-purpose actions.
2655
2656 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09002657 * Broadcast Action: A GTalk connection has been established.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002658 */
2659 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2660 public static final String ACTION_GTALK_SERVICE_CONNECTED =
2661 "android.intent.action.GTALK_CONNECTED";
2662
2663 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09002664 * Broadcast Action: A GTalk connection has been disconnected.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002665 */
2666 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2667 public static final String ACTION_GTALK_SERVICE_DISCONNECTED =
2668 "android.intent.action.GTALK_DISCONNECTED";
The Android Open Source Project10592532009-03-18 17:39:46 -07002669
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08002670 /**
2671 * Broadcast Action: An input method has been changed.
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08002672 */
2673 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2674 public static final String ACTION_INPUT_METHOD_CHANGED =
2675 "android.intent.action.INPUT_METHOD_CHANGED";
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002676
2677 /**
2678 * <p>Broadcast Action: The user has switched the phone into or out of Airplane Mode. One or
2679 * more radios have been turned off or on. The intent will have the following extra value:</p>
2680 * <ul>
2681 * <li><em>state</em> - A boolean value indicating whether Airplane Mode is on. If true,
2682 * then cell radio and possibly other radios such as bluetooth or WiFi may have also been
2683 * turned off</li>
2684 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002685 *
Peng Xua35b5532016-01-20 00:05:45 -08002686 * <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 -07002687 */
2688 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2689 public static final String ACTION_AIRPLANE_MODE_CHANGED = "android.intent.action.AIRPLANE_MODE";
2690
2691 /**
2692 * Broadcast Action: Some content providers have parts of their namespace
2693 * where they publish new events or items that the user may be especially
2694 * interested in. For these things, they may broadcast this action when the
2695 * set of interesting items change.
2696 *
2697 * For example, GmailProvider sends this notification when the set of unread
2698 * mail in the inbox changes.
2699 *
2700 * <p>The data of the intent identifies which part of which provider
2701 * changed. When queried through the content resolver, the data URI will
2702 * return the data set in question.
2703 *
2704 * <p>The intent will have the following extra values:
2705 * <ul>
2706 * <li><em>count</em> - The number of items in the data set. This is the
2707 * same as the number of items in the cursor returned by querying the
2708 * data URI. </li>
2709 * </ul>
2710 *
2711 * This intent will be sent at boot (if the count is non-zero) and when the
2712 * data set changes. It is possible for the data set to change without the
2713 * count changing (for example, if a new unread message arrives in the same
2714 * sync operation in which a message is archived). The phone should still
2715 * ring/vibrate/etc as normal in this case.
2716 */
2717 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2718 public static final String ACTION_PROVIDER_CHANGED =
2719 "android.intent.action.PROVIDER_CHANGED";
2720
2721 /**
2722 * Broadcast Action: Wired Headset plugged in or unplugged.
2723 *
Jean-Michel Trivic5258432014-08-27 15:46:54 -07002724 * Same as {@link android.media.AudioManager#ACTION_HEADSET_PLUG}, to be consulted for value
2725 * and documentation.
2726 * <p>If the minimum SDK version of your application is
Dianne Hackborn955d8d62014-10-07 20:17:19 -07002727 * {@link android.os.Build.VERSION_CODES#LOLLIPOP}, it is recommended to refer
Jean-Michel Trivic5258432014-08-27 15:46:54 -07002728 * to the <code>AudioManager</code> constant in your receiver registration code instead.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002729 */
2730 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jean-Michel Trivic5258432014-08-27 15:46:54 -07002731 public static final String ACTION_HEADSET_PLUG = android.media.AudioManager.ACTION_HEADSET_PLUG;
Eric Laurent59f48272012-04-05 19:42:21 -07002732
2733 /**
Joe Onorato9cdffa12011-04-06 18:27:27 -07002734 * <p>Broadcast Action: The user has switched on advanced settings in the settings app:</p>
2735 * <ul>
2736 * <li><em>state</em> - A boolean value indicating whether the settings is on or off.</li>
2737 * </ul>
2738 *
2739 * <p class="note">This is a protected intent that can only be sent
2740 * by the system.
2741 *
2742 * @hide
2743 */
2744 //@SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2745 public static final String ACTION_ADVANCED_SETTINGS_CHANGED
2746 = "android.intent.action.ADVANCED_SETTINGS";
2747
2748 /**
Robin Lee66e5d962014-04-09 16:44:21 +01002749 * Broadcast Action: Sent after application restrictions are changed.
2750 *
2751 * <p class="note">This is a protected intent that can only be sent
2752 * by the system.</p>
2753 */
2754 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2755 public static final String ACTION_APPLICATION_RESTRICTIONS_CHANGED =
2756 "android.intent.action.APPLICATION_RESTRICTIONS_CHANGED";
2757
2758 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002759 * Broadcast Action: An outgoing call is about to be placed.
2760 *
Dirk Dougherty367ce902013-05-28 17:37:12 -07002761 * <p>The Intent will have the following extra value:</p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002762 * <ul>
The Android Open Source Project10592532009-03-18 17:39:46 -07002763 * <li><em>{@link android.content.Intent#EXTRA_PHONE_NUMBER}</em> -
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002764 * the phone number originally intended to be dialed.</li>
2765 * </ul>
2766 * <p>Once the broadcast is finished, the resultData is used as the actual
2767 * number to call. If <code>null</code>, no call will be placed.</p>
The Android Open Source Project10592532009-03-18 17:39:46 -07002768 * <p>It is perfectly acceptable for multiple receivers to process the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002769 * outgoing call in turn: for example, a parental control application
2770 * might verify that the user is authorized to place the call at that
2771 * time, then a number-rewriting application might add an area code if
2772 * one was not specified.</p>
2773 * <p>For consistency, any receiver whose purpose is to prohibit phone
2774 * calls should have a priority of 0, to ensure it will see the final
2775 * phone number to be dialed.
The Android Open Source Project10592532009-03-18 17:39:46 -07002776 * Any receiver whose purpose is to rewrite phone numbers to be called
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002777 * should have a positive priority.
2778 * Negative priorities are reserved for the system for this broadcast;
2779 * using them may cause problems.</p>
Dirk Dougherty932fbcc2013-05-29 15:19:14 -07002780 * <p>Any BroadcastReceiver receiving this Intent <em>must not</em>
2781 * abort the broadcast.</p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002782 * <p>Emergency calls cannot be intercepted using this mechanism, and
2783 * other calls cannot be modified to call emergency numbers using this
2784 * mechanism.
Santos Cordonba701362013-05-17 14:48:54 -07002785 * <p>Some apps (such as VoIP apps) may want to redirect the outgoing
2786 * call to use their own service instead. Those apps should first prevent
2787 * the call from being placed by setting resultData to <code>null</code>
2788 * and then start their own app to make the call.
The Android Open Source Project10592532009-03-18 17:39:46 -07002789 * <p>You must hold the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002790 * {@link android.Manifest.permission#PROCESS_OUTGOING_CALLS}
2791 * permission to receive this Intent.</p>
Tom Taylord4a47292009-12-21 13:59:18 -08002792 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002793 * <p class="note">This is a protected intent that can only be sent
2794 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002795 */
2796 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2797 public static final String ACTION_NEW_OUTGOING_CALL =
2798 "android.intent.action.NEW_OUTGOING_CALL";
2799
2800 /**
2801 * Broadcast Action: Have the device reboot. This is only for use by
2802 * system code.
Tom Taylord4a47292009-12-21 13:59:18 -08002803 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002804 * <p class="note">This is a protected intent that can only be sent
2805 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002806 */
2807 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2808 public static final String ACTION_REBOOT =
2809 "android.intent.action.REBOOT";
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002810
Wei Huang97ecc9c2009-05-11 17:44:20 -07002811 /**
Dianne Hackborn7299c412010-03-04 18:41:49 -08002812 * Broadcast Action: A sticky broadcast for changes in the physical
2813 * docking state of the device.
Tobias Haamel154f7a12010-02-17 11:56:39 -08002814 *
2815 * <p>The intent will have the following extra values:
2816 * <ul>
2817 * <li><em>{@link #EXTRA_DOCK_STATE}</em> - the current dock
Dianne Hackborn7299c412010-03-04 18:41:49 -08002818 * state, indicating which dock the device is physically in.</li>
Tobias Haamel154f7a12010-02-17 11:56:39 -08002819 * </ul>
Dianne Hackborn7299c412010-03-04 18:41:49 -08002820 * <p>This is intended for monitoring the current physical dock state.
2821 * See {@link android.app.UiModeManager} for the normal API dealing with
2822 * dock mode changes.
Dianne Hackbornedd93162009-09-19 14:03:05 -07002823 */
2824 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2825 public static final String ACTION_DOCK_EVENT =
2826 "android.intent.action.DOCK_EVENT";
2827
2828 /**
Svetoslavb3038ec2013-02-13 14:39:30 -08002829 * Broadcast Action: A broadcast when idle maintenance can be started.
2830 * This means that the user is not interacting with the device and is
2831 * not expected to do so soon. Typical use of the idle maintenance is
2832 * to perform somehow expensive tasks that can be postponed at a moment
2833 * when they will not degrade user experience.
2834 * <p>
2835 * <p class="note">In order to keep the device responsive in case of an
2836 * unexpected user interaction, implementations of a maintenance task
2837 * should be interruptible. In such a scenario a broadcast with action
2838 * {@link #ACTION_IDLE_MAINTENANCE_END} will be sent. In other words, you
2839 * should not do the maintenance work in
2840 * {@link BroadcastReceiver#onReceive(Context, Intent)}, rather start a
2841 * maintenance service by {@link Context#startService(Intent)}. Also
2842 * you should hold a wake lock while your maintenance service is running
2843 * to prevent the device going to sleep.
2844 * </p>
2845 * <p>
2846 * <p class="note">This is a protected intent that can only be sent by
2847 * the system.
2848 * </p>
2849 *
2850 * @see #ACTION_IDLE_MAINTENANCE_END
Svetoslav6a08a122013-05-03 11:24:26 -07002851 *
2852 * @hide
Svetoslavb3038ec2013-02-13 14:39:30 -08002853 */
2854 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2855 public static final String ACTION_IDLE_MAINTENANCE_START =
2856 "android.intent.action.ACTION_IDLE_MAINTENANCE_START";
2857
2858 /**
2859 * Broadcast Action: A broadcast when idle maintenance should be stopped.
2860 * This means that the user was not interacting with the device as a result
2861 * of which a broadcast with action {@link #ACTION_IDLE_MAINTENANCE_START}
2862 * was sent and now the user started interacting with the device. Typical
2863 * use of the idle maintenance is to perform somehow expensive tasks that
2864 * can be postponed at a moment when they will not degrade user experience.
2865 * <p>
2866 * <p class="note">In order to keep the device responsive in case of an
2867 * unexpected user interaction, implementations of a maintenance task
2868 * should be interruptible. Hence, on receiving a broadcast with this
2869 * action, the maintenance task should be interrupted as soon as possible.
2870 * In other words, you should not do the maintenance work in
2871 * {@link BroadcastReceiver#onReceive(Context, Intent)}, rather stop the
2872 * maintenance service that was started on receiving of
2873 * {@link #ACTION_IDLE_MAINTENANCE_START}.Also you should release the wake
2874 * lock you acquired when your maintenance service started.
2875 * </p>
2876 * <p class="note">This is a protected intent that can only be sent
2877 * by the system.
2878 *
2879 * @see #ACTION_IDLE_MAINTENANCE_START
Svetoslav6a08a122013-05-03 11:24:26 -07002880 *
2881 * @hide
Svetoslavb3038ec2013-02-13 14:39:30 -08002882 */
2883 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2884 public static final String ACTION_IDLE_MAINTENANCE_END =
2885 "android.intent.action.ACTION_IDLE_MAINTENANCE_END";
2886
2887 /**
Wei Huang97ecc9c2009-05-11 17:44:20 -07002888 * Broadcast Action: a remote intent is to be broadcasted.
2889 *
2890 * A remote intent is used for remote RPC between devices. The remote intent
2891 * is serialized and sent from one device to another device. The receiving
2892 * device parses the remote intent and broadcasts it. Note that anyone can
2893 * broadcast a remote intent. However, if the intent receiver of the remote intent
2894 * does not trust intent broadcasts from arbitrary intent senders, it should require
2895 * the sender to hold certain permissions so only trusted sender's broadcast will be
2896 * let through.
Dianne Hackbornedd93162009-09-19 14:03:05 -07002897 * @hide
Wei Huang97ecc9c2009-05-11 17:44:20 -07002898 */
2899 public static final String ACTION_REMOTE_INTENT =
Costin Manolache8d83f9e2010-05-12 16:04:10 -07002900 "com.google.android.c2dm.intent.RECEIVE";
Wei Huang97ecc9c2009-05-11 17:44:20 -07002901
Dianne Hackborn9acc0302009-08-25 00:27:12 -07002902 /**
Jeff Sharkeybd91e2f2016-03-22 15:32:31 -06002903 * Broadcast Action: This is broadcast once when the user is booting after a
2904 * system update. It can be used to perform cleanup or upgrades after a
2905 * system update.
2906 * <p>
2907 * This broadcast is sent after the {@link #ACTION_LOCKED_BOOT_COMPLETED}
2908 * broadcast but before the {@link #ACTION_BOOT_COMPLETED} broadcast. It's
2909 * only sent when the {@link Build#FINGERPRINT} has changed, and it's only
2910 * sent to receivers in the system image.
Dianne Hackborn9acc0302009-08-25 00:27:12 -07002911 *
Dianne Hackborn9acc0302009-08-25 00:27:12 -07002912 * @hide
2913 */
Amith Yamasanicbabb8d2017-02-17 16:50:05 -08002914 @SystemApi
Dianne Hackborn9acc0302009-08-25 00:27:12 -07002915 public static final String ACTION_PRE_BOOT_COMPLETED =
2916 "android.intent.action.PRE_BOOT_COMPLETED";
2917
Amith Yamasani13593602012-03-22 16:16:17 -07002918 /**
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08002919 * Broadcast to a specific application to query any supported restrictions to impose
Amith Yamasani7e99bc02013-04-16 18:24:51 -07002920 * on restricted users. The broadcast intent contains an extra
2921 * {@link #EXTRA_RESTRICTIONS_BUNDLE} with the currently persisted
2922 * restrictions as a Bundle of key/value pairs. The value types can be Boolean, String or
2923 * String[] depending on the restriction type.<p/>
2924 * The response should contain an extra {@link #EXTRA_RESTRICTIONS_LIST},
Amith Yamasani86118ba2013-03-28 14:33:16 -07002925 * which is of type <code>ArrayList&lt;RestrictionEntry&gt;</code>. It can also
2926 * contain an extra {@link #EXTRA_RESTRICTIONS_INTENT}, which is of type <code>Intent</code>.
2927 * The activity specified by that intent will be launched for a result which must contain
Amith Yamasani3b458ad2013-04-18 18:40:07 -07002928 * one of the extras {@link #EXTRA_RESTRICTIONS_LIST} or {@link #EXTRA_RESTRICTIONS_BUNDLE}.
2929 * The keys and values of the returned restrictions will be persisted.
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08002930 * @see RestrictionEntry
2931 */
2932 public static final String ACTION_GET_RESTRICTION_ENTRIES =
2933 "android.intent.action.GET_RESTRICTION_ENTRIES";
2934
2935 /**
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002936 * Sent the first time a user is starting, to allow system apps to
2937 * perform one time initialization. (This will not be seen by third
2938 * party applications because a newly initialized user does not have any
2939 * third party applications installed for it.) This is sent early in
2940 * starting the user, around the time the home app is started, before
Dianne Hackborn36d337a2012-10-08 14:33:47 -07002941 * {@link #ACTION_BOOT_COMPLETED} is sent. This is sent as a foreground
2942 * broadcast, since it is part of a visible user interaction; be as quick
2943 * as possible when handling it.
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002944 */
2945 public static final String ACTION_USER_INITIALIZE =
2946 "android.intent.action.USER_INITIALIZE";
2947
2948 /**
2949 * Sent when a user switch is happening, causing the process's user to be
2950 * brought to the foreground. This is only sent to receivers registered
2951 * through {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
2952 * Context.registerReceiver}. It is sent to the user that is going to the
Dianne Hackborn36d337a2012-10-08 14:33:47 -07002953 * foreground. This is sent as a foreground
2954 * broadcast, since it is part of a visible user interaction; be as quick
2955 * as possible when handling it.
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002956 */
2957 public static final String ACTION_USER_FOREGROUND =
2958 "android.intent.action.USER_FOREGROUND";
2959
2960 /**
2961 * Sent when a user switch is happening, causing the process's user to be
2962 * sent to the background. This is only sent to receivers registered
2963 * through {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
2964 * Context.registerReceiver}. It is sent to the user that is going to the
Dianne Hackborn36d337a2012-10-08 14:33:47 -07002965 * background. This is sent as a foreground
2966 * broadcast, since it is part of a visible user interaction; be as quick
2967 * as possible when handling it.
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002968 */
2969 public static final String ACTION_USER_BACKGROUND =
2970 "android.intent.action.USER_BACKGROUND";
2971
2972 /**
Dianne Hackborn36d337a2012-10-08 14:33:47 -07002973 * Broadcast sent to the system when a user is added. Carries an extra
2974 * EXTRA_USER_HANDLE that has the userHandle of the new user. It is sent to
2975 * all running users. You must hold
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002976 * {@link android.Manifest.permission#MANAGE_USERS} to receive this broadcast.
Amith Yamasani13593602012-03-22 16:16:17 -07002977 * @hide
2978 */
2979 public static final String ACTION_USER_ADDED =
2980 "android.intent.action.USER_ADDED";
2981
2982 /**
Dianne Hackborn36d337a2012-10-08 14:33:47 -07002983 * Broadcast sent by the system when a user is started. Carries an extra
2984 * EXTRA_USER_HANDLE that has the userHandle of the user. This is only sent to
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002985 * registered receivers, not manifest receivers. It is sent to the user
Dianne Hackborn36d337a2012-10-08 14:33:47 -07002986 * that has been started. This is sent as a foreground
2987 * broadcast, since it is part of a visible user interaction; be as quick
2988 * as possible when handling it.
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002989 * @hide
2990 */
2991 public static final String ACTION_USER_STARTED =
2992 "android.intent.action.USER_STARTED";
2993
2994 /**
Dianne Hackborn36d337a2012-10-08 14:33:47 -07002995 * Broadcast sent when a user is in the process of starting. Carries an extra
2996 * EXTRA_USER_HANDLE that has the userHandle of the user. This is only
2997 * sent to registered receivers, not manifest receivers. It is sent to all
2998 * users (including the one that is being started). You must hold
2999 * {@link android.Manifest.permission#INTERACT_ACROSS_USERS} to receive
3000 * this broadcast. This is sent as a background broadcast, since
3001 * its result is not part of the primary UX flow; to safely keep track of
3002 * started/stopped state of a user you can use this in conjunction with
3003 * {@link #ACTION_USER_STOPPING}. It is <b>not</b> generally safe to use with
3004 * other user state broadcasts since those are foreground broadcasts so can
3005 * execute in a different order.
3006 * @hide
3007 */
3008 public static final String ACTION_USER_STARTING =
3009 "android.intent.action.USER_STARTING";
3010
3011 /**
3012 * Broadcast sent when a user is going to be stopped. Carries an extra
3013 * EXTRA_USER_HANDLE that has the userHandle of the user. This is only
3014 * sent to registered receivers, not manifest receivers. It is sent to all
3015 * users (including the one that is being stopped). You must hold
3016 * {@link android.Manifest.permission#INTERACT_ACROSS_USERS} to receive
3017 * this broadcast. The user will not stop until all receivers have
3018 * handled the broadcast. This is sent as a background broadcast, since
3019 * its result is not part of the primary UX flow; to safely keep track of
3020 * started/stopped state of a user you can use this in conjunction with
3021 * {@link #ACTION_USER_STARTING}. It is <b>not</b> generally safe to use with
3022 * other user state broadcasts since those are foreground broadcasts so can
3023 * execute in a different order.
3024 * @hide
3025 */
3026 public static final String ACTION_USER_STOPPING =
3027 "android.intent.action.USER_STOPPING";
3028
3029 /**
3030 * Broadcast sent to the system when a user is stopped. Carries an extra
3031 * EXTRA_USER_HANDLE that has the userHandle of the user. This is similar to
3032 * {@link #ACTION_PACKAGE_RESTARTED}, but for an entire user instead of a
3033 * specific package. This is only sent to registered receivers, not manifest
3034 * receivers. It is sent to all running users <em>except</em> the one that
3035 * has just been stopped (which is no longer running).
Dianne Hackborn80a4af22012-08-27 19:18:31 -07003036 * @hide
3037 */
3038 public static final String ACTION_USER_STOPPED =
3039 "android.intent.action.USER_STOPPED";
3040
3041 /**
Amith Yamasani2a003292012-08-14 18:25:45 -07003042 * 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 -07003043 * the userHandle of the user. It is sent to all running users except the
Amith Yamasanidb6a14c2012-10-17 21:16:52 -07003044 * one that has been removed. The user will not be completely removed until all receivers have
3045 * handled the broadcast. You must hold
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07003046 * {@link android.Manifest.permission#MANAGE_USERS} to receive this broadcast.
Amith Yamasani13593602012-03-22 16:16:17 -07003047 * @hide
3048 */
3049 public static final String ACTION_USER_REMOVED =
3050 "android.intent.action.USER_REMOVED";
3051
3052 /**
Amith Yamasani2a003292012-08-14 18:25:45 -07003053 * Broadcast sent to the system when the user switches. Carries an extra EXTRA_USER_HANDLE that has
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07003054 * the userHandle of the user to become the current one. This is only sent to
3055 * registered receivers, not manifest receivers. It is sent to all running users.
3056 * You must hold
3057 * {@link android.Manifest.permission#MANAGE_USERS} to receive this broadcast.
Amith Yamasani13593602012-03-22 16:16:17 -07003058 * @hide
3059 */
3060 public static final String ACTION_USER_SWITCHED =
3061 "android.intent.action.USER_SWITCHED";
3062
Amith Yamasanie928d7d2012-09-17 21:46:51 -07003063 /**
Jeff Sharkey8924e872015-11-30 12:52:10 -07003064 * Broadcast Action: Sent when the credential-encrypted private storage has
3065 * become unlocked for the target user. This is only sent to registered
3066 * receivers, not manifest receivers.
3067 */
3068 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3069 public static final String ACTION_USER_UNLOCKED = "android.intent.action.USER_UNLOCKED";
3070
3071 /**
Amith Yamasanie928d7d2012-09-17 21:46:51 -07003072 * Broadcast sent to the system when a user's information changes. Carries an extra
3073 * {@link #EXTRA_USER_HANDLE} to indicate which user's information changed.
Amith Yamasani6fc1d4e2013-05-08 16:43:58 -07003074 * This is only sent to registered receivers, not manifest receivers. It is sent to all users.
Amith Yamasanie928d7d2012-09-17 21:46:51 -07003075 * @hide
3076 */
3077 public static final String ACTION_USER_INFO_CHANGED =
3078 "android.intent.action.USER_INFO_CHANGED";
3079
Daniel Sandler2e7d25b2012-10-01 16:43:26 -04003080 /**
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01003081 * Broadcast sent to the primary user when an associated managed profile is added (the profile
3082 * was created and is ready to be used). Carries an extra {@link #EXTRA_USER} that specifies
Adam Connorsd4b584e2014-06-09 13:55:47 +01003083 * the UserHandle of the profile that was added. Only applications (for example Launchers)
3084 * that need to display merged content across both primary and managed profiles need to
3085 * worry about this broadcast. This is only sent to registered receivers,
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01003086 * not manifest receivers.
3087 */
3088 public static final String ACTION_MANAGED_PROFILE_ADDED =
3089 "android.intent.action.MANAGED_PROFILE_ADDED";
3090
3091 /**
3092 * Broadcast sent to the primary user when an associated managed profile is removed. Carries an
Adam Connorsd4b584e2014-06-09 13:55:47 +01003093 * extra {@link #EXTRA_USER} that specifies the UserHandle of the profile that was removed.
3094 * Only applications (for example Launchers) that need to display merged content across both
3095 * primary and managed profiles need to worry about this broadcast. This is only sent to
3096 * registered receivers, not manifest receivers.
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01003097 */
3098 public static final String ACTION_MANAGED_PROFILE_REMOVED =
3099 "android.intent.action.MANAGED_PROFILE_REMOVED";
3100
3101 /**
Kenny Guyb1b30262016-02-09 16:02:35 +00003102 * Broadcast sent to the primary user when the credential-encrypted private storage for
3103 * an associated managed profile is unlocked. Carries an extra {@link #EXTRA_USER} that
3104 * specifies the UserHandle of the profile that was unlocked. Only applications (for example
3105 * Launchers) that need to display merged content across both primary and managed profiles
3106 * need to worry about this broadcast. This is only sent to registered receivers,
3107 * not manifest receivers.
3108 */
3109 public static final String ACTION_MANAGED_PROFILE_UNLOCKED =
3110 "android.intent.action.MANAGED_PROFILE_UNLOCKED";
3111
3112 /**
Rubin Xue95057a2016-04-01 16:49:25 +01003113 * Broadcast sent to the primary user when an associated managed profile has become available.
3114 * Currently this includes when the user disables quiet mode for the profile. Carries an extra
Rubin Xuf13c9802016-01-21 18:06:00 +00003115 * {@link #EXTRA_USER} that specifies the UserHandle of the profile. When quiet mode is changed,
3116 * this broadcast will carry a boolean extra {@link #EXTRA_QUIET_MODE} indicating the new state
3117 * of quiet mode. This is only sent to registered receivers, not manifest receivers.
Rubin Xu0a29ecd2015-11-04 15:11:48 +00003118 */
Rubin Xue95057a2016-04-01 16:49:25 +01003119 public static final String ACTION_MANAGED_PROFILE_AVAILABLE =
3120 "android.intent.action.MANAGED_PROFILE_AVAILABLE";
3121
3122 /**
3123 * Broadcast sent to the primary user when an associated managed profile has become unavailable.
3124 * Currently this includes when the user enables quiet mode for the profile. Carries an extra
3125 * {@link #EXTRA_USER} that specifies the UserHandle of the profile. When quiet mode is changed,
3126 * this broadcast will carry a boolean extra {@link #EXTRA_QUIET_MODE} indicating the new state
3127 * of quiet mode. This is only sent to registered receivers, not manifest receivers.
3128 */
3129 public static final String ACTION_MANAGED_PROFILE_UNAVAILABLE =
3130 "android.intent.action.MANAGED_PROFILE_UNAVAILABLE";
Rubin Xu0a29ecd2015-11-04 15:11:48 +00003131
3132 /**
Robin Lee92b83c62016-08-31 13:27:51 +01003133 * Broadcast sent to the system user when the 'device locked' state changes for any user.
3134 * Carries an extra {@link #EXTRA_USER_HANDLE} that specifies the ID of the user for which
3135 * the device was locked or unlocked.
3136 *
3137 * This is only sent to registered receivers.
3138 *
3139 * @hide
3140 */
3141 public static final String ACTION_DEVICE_LOCKED_CHANGED =
3142 "android.intent.action.DEVICE_LOCKED_CHANGED";
3143
3144 /**
Daniel Sandler2e7d25b2012-10-01 16:43:26 -04003145 * Sent when the user taps on the clock widget in the system's "quick settings" area.
3146 */
3147 public static final String ACTION_QUICK_CLOCK =
3148 "android.intent.action.QUICK_CLOCK";
3149
Michael Wright0087a142013-02-05 16:29:39 -08003150 /**
Alan Viverette5a399492014-07-14 16:19:38 -07003151 * Activity Action: Shows the brightness setting dialog.
Michael Wright0087a142013-02-05 16:29:39 -08003152 * @hide
3153 */
3154 public static final String ACTION_SHOW_BRIGHTNESS_DIALOG =
Clara Bayarri847d8682017-03-06 16:48:44 +00003155 "com.android.intent.action.SHOW_BRIGHTNESS_DIALOG";
Michael Wright0087a142013-02-05 16:29:39 -08003156
Justin Kohd378ad72013-04-01 12:18:26 -07003157 /**
3158 * Broadcast Action: A global button was pressed. Includes a single
3159 * extra field, {@link #EXTRA_KEY_EVENT}, containing the key event that
3160 * caused the broadcast.
3161 * @hide
3162 */
3163 public static final String ACTION_GLOBAL_BUTTON = "android.intent.action.GLOBAL_BUTTON";
3164
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003165 /**
Dongwon Kang2034a4c2015-12-14 21:57:34 +09003166 * Broadcast Action: Sent when media resource is granted.
3167 * <p>
3168 * {@link #EXTRA_PACKAGES} specifies the packages on the process holding the media resource
3169 * granted.
3170 * </p>
3171 * <p class="note">
3172 * This is a protected intent that can only be sent by the system.
3173 * </p>
3174 * <p class="note">
Dongwon Kang32cb9ab2016-01-13 18:11:10 -08003175 * This requires {@link android.Manifest.permission#RECEIVE_MEDIA_RESOURCE_USAGE} permission.
Dongwon Kang2034a4c2015-12-14 21:57:34 +09003176 * </p>
3177 *
3178 * @hide
3179 */
3180 public static final String ACTION_MEDIA_RESOURCE_GRANTED =
3181 "android.intent.action.MEDIA_RESOURCE_GRANTED";
3182
3183 /**
MÃ¥rten Kongstadeabc9e92015-12-15 16:40:23 +01003184 * Broadcast Action: An overlay package has been installed. The data
3185 * contains the name of the added overlay package.
3186 * @hide
3187 */
3188 public static final String ACTION_OVERLAY_ADDED = "android.intent.action.OVERLAY_ADDED";
3189
3190 /**
3191 * Broadcast Action: An overlay package has changed. The data contains the
3192 * name of the overlay package which has changed. This is broadcast on all
3193 * changes to the OverlayInfo returned by {@link
3194 * android.content.om.IOverlayManager#getOverlayInfo(String, int)}. The
3195 * most common change is a state change that will change whether the
3196 * overlay is enabled or not.
3197 * @hide
3198 */
3199 public static final String ACTION_OVERLAY_CHANGED = "android.intent.action.OVERLAY_CHANGED";
3200
3201 /**
3202 * Broadcast Action: An overlay package has been removed. The data contains
3203 * the name of the overlay package which has been removed.
3204 * @hide
3205 */
3206 public static final String ACTION_OVERLAY_REMOVED = "android.intent.action.OVERLAY_REMOVED";
3207
3208 /**
3209 * Broadcast Action: The order of a package's list of overlay packages has
3210 * changed. The data contains the package name of the overlay package that
3211 * had its position in the list adjusted.
3212 * @hide
3213 */
3214 public static final String
3215 ACTION_OVERLAY_PRIORITY_CHANGED = "android.intent.action.OVERLAY_PRIORITY_CHANGED";
3216
3217 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003218 * Activity Action: Allow the user to select and return one or more existing
3219 * documents. When invoked, the system will display the various
3220 * {@link DocumentsProvider} instances installed on the device, letting the
3221 * user interactively navigate through them. These documents include local
3222 * media, such as photos and video, and documents provided by installed
3223 * cloud storage providers.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003224 * <p>
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003225 * Each document is represented as a {@code content://} URI backed by a
3226 * {@link DocumentsProvider}, which can be opened as a stream with
3227 * {@link ContentResolver#openFileDescriptor(Uri, String)}, or queried for
3228 * {@link android.provider.DocumentsContract.Document} metadata.
3229 * <p>
3230 * All selected documents are returned to the calling application with
3231 * persistable read and write permission grants. If you want to maintain
3232 * access to the documents across device reboots, you need to explicitly
3233 * take the persistable permissions using
3234 * {@link ContentResolver#takePersistableUriPermission(Uri, int)}.
3235 * <p>
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003236 * Callers must indicate the acceptable document MIME types through
3237 * {@link #setType(String)}. For example, to select photos, use
3238 * {@code image/*}. If multiple disjoint MIME types are acceptable, define
3239 * them in {@link #EXTRA_MIME_TYPES} and {@link #setType(String)} to
3240 * {@literal *}/*.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003241 * <p>
3242 * If the caller can handle multiple returned items (the user performing
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003243 * multiple selection), then you can specify {@link #EXTRA_ALLOW_MULTIPLE}
3244 * to indicate this.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003245 * <p>
Tomasz Mikolajewskia8057a92015-11-16 11:41:28 +09003246 * Callers must include {@link #CATEGORY_OPENABLE} in the Intent to obtain
3247 * URIs that can be opened with
Jeff Sharkeybd3b9022013-08-20 15:20:04 -07003248 * {@link ContentResolver#openFileDescriptor(Uri, String)}.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003249 * <p>
Garfield Tanb44ae612016-11-07 16:46:37 -08003250 * Callers can set a document URI through
3251 * {@link DocumentsContract#EXTRA_INITIAL_URI} to indicate the initial
3252 * location of documents navigator. System will do its best to launch the
3253 * navigator in the specified document if it's a folder, or the folder that
3254 * contains the specified document if not.
Garfield Tan0b3cf662016-10-31 12:59:45 -07003255 * <p>
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003256 * Output: The URI of the item that was picked, returned in
3257 * {@link #getData()}. This must be a {@code content://} URI so that any
3258 * receiver can access it. If multiple documents were selected, they are
3259 * returned in {@link #getClipData()}.
Jeff Sharkeybd3b9022013-08-20 15:20:04 -07003260 *
3261 * @see DocumentsContract
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003262 * @see #ACTION_OPEN_DOCUMENT_TREE
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003263 * @see #ACTION_CREATE_DOCUMENT
3264 * @see #FLAG_GRANT_PERSISTABLE_URI_PERMISSION
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003265 */
3266 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
3267 public static final String ACTION_OPEN_DOCUMENT = "android.intent.action.OPEN_DOCUMENT";
3268
3269 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003270 * Activity Action: Allow the user to create a new document. When invoked,
3271 * the system will display the various {@link DocumentsProvider} instances
3272 * installed on the device, letting the user navigate through them. The
3273 * returned document may be a newly created document with no content, or it
3274 * may be an existing document with the requested MIME type.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003275 * <p>
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003276 * Each document is represented as a {@code content://} URI backed by a
3277 * {@link DocumentsProvider}, which can be opened as a stream with
3278 * {@link ContentResolver#openFileDescriptor(Uri, String)}, or queried for
3279 * {@link android.provider.DocumentsContract.Document} metadata.
3280 * <p>
3281 * Callers must indicate the concrete MIME type of the document being
3282 * created by setting {@link #setType(String)}. This MIME type cannot be
3283 * changed after the document is created.
3284 * <p>
3285 * Callers can provide an initial display name through {@link #EXTRA_TITLE},
3286 * but the user may change this value before creating the file.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003287 * <p>
Tomasz Mikolajewskia8057a92015-11-16 11:41:28 +09003288 * Callers must include {@link #CATEGORY_OPENABLE} in the Intent to obtain
3289 * URIs that can be opened with
Jeff Sharkeybd3b9022013-08-20 15:20:04 -07003290 * {@link ContentResolver#openFileDescriptor(Uri, String)}.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003291 * <p>
Garfield Tanb44ae612016-11-07 16:46:37 -08003292 * Callers can set a document URI through
3293 * {@link DocumentsContract#EXTRA_INITIAL_URI} to indicate the initial
3294 * location of documents navigator. System will do its best to launch the
3295 * navigator in the specified document if it's a folder, or the folder that
3296 * contains the specified document if not.
Garfield Tan0b3cf662016-10-31 12:59:45 -07003297 * <p>
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003298 * Output: The URI of the item that was created. This must be a
3299 * {@code content://} URI so that any receiver can access it.
Jeff Sharkeybd3b9022013-08-20 15:20:04 -07003300 *
3301 * @see DocumentsContract
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003302 * @see #ACTION_OPEN_DOCUMENT
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003303 * @see #ACTION_OPEN_DOCUMENT_TREE
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003304 * @see #FLAG_GRANT_PERSISTABLE_URI_PERMISSION
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003305 */
3306 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
3307 public static final String ACTION_CREATE_DOCUMENT = "android.intent.action.CREATE_DOCUMENT";
3308
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003309 /**
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003310 * Activity Action: Allow the user to pick a directory subtree. When
3311 * invoked, the system will display the various {@link DocumentsProvider}
3312 * instances installed on the device, letting the user navigate through
3313 * them. Apps can fully manage documents within the returned directory.
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003314 * <p>
3315 * To gain access to descendant (child, grandchild, etc) documents, use
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003316 * {@link DocumentsContract#buildDocumentUriUsingTree(Uri, String)} and
3317 * {@link DocumentsContract#buildChildDocumentsUriUsingTree(Uri, String)}
3318 * with the returned URI.
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003319 * <p>
Garfield Tanb44ae612016-11-07 16:46:37 -08003320 * Callers can set a document URI through
3321 * {@link DocumentsContract#EXTRA_INITIAL_URI} to indicate the initial
3322 * location of documents navigator. System will do its best to launch the
3323 * navigator in the specified document if it's a folder, or the folder that
3324 * contains the specified document if not.
Garfield Tan0b3cf662016-10-31 12:59:45 -07003325 * <p>
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003326 * Output: The URI representing the selected directory tree.
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003327 *
3328 * @see DocumentsContract
3329 */
3330 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003331 public static final String
3332 ACTION_OPEN_DOCUMENT_TREE = "android.intent.action.OPEN_DOCUMENT_TREE";
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003333
Felipe Lemec7b1f892016-01-15 15:02:31 -08003334 /**
Peng Xua35b5532016-01-20 00:05:45 -08003335 * Broadcast Action: List of dynamic sensor is changed due to new sensor being connected or
3336 * exisiting sensor being disconnected.
3337 *
3338 * <p class="note">This is a protected intent that can only be sent by the system.</p>
3339 *
3340 * {@hide}
3341 */
3342 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3343 public static final String
3344 ACTION_DYNAMIC_SENSOR_CHANGED = "android.intent.action.DYNAMIC_SENSOR_CHANGED";
3345
Lenka Trochtova73aeea22016-11-18 17:34:34 +01003346 /**
3347 * Deprecated - use {@link #ACTION_FACTORY_RESET} instead.
3348 *
3349 * {@hide}
3350 */
3351 @Deprecated
Jeff Sharkey004a4b22014-09-24 11:45:24 -07003352 public static final String ACTION_MASTER_CLEAR = "android.intent.action.MASTER_CLEAR";
3353
Christopher Tate6597e342015-02-17 12:15:25 -08003354 /**
Amith Yamasanicbabb8d2017-02-17 16:50:05 -08003355 * Broadcast intent sent by the RecoverySystem to inform listeners that a master clear (wipe)
3356 * is about to be performed.
3357 * @hide
3358 */
3359 @SystemApi
3360 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3361 public static final String ACTION_MASTER_CLEAR_NOTIFICATION
3362 = "android.intent.action.MASTER_CLEAR_NOTIFICATION";
3363
3364 /**
Lenka Trochtova73aeea22016-11-18 17:34:34 +01003365 * Boolean intent extra to be used with {@link #ACTION_MASTER_CLEAR} in order to force a factory
3366 * reset even if {@link android.os.UserManager#DISALLOW_FACTORY_RESET} is set.
3367 *
3368 * <p>Deprecated - use {@link #EXTRA_FORCE_FACTORY_RESET} instead.
3369 *
Benjamin Franzf9d5e6a2016-05-26 14:24:29 +01003370 * @hide
3371 */
Lenka Trochtova73aeea22016-11-18 17:34:34 +01003372 @Deprecated
Benjamin Franzf9d5e6a2016-05-26 14:24:29 +01003373 public static final String EXTRA_FORCE_MASTER_CLEAR =
3374 "android.intent.extra.FORCE_MASTER_CLEAR";
3375
3376 /**
Lenka Trochtova73aeea22016-11-18 17:34:34 +01003377 * A broadcast action to trigger a factory reset.
3378 *
3379 * <p> The sender must hold the {@link android.Manifest.permission#MASTER_CLEAR} permission.
3380 *
3381 * <p>Not for use by third-party applications.
3382 *
3383 * @see #EXTRA_FORCE_MASTER_CLEAR
3384 *
3385 * {@hide}
3386 */
3387 @SystemApi
3388 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3389 public static final String ACTION_FACTORY_RESET = "android.intent.action.FACTORY_RESET";
3390
3391 /**
3392 * Boolean intent extra to be used with {@link #ACTION_MASTER_CLEAR} in order to force a factory
3393 * reset even if {@link android.os.UserManager#DISALLOW_FACTORY_RESET} is set.
3394 *
3395 * <p>Not for use by third-party applications.
3396 *
3397 * @hide
3398 */
3399 @SystemApi
3400 public static final String EXTRA_FORCE_FACTORY_RESET =
3401 "android.intent.extra.FORCE_FACTORY_RESET";
3402
3403 /**
Christopher Tate6597e342015-02-17 12:15:25 -08003404 * Broadcast action: report that a settings element is being restored from backup. The intent
3405 * contains three extras: EXTRA_SETTING_NAME is a string naming the restored setting,
3406 * EXTRA_SETTING_NEW_VALUE is the value being restored, and EXTRA_SETTING_PREVIOUS_VALUE
3407 * is the value of that settings entry prior to the restore operation. All of these values are
3408 * represented as strings.
3409 *
3410 * <p>This broadcast is sent only for settings provider entries known to require special handling
3411 * around restore time. These entries are found in the BROADCAST_ON_RESTORE table within
3412 * the provider's backup agent implementation.
3413 *
3414 * @see #EXTRA_SETTING_NAME
3415 * @see #EXTRA_SETTING_PREVIOUS_VALUE
3416 * @see #EXTRA_SETTING_NEW_VALUE
3417 * {@hide}
3418 */
3419 public static final String ACTION_SETTING_RESTORED = "android.os.action.SETTING_RESTORED";
3420
3421 /** {@hide} */
3422 public static final String EXTRA_SETTING_NAME = "setting_name";
3423 /** {@hide} */
3424 public static final String EXTRA_SETTING_PREVIOUS_VALUE = "previous_value";
3425 /** {@hide} */
3426 public static final String EXTRA_SETTING_NEW_VALUE = "new_value";
3427
Clara Bayarri0a26157a2015-03-26 18:38:55 +00003428 /**
3429 * Activity Action: Process a piece of text.
3430 * <p>Input: {@link #EXTRA_PROCESS_TEXT} contains the text to be processed.
3431 * {@link #EXTRA_PROCESS_TEXT_READONLY} states if the resulting text will be read-only.</p>
3432 * <p>Output: {@link #EXTRA_PROCESS_TEXT} contains the processed text.</p>
3433 */
3434 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
3435 public static final String ACTION_PROCESS_TEXT = "android.intent.action.PROCESS_TEXT";
Amith Yamasanicbabb8d2017-02-17 16:50:05 -08003436
3437 /**
3438 * Broadcast Action: The sim card state has changed.
3439 * For more details see TelephonyIntents.ACTION_SIM_STATE_CHANGED. This is here
3440 * because TelephonyIntents is an internal class.
3441 * @hide
3442 */
3443 @SystemApi
3444 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3445 public static final String ACTION_SIM_STATE_CHANGED = "android.intent.action.SIM_STATE_CHANGED";
3446
Clara Bayarri0a26157a2015-03-26 18:38:55 +00003447 /**
Clara Bayarri92c8e6f2015-05-21 17:50:08 +01003448 * The name of the extra used to define the text to be processed, as a
3449 * CharSequence. Note that this may be a styled CharSequence, so you must use
3450 * {@link Bundle#getCharSequence(String) Bundle.getCharSequence()} to retrieve it.
Clara Bayarri0a26157a2015-03-26 18:38:55 +00003451 */
3452 public static final String EXTRA_PROCESS_TEXT = "android.intent.extra.PROCESS_TEXT";
3453 /**
Clara Bayarri92c8e6f2015-05-21 17:50:08 +01003454 * 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 +00003455 */
3456 public static final String EXTRA_PROCESS_TEXT_READONLY =
3457 "android.intent.extra.PROCESS_TEXT_READONLY";
3458
Bryce Leebc58f592015-09-25 16:43:01 -07003459 /**
3460 * Broadcast action: reports when a new thermal event has been reached. When the device
3461 * is reaching its maximum temperatue, the thermal level reported
3462 * {@hide}
3463 */
3464 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
3465 public static final String ACTION_THERMAL_EVENT = "android.intent.action.THERMAL_EVENT";
3466
3467 /** {@hide} */
3468 public static final String EXTRA_THERMAL_STATE = "android.intent.extra.THERMAL_STATE";
3469
3470 /**
3471 * Thermal state when the device is normal. This state is sent in the
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08003472 * {@link #ACTION_THERMAL_EVENT} broadcast as {@link #EXTRA_THERMAL_STATE}.
Bryce Leebc58f592015-09-25 16:43:01 -07003473 * {@hide}
3474 */
3475 public static final int EXTRA_THERMAL_STATE_NORMAL = 0;
3476
3477 /**
3478 * Thermal state where the device is approaching its maximum threshold. This state is sent in
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08003479 * the {@link #ACTION_THERMAL_EVENT} broadcast as {@link #EXTRA_THERMAL_STATE}.
Bryce Leebc58f592015-09-25 16:43:01 -07003480 * {@hide}
3481 */
3482 public static final int EXTRA_THERMAL_STATE_WARNING = 1;
3483
3484 /**
3485 * Thermal state where the device has reached its maximum threshold. This state is sent in the
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08003486 * {@link #ACTION_THERMAL_EVENT} broadcast as {@link #EXTRA_THERMAL_STATE}.
Bryce Leebc58f592015-09-25 16:43:01 -07003487 * {@hide}
3488 */
3489 public static final int EXTRA_THERMAL_STATE_EXCEEDED = 2;
3490
3491
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003492 // ---------------------------------------------------------------------
3493 // ---------------------------------------------------------------------
3494 // Standard intent categories (see addCategory()).
3495
3496 /**
3497 * Set if the activity should be an option for the default action
3498 * (center press) to perform on a piece of data. Setting this will
3499 * hide from the user any activities without it set when performing an
John Spurlock6098c5d2013-06-17 10:32:46 -04003500 * action on some data. Note that this is normally -not- set in the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003501 * Intent when initiating an action -- it is for use in intent filters
3502 * specified in packages.
3503 */
3504 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3505 public static final String CATEGORY_DEFAULT = "android.intent.category.DEFAULT";
3506 /**
3507 * Activities that can be safely invoked from a browser must support this
3508 * category. For example, if the user is viewing a web page or an e-mail
3509 * and clicks on a link in the text, the Intent generated execute that
3510 * link will require the BROWSABLE category, so that only activities
3511 * supporting this category will be considered as possible actions. By
3512 * supporting this category, you are promising that there is nothing
3513 * damaging (without user intervention) that can happen by invoking any
3514 * matching Intent.
3515 */
3516 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3517 public static final String CATEGORY_BROWSABLE = "android.intent.category.BROWSABLE";
3518 /**
Dianne Hackborn91097de2014-04-04 18:02:06 -07003519 * Categories for activities that can participate in voice interaction.
3520 * An activity that supports this category must be prepared to run with
3521 * no UI shown at all (though in some case it may have a UI shown), and
3522 * rely on {@link android.app.VoiceInteractor} to interact with the user.
3523 */
3524 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3525 public static final String CATEGORY_VOICE = "android.intent.category.VOICE";
3526 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003527 * Set if the activity should be considered as an alternative action to
3528 * the data the user is currently viewing. See also
3529 * {@link #CATEGORY_SELECTED_ALTERNATIVE} for an alternative action that
3530 * applies to the selection in a list of items.
3531 *
3532 * <p>Supporting this category means that you would like your activity to be
3533 * displayed in the set of alternative things the user can do, usually as
3534 * part of the current activity's options menu. You will usually want to
3535 * include a specific label in the &lt;intent-filter&gt; of this action
3536 * describing to the user what it does.
3537 *
3538 * <p>The action of IntentFilter with this category is important in that it
3539 * describes the specific action the target will perform. This generally
3540 * should not be a generic action (such as {@link #ACTION_VIEW}, but rather
3541 * a specific name such as "com.android.camera.action.CROP. Only one
3542 * alternative of any particular action will be shown to the user, so using
3543 * a specific action like this makes sure that your alternative will be
3544 * displayed while also allowing other applications to provide their own
3545 * overrides of that particular action.
3546 */
3547 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3548 public static final String CATEGORY_ALTERNATIVE = "android.intent.category.ALTERNATIVE";
3549 /**
3550 * Set if the activity should be considered as an alternative selection
3551 * action to the data the user has currently selected. This is like
3552 * {@link #CATEGORY_ALTERNATIVE}, but is used in activities showing a list
3553 * of items from which the user can select, giving them alternatives to the
3554 * default action that will be performed on it.
3555 */
3556 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3557 public static final String CATEGORY_SELECTED_ALTERNATIVE = "android.intent.category.SELECTED_ALTERNATIVE";
3558 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09003559 * Intended to be used as a tab inside of a containing TabActivity.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003560 */
3561 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3562 public static final String CATEGORY_TAB = "android.intent.category.TAB";
3563 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003564 * Should be displayed in the top-level launcher.
3565 */
3566 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3567 public static final String CATEGORY_LAUNCHER = "android.intent.category.LAUNCHER";
3568 /**
Jose Lima38b75b62014-03-11 10:41:39 -07003569 * Indicates an activity optimized for Leanback mode, and that should
3570 * be displayed in the Leanback launcher.
3571 */
3572 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3573 public static final String CATEGORY_LEANBACK_LAUNCHER = "android.intent.category.LEANBACK_LAUNCHER";
3574 /**
Jose Lima73915cf2014-07-29 17:16:31 -07003575 * Indicates a Leanback settings activity to be displayed in the Leanback launcher.
3576 * @hide
3577 */
3578 @SystemApi
3579 public static final String CATEGORY_LEANBACK_SETTINGS = "android.intent.category.LEANBACK_SETTINGS";
3580 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003581 * Provides information about the package it is in; typically used if
3582 * a package does not contain a {@link #CATEGORY_LAUNCHER} to provide
3583 * a front-door to the user without having to be shown in the all apps list.
3584 */
3585 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3586 public static final String CATEGORY_INFO = "android.intent.category.INFO";
3587 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003588 * This is the home activity, that is the first activity that is displayed
3589 * when the device boots.
3590 */
3591 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3592 public static final String CATEGORY_HOME = "android.intent.category.HOME";
3593 /**
Anthony Hugh979b81a2015-09-29 16:50:35 -07003594 * This is the home activity that is displayed when the device is finished setting up and ready
3595 * for use.
3596 * @hide
3597 */
3598 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3599 public static final String CATEGORY_HOME_MAIN = "android.intent.category.HOME_MAIN";
3600 /**
Svet Ganov50a8bf42015-07-15 11:04:18 -07003601 * This is the setup wizard activity, that is the first activity that is displayed
3602 * when the user sets up the device for the first time.
3603 * @hide
3604 */
3605 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3606 public static final String CATEGORY_SETUP_WIZARD = "android.intent.category.SETUP_WIZARD";
3607 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003608 * This activity is a preference panel.
3609 */
3610 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3611 public static final String CATEGORY_PREFERENCE = "android.intent.category.PREFERENCE";
3612 /**
3613 * This activity is a development preference panel.
3614 */
3615 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3616 public static final String CATEGORY_DEVELOPMENT_PREFERENCE = "android.intent.category.DEVELOPMENT_PREFERENCE";
3617 /**
3618 * Capable of running inside a parent activity container.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003619 */
3620 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3621 public static final String CATEGORY_EMBED = "android.intent.category.EMBED";
3622 /**
Patrick Dubroy6dabe242010-08-30 10:43:47 -07003623 * This activity allows the user to browse and download new applications.
3624 */
3625 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3626 public static final String CATEGORY_APP_MARKET = "android.intent.category.APP_MARKET";
3627 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003628 * This activity may be exercised by the monkey or other automated test tools.
3629 */
3630 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3631 public static final String CATEGORY_MONKEY = "android.intent.category.MONKEY";
3632 /**
3633 * To be used as a test (not part of the normal user experience).
3634 */
3635 public static final String CATEGORY_TEST = "android.intent.category.TEST";
3636 /**
3637 * To be used as a unit test (run through the Test Harness).
3638 */
3639 public static final String CATEGORY_UNIT_TEST = "android.intent.category.UNIT_TEST";
3640 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09003641 * To be used as a sample code example (not part of the normal user
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003642 * experience).
3643 */
3644 public static final String CATEGORY_SAMPLE_CODE = "android.intent.category.SAMPLE_CODE";
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003645
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003646 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003647 * Used to indicate that an intent only wants URIs that can be opened with
3648 * {@link ContentResolver#openFileDescriptor(Uri, String)}. Openable URIs
3649 * must support at least the columns defined in {@link OpenableColumns} when
3650 * queried.
3651 *
3652 * @see #ACTION_GET_CONTENT
3653 * @see #ACTION_OPEN_DOCUMENT
3654 * @see #ACTION_CREATE_DOCUMENT
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003655 */
3656 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3657 public static final String CATEGORY_OPENABLE = "android.intent.category.OPENABLE";
3658
3659 /**
Tomasz Mikolajewski28a815c2016-10-28 15:54:11 +09003660 * Used to indicate that an intent filter can accept files which are not necessarily
3661 * openable by {@link ContentResolver#openFileDescriptor(Uri, String)}, but
3662 * at least streamable via
3663 * {@link ContentResolver#openTypedAssetFileDescriptor(Uri, String, Bundle)}
3664 * using one of the stream types exposed via
3665 * {@link ContentResolver#getStreamTypes(Uri, String)}.
3666 *
3667 * @see #ACTION_SEND
3668 * @see #ACTION_SEND_MULTIPLE
3669 */
3670 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3671 public static final String CATEGORY_TYPED_OPENABLE =
3672 "android.intent.category.TYPED_OPENABLE";
3673
3674 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003675 * To be used as code under test for framework instrumentation tests.
3676 */
3677 public static final String CATEGORY_FRAMEWORK_INSTRUMENTATION_TEST =
3678 "android.intent.category.FRAMEWORK_INSTRUMENTATION_TEST";
Mike Lockwood9092ab42009-09-16 13:01:32 -04003679 /**
3680 * An activity to run when device is inserted into a car dock.
Dianne Hackborn7299c412010-03-04 18:41:49 -08003681 * Used with {@link #ACTION_MAIN} to launch an activity. For more
3682 * information, see {@link android.app.UiModeManager}.
Mike Lockwood9092ab42009-09-16 13:01:32 -04003683 */
3684 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3685 public static final String CATEGORY_CAR_DOCK = "android.intent.category.CAR_DOCK";
3686 /**
3687 * An activity to run when device is inserted into a car dock.
Dianne Hackborn7299c412010-03-04 18:41:49 -08003688 * Used with {@link #ACTION_MAIN} to launch an activity. For more
3689 * information, see {@link android.app.UiModeManager}.
Mike Lockwood9092ab42009-09-16 13:01:32 -04003690 */
3691 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3692 public static final String CATEGORY_DESK_DOCK = "android.intent.category.DESK_DOCK";
Praveen Bharathi21e941b2010-10-06 15:23:14 -05003693 /**
3694 * An activity to run when device is inserted into a analog (low end) dock.
3695 * Used with {@link #ACTION_MAIN} to launch an activity. For more
3696 * information, see {@link android.app.UiModeManager}.
3697 */
3698 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3699 public static final String CATEGORY_LE_DESK_DOCK = "android.intent.category.LE_DESK_DOCK";
3700
3701 /**
3702 * An activity to run when device is inserted into a digital (high end) dock.
3703 * Used with {@link #ACTION_MAIN} to launch an activity. For more
3704 * information, see {@link android.app.UiModeManager}.
3705 */
3706 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3707 public static final String CATEGORY_HE_DESK_DOCK = "android.intent.category.HE_DESK_DOCK";
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05003708
Bernd Holzheyaea4b672010-03-31 09:46:13 +02003709 /**
3710 * Used to indicate that the activity can be used in a car environment.
3711 */
3712 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3713 public static final String CATEGORY_CAR_MODE = "android.intent.category.CAR_MODE";
3714
Zak Cohendb6ca492017-01-26 14:09:00 -08003715 /**
3716 * An activity to use for the launcher when the device is placed in a VR Headset viewer.
3717 * Used with {@link #ACTION_MAIN} to launch an activity. For more
3718 * information, see {@link android.app.UiModeManager}.
3719 */
3720 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3721 public static final String CATEGORY_VR_HOME = "android.intent.category.VR_HOME";
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003722 // ---------------------------------------------------------------------
3723 // ---------------------------------------------------------------------
Jeff Brown6651a632011-11-28 12:59:11 -08003724 // Application launch intent categories (see addCategory()).
3725
3726 /**
3727 * Used with {@link #ACTION_MAIN} to launch the browser application.
3728 * The activity should be able to browse the Internet.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003729 * <p>NOTE: This should not be used as the primary key of an Intent,
3730 * since it will not result in the app launching with the correct
3731 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003732 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003733 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003734 */
3735 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3736 public static final String CATEGORY_APP_BROWSER = "android.intent.category.APP_BROWSER";
3737
3738 /**
3739 * Used with {@link #ACTION_MAIN} to launch the calculator application.
3740 * The activity should be able to perform standard arithmetic operations.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003741 * <p>NOTE: This should not be used as the primary key of an Intent,
3742 * since it will not result in the app launching with the correct
3743 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003744 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003745 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003746 */
3747 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3748 public static final String CATEGORY_APP_CALCULATOR = "android.intent.category.APP_CALCULATOR";
3749
3750 /**
3751 * Used with {@link #ACTION_MAIN} to launch the calendar application.
3752 * The activity should be able to view and manipulate calendar entries.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003753 * <p>NOTE: This should not be used as the primary key of an Intent,
3754 * since it will not result in the app launching with the correct
3755 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003756 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003757 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003758 */
3759 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3760 public static final String CATEGORY_APP_CALENDAR = "android.intent.category.APP_CALENDAR";
3761
3762 /**
3763 * Used with {@link #ACTION_MAIN} to launch the contacts application.
3764 * The activity should be able to view and manipulate address book entries.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003765 * <p>NOTE: This should not be used as the primary key of an Intent,
3766 * since it will not result in the app launching with the correct
3767 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003768 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003769 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003770 */
3771 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3772 public static final String CATEGORY_APP_CONTACTS = "android.intent.category.APP_CONTACTS";
3773
3774 /**
3775 * Used with {@link #ACTION_MAIN} to launch the email application.
3776 * The activity should be able to send and receive email.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003777 * <p>NOTE: This should not be used as the primary key of an Intent,
3778 * since it will not result in the app launching with the correct
3779 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003780 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003781 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003782 */
3783 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3784 public static final String CATEGORY_APP_EMAIL = "android.intent.category.APP_EMAIL";
3785
3786 /**
3787 * Used with {@link #ACTION_MAIN} to launch the gallery application.
3788 * The activity should be able to view and manipulate image and video files
3789 * stored on the device.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003790 * <p>NOTE: This should not be used as the primary key of an Intent,
3791 * since it will not result in the app launching with the correct
3792 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003793 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003794 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003795 */
3796 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3797 public static final String CATEGORY_APP_GALLERY = "android.intent.category.APP_GALLERY";
3798
3799 /**
3800 * Used with {@link #ACTION_MAIN} to launch the maps application.
3801 * The activity should be able to show the user's current location and surroundings.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003802 * <p>NOTE: This should not be used as the primary key of an Intent,
3803 * since it will not result in the app launching with the correct
3804 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003805 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003806 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003807 */
3808 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3809 public static final String CATEGORY_APP_MAPS = "android.intent.category.APP_MAPS";
3810
3811 /**
3812 * Used with {@link #ACTION_MAIN} to launch the messaging application.
3813 * The activity should be able to send and receive text messages.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003814 * <p>NOTE: This should not be used as the primary key of an Intent,
3815 * since it will not result in the app launching with the correct
3816 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003817 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003818 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003819 */
3820 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3821 public static final String CATEGORY_APP_MESSAGING = "android.intent.category.APP_MESSAGING";
3822
3823 /**
3824 * Used with {@link #ACTION_MAIN} to launch the music application.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003825 * The activity should be able to play, browse, or manipulate music files
3826 * stored on the device.
3827 * <p>NOTE: This should not be used as the primary key of an Intent,
3828 * since it will not result in the app launching with the correct
3829 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003830 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003831 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003832 */
3833 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3834 public static final String CATEGORY_APP_MUSIC = "android.intent.category.APP_MUSIC";
3835
3836 // ---------------------------------------------------------------------
3837 // ---------------------------------------------------------------------
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003838 // Standard extra data keys.
3839
3840 /**
3841 * The initial data to place in a newly created record. Use with
3842 * {@link #ACTION_INSERT}. The data here is a Map containing the same
3843 * fields as would be given to the underlying ContentProvider.insert()
3844 * call.
3845 */
3846 public static final String EXTRA_TEMPLATE = "android.intent.extra.TEMPLATE";
3847
3848 /**
3849 * A constant CharSequence that is associated with the Intent, used with
3850 * {@link #ACTION_SEND} to supply the literal data to be sent. Note that
3851 * this may be a styled CharSequence, so you must use
3852 * {@link Bundle#getCharSequence(String) Bundle.getCharSequence()} to
3853 * retrieve it.
3854 */
3855 public static final String EXTRA_TEXT = "android.intent.extra.TEXT";
3856
3857 /**
Dianne Hackbornacb69bb2012-04-13 15:36:06 -07003858 * A constant String that is associated with the Intent, used with
3859 * {@link #ACTION_SEND} to supply an alternative to {@link #EXTRA_TEXT}
3860 * as HTML formatted text. Note that you <em>must</em> also supply
3861 * {@link #EXTRA_TEXT}.
3862 */
3863 public static final String EXTRA_HTML_TEXT = "android.intent.extra.HTML_TEXT";
3864
3865 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003866 * A content: URI holding a stream of data associated with the Intent,
3867 * used with {@link #ACTION_SEND} to supply the data being sent.
3868 */
3869 public static final String EXTRA_STREAM = "android.intent.extra.STREAM";
3870
3871 /**
3872 * A String[] holding e-mail addresses that should be delivered to.
3873 */
3874 public static final String EXTRA_EMAIL = "android.intent.extra.EMAIL";
3875
3876 /**
3877 * A String[] holding e-mail addresses that should be carbon copied.
3878 */
3879 public static final String EXTRA_CC = "android.intent.extra.CC";
3880
3881 /**
3882 * A String[] holding e-mail addresses that should be blind carbon copied.
3883 */
3884 public static final String EXTRA_BCC = "android.intent.extra.BCC";
3885
3886 /**
3887 * A constant string holding the desired subject line of a message.
3888 */
3889 public static final String EXTRA_SUBJECT = "android.intent.extra.SUBJECT";
3890
3891 /**
3892 * An Intent describing the choices you would like shown with
Adam Powell2ed547e2015-04-29 18:45:04 -07003893 * {@link #ACTION_PICK_ACTIVITY} or {@link #ACTION_CHOOSER}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003894 */
3895 public static final String EXTRA_INTENT = "android.intent.extra.INTENT";
3896
3897 /**
Clara Bayarrif7fea162015-10-22 16:09:52 +01003898 * An int representing the user id to be used.
3899 *
3900 * @hide
3901 */
3902 public static final String EXTRA_USER_ID = "android.intent.extra.USER_ID";
3903
3904 /**
Clara Bayarriea9b10e2015-12-04 15:36:26 +00003905 * An int representing the task id to be retrieved. This is used when a launch from recents is
3906 * intercepted by another action such as credentials confirmation to remember which task should
3907 * be resumed when complete.
3908 *
3909 * @hide
3910 */
3911 public static final String EXTRA_TASK_ID = "android.intent.extra.TASK_ID";
3912
3913 /**
Adam Powell2ed547e2015-04-29 18:45:04 -07003914 * An Intent[] describing additional, alternate choices you would like shown with
3915 * {@link #ACTION_CHOOSER}.
3916 *
3917 * <p>An app may be capable of providing several different payload types to complete a
3918 * user's intended action. For example, an app invoking {@link #ACTION_SEND} to share photos
3919 * with another app may use EXTRA_ALTERNATE_INTENTS to have the chooser transparently offer
3920 * several different supported sending mechanisms for sharing, such as the actual "image/*"
3921 * photo data or a hosted link where the photos can be viewed.</p>
3922 *
3923 * <p>The intent present in {@link #EXTRA_INTENT} will be treated as the
3924 * first/primary/preferred intent in the set. Additional intents specified in
3925 * this extra are ordered; by default intents that appear earlier in the array will be
3926 * preferred over intents that appear later in the array as matches for the same
3927 * target component. To alter this preference, a calling app may also supply
3928 * {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER}.</p>
3929 */
3930 public static final String EXTRA_ALTERNATE_INTENTS = "android.intent.extra.ALTERNATE_INTENTS";
3931
3932 /**
Adam Powell52c39212016-04-07 15:14:18 -07003933 * A {@link ComponentName ComponentName[]} describing components that should be filtered out
3934 * and omitted from a list of components presented to the user.
3935 *
3936 * <p>When used with {@link #ACTION_CHOOSER}, the chooser will omit any of the components
3937 * in this array if it otherwise would have shown them. Useful for omitting specific targets
3938 * from your own package or other apps from your organization if the idea of sending to those
3939 * targets would be redundant with other app functionality. Filtered components will not
3940 * be able to present targets from an associated <code>ChooserTargetService</code>.</p>
3941 */
3942 public static final String EXTRA_EXCLUDE_COMPONENTS
3943 = "android.intent.extra.EXCLUDE_COMPONENTS";
3944
3945 /**
3946 * A {@link android.service.chooser.ChooserTarget ChooserTarget[]} for {@link #ACTION_CHOOSER}
3947 * describing additional high-priority deep-link targets for the chooser to present to the user.
3948 *
3949 * <p>Targets provided in this way will be presented inline with all other targets provided
3950 * by services from other apps. They will be prioritized before other service targets, but
3951 * after those targets provided by sources that the user has manually pinned to the front.</p>
3952 *
3953 * @see #ACTION_CHOOSER
3954 */
3955 public static final String EXTRA_CHOOSER_TARGETS = "android.intent.extra.CHOOSER_TARGETS";
3956
3957 /**
Adam Powell2ed547e2015-04-29 18:45:04 -07003958 * An {@link IntentSender} for an Activity that will be invoked when the user makes a selection
3959 * from the chooser activity presented by {@link #ACTION_CHOOSER}.
3960 *
3961 * <p>An app preparing an action for another app to complete may wish to allow the user to
3962 * disambiguate between several options for completing the action based on the chosen target
3963 * or otherwise refine the action before it is invoked.
3964 * </p>
3965 *
3966 * <p>When sent, this IntentSender may be filled in with the following extras:</p>
3967 * <ul>
3968 * <li>{@link #EXTRA_INTENT} The first intent that matched the user's chosen target</li>
3969 * <li>{@link #EXTRA_ALTERNATE_INTENTS} Any additional intents that also matched the user's
3970 * chosen target beyond the first</li>
3971 * <li>{@link #EXTRA_RESULT_RECEIVER} A {@link ResultReceiver} that the refinement activity
3972 * should fill in and send once the disambiguation is complete</li>
3973 * </ul>
3974 */
3975 public static final String EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER
3976 = "android.intent.extra.CHOOSER_REFINEMENT_INTENT_SENDER";
3977
3978 /**
Kang Li9fa2a2c2017-01-06 13:33:24 -08003979 * An {@code ArrayList} of {@code String} annotations describing content for
3980 * {@link #ACTION_CHOOSER}.
3981 *
3982 * <p>If {@link #EXTRA_CONTENT_ANNOTATIONS} is present in an intent used to start a
3983 * {@link #ACTION_CHOOSER} activity, the first three annotations will be used to rank apps.</p>
3984 *
3985 * <p>Annotations should describe the major components or topics of the content. It is up to
3986 * apps initiating {@link #ACTION_CHOOSER} to learn and add annotations. Annotations should be
3987 * learned in advance, e.g., when creating or saving content, to avoid increasing latency to
3988 * start {@link #ACTION_CHOOSER}. Performance on customized annotations can suffer, if they are
3989 * rarely used for {@link #ACTION_CHOOSER} in the past 14 days. Therefore, it is recommended to
3990 * use the following annotations when applicable:</p>
3991 * <ul>
3992 * <li>"product": represents that the topic of the content is mainly about products, e.g.,
3993 * health & beauty, and office supplies.</li>
3994 * <li>"emotion": represents that the topic of the content is mainly about emotions, e.g.,
3995 * happy, and sad.</li>
3996 * <li>"person": represents that the topic of the content is mainly about persons, e.g.,
3997 * face, finger, standing, and walking.</li>
3998 * <li>"child": represents that the topic of the content is mainly about children, e.g.,
3999 * child, and baby.</li>
4000 * <li>"selfie": represents that the topic of the content is mainly about selfies.</li>
4001 * <li>"crowd": represents that the topic of the content is mainly about crowds.</li>
4002 * <li>"party": represents that the topic of the content is mainly about parties.</li>
4003 * <li>"animal": represent that the topic of the content is mainly about animals.</li>
4004 * <li>"plant": represents that the topic of the content is mainly about plants, e.g.,
4005 * flowers.</li>
4006 * <li>"vacation": represents that the topic of the content is mainly about vacations.</li>
4007 * <li>"fashion": represents that the topic of the content is mainly about fashion, e.g.
4008 * sunglasses, jewelry, handbags and clothing.</li>
4009 * <li>"material": represents that the topic of the content is mainly about materials, e.g.,
4010 * paper, and silk.</li>
4011 * <li>"vehicle": represents that the topic of the content is mainly about vehicles, like
4012 * cars, and boats.</li>
4013 * <li>"document": represents that the topic of the content is mainly about documents, e.g.
4014 * posters.</li>
4015 * <li>"design": represents that the topic of the content is mainly about design, e.g. arts
4016 * and designs of houses.</li>
4017 * <li>"holiday": represents that the topic of the content is mainly about holidays, e.g.,
4018 * Christmas and Thanksgiving.</li>
4019 * </ul>
4020 */
4021 public static final String EXTRA_CONTENT_ANNOTATIONS
4022 = "android.intent.extra.CONTENT_ANNOTATIONS";
4023
4024 /**
Adam Powell2ed547e2015-04-29 18:45:04 -07004025 * A {@link ResultReceiver} used to return data back to the sender.
4026 *
4027 * <p>Used to complete an app-specific
4028 * {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER refinement} for {@link #ACTION_CHOOSER}.</p>
4029 *
4030 * <p>If {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER} is present in the intent
4031 * used to start a {@link #ACTION_CHOOSER} activity this extra will be
4032 * {@link #fillIn(Intent, int) filled in} to that {@link IntentSender} and sent
4033 * when the user selects a target component from the chooser. It is up to the recipient
4034 * to send a result to this ResultReceiver to signal that disambiguation is complete
4035 * and that the chooser should invoke the user's choice.</p>
4036 *
4037 * <p>The disambiguator should provide a Bundle to the ResultReceiver with an intent
4038 * assigned to the key {@link #EXTRA_INTENT}. This supplied intent will be used by the chooser
4039 * to match and fill in the final Intent or ChooserTarget before starting it.
4040 * The supplied intent must {@link #filterEquals(Intent) match} one of the intents from
4041 * {@link #EXTRA_INTENT} or {@link #EXTRA_ALTERNATE_INTENTS} passed to
4042 * {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER} to be accepted.</p>
4043 *
4044 * <p>The result code passed to the ResultReceiver should be
4045 * {@link android.app.Activity#RESULT_OK} if the refinement succeeded and the supplied intent's
4046 * target in the chooser should be started, or {@link android.app.Activity#RESULT_CANCELED} if
4047 * the chooser should finish without starting a target.</p>
4048 */
4049 public static final String EXTRA_RESULT_RECEIVER
4050 = "android.intent.extra.RESULT_RECEIVER";
4051
4052 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004053 * A CharSequence dialog title to provide to the user when used with a
Jim Miller4d64746d2014-08-13 21:08:41 +00004054 * {@link #ACTION_CHOOSER}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004055 */
4056 public static final String EXTRA_TITLE = "android.intent.extra.TITLE";
4057
4058 /**
Dianne Hackborneb034652009-09-07 00:49:58 -07004059 * A Parcelable[] of {@link Intent} or
4060 * {@link android.content.pm.LabeledIntent} objects as set with
4061 * {@link #putExtra(String, Parcelable[])} of additional activities to place
4062 * a the front of the list of choices, when shown to the user with a
4063 * {@link #ACTION_CHOOSER}.
4064 */
4065 public static final String EXTRA_INITIAL_INTENTS = "android.intent.extra.INITIAL_INTENTS";
4066
4067 /**
Todd Kennedy7440f172015-12-09 14:31:22 -08004068 * A {@link IntentSender} to start after ephemeral installation success.
4069 * @hide
4070 */
Todd Kennedy7440f172015-12-09 14:31:22 -08004071 public static final String EXTRA_EPHEMERAL_SUCCESS = "android.intent.extra.EPHEMERAL_SUCCESS";
4072
4073 /**
4074 * A {@link IntentSender} to start after ephemeral installation failure.
4075 * @hide
4076 */
Todd Kennedy7440f172015-12-09 14:31:22 -08004077 public static final String EXTRA_EPHEMERAL_FAILURE = "android.intent.extra.EPHEMERAL_FAILURE";
4078
4079 /**
Todd Kennedy01ad0c72016-11-11 15:33:12 -08004080 * The host name that triggered an ephemeral resolution.
4081 * @hide
4082 */
4083 public static final String EXTRA_EPHEMERAL_HOSTNAME = "android.intent.extra.EPHEMERAL_HOSTNAME";
4084
4085 /**
4086 * An opaque token to track ephemeral resolution.
4087 * @hide
4088 */
4089 public static final String EXTRA_EPHEMERAL_TOKEN = "android.intent.extra.EPHEMERAL_TOKEN";
4090
4091 /**
Todd Kennedy316c2f22017-01-23 15:40:07 -08004092 * The version code of the app to install components from.
4093 * @hide
4094 */
4095 public static final String EXTRA_VERSION_CODE = "android.intent.extra.VERSION_CODE";
4096
4097 /**
Adam Powelle49d9392014-07-17 18:45:19 -07004098 * A Bundle forming a mapping of potential target package names to different extras Bundles
4099 * to add to the default intent extras in {@link #EXTRA_INTENT} when used with
4100 * {@link #ACTION_CHOOSER}. Each key should be a package name. The package need not
4101 * be currently installed on the device.
4102 *
4103 * <p>An application may choose to provide alternate extras for the case where a user
4104 * selects an activity from a predetermined set of target packages. If the activity
4105 * the user selects from the chooser belongs to a package with its package name as
4106 * a key in this bundle, the corresponding extras for that package will be merged with
4107 * the extras already present in the intent at {@link #EXTRA_INTENT}. If a replacement
4108 * extra has the same key as an extra already present in the intent it will overwrite
4109 * the extra from the intent.</p>
4110 *
4111 * <p><em>Examples:</em>
4112 * <ul>
4113 * <li>An application may offer different {@link #EXTRA_TEXT} to an application
4114 * when sharing with it via {@link #ACTION_SEND}, augmenting a link with additional query
4115 * parameters for that target.</li>
4116 * <li>An application may offer additional metadata for known targets of a given intent
4117 * to pass along information only relevant to that target such as account or content
4118 * identifiers already known to that application.</li>
4119 * </ul></p>
4120 */
4121 public static final String EXTRA_REPLACEMENT_EXTRAS =
4122 "android.intent.extra.REPLACEMENT_EXTRAS";
4123
4124 /**
Adam Powell0b3c1122014-10-09 12:50:14 -07004125 * An {@link IntentSender} that will be notified if a user successfully chooses a target
4126 * component to handle an action in an {@link #ACTION_CHOOSER} activity. The IntentSender
4127 * will have the extra {@link #EXTRA_CHOSEN_COMPONENT} appended to it containing the
4128 * {@link ComponentName} of the chosen component.
4129 *
4130 * <p>In some situations this callback may never come, for example if the user abandons
4131 * the chooser, switches to another task or any number of other reasons. Apps should not
4132 * be written assuming that this callback will always occur.</p>
4133 */
4134 public static final String EXTRA_CHOSEN_COMPONENT_INTENT_SENDER =
4135 "android.intent.extra.CHOSEN_COMPONENT_INTENT_SENDER";
4136
4137 /**
4138 * The {@link ComponentName} chosen by the user to complete an action.
4139 *
4140 * @see #EXTRA_CHOSEN_COMPONENT_INTENT_SENDER
4141 */
4142 public static final String EXTRA_CHOSEN_COMPONENT = "android.intent.extra.CHOSEN_COMPONENT";
4143
4144 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004145 * A {@link android.view.KeyEvent} object containing the event that
4146 * triggered the creation of the Intent it is in.
4147 */
4148 public static final String EXTRA_KEY_EVENT = "android.intent.extra.KEY_EVENT";
4149
4150 /**
Mike Lockwoodbad80e02009-07-30 01:21:08 -07004151 * Set to true in {@link #ACTION_REQUEST_SHUTDOWN} to request confirmation from the user
4152 * before shutting down.
4153 *
4154 * {@hide}
4155 */
4156 public static final String EXTRA_KEY_CONFIRM = "android.intent.extra.KEY_CONFIRM";
4157
4158 /**
Yusuke Sato705ffd12015-07-21 15:52:11 -07004159 * Set to true in {@link #ACTION_REQUEST_SHUTDOWN} to indicate that the shutdown is
4160 * requested by the user.
4161 *
4162 * {@hide}
4163 */
4164 public static final String EXTRA_USER_REQUESTED_SHUTDOWN =
4165 "android.intent.extra.USER_REQUESTED_SHUTDOWN";
4166
4167 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09004168 * 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 -07004169 * {@link android.content.Intent#ACTION_PACKAGE_CHANGED} intents to override the default action
4170 * of restarting the application.
4171 */
4172 public static final String EXTRA_DONT_KILL_APP = "android.intent.extra.DONT_KILL_APP";
4173
4174 /**
4175 * A String holding the phone number originally entered in
4176 * {@link android.content.Intent#ACTION_NEW_OUTGOING_CALL}, or the actual
4177 * number to call in a {@link android.content.Intent#ACTION_CALL}.
4178 */
4179 public static final String EXTRA_PHONE_NUMBER = "android.intent.extra.PHONE_NUMBER";
Bernd Holzheyaea4b672010-03-31 09:46:13 +02004180
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004181 /**
4182 * Used as an int extra field in {@link android.content.Intent#ACTION_UID_REMOVED}
4183 * intents to supply the uid the package had been assigned. Also an optional
4184 * extra in {@link android.content.Intent#ACTION_PACKAGE_REMOVED} or
4185 * {@link android.content.Intent#ACTION_PACKAGE_CHANGED} for the same
4186 * purpose.
4187 */
4188 public static final String EXTRA_UID = "android.intent.extra.UID";
4189
4190 /**
Dianne Hackborn21f1bd12010-02-19 17:02:21 -08004191 * @hide String array of package names.
4192 */
Soonil Nagarkar0e8fd092015-02-10 10:37:36 -08004193 @SystemApi
Dianne Hackborn21f1bd12010-02-19 17:02:21 -08004194 public static final String EXTRA_PACKAGES = "android.intent.extra.PACKAGES";
4195
4196 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004197 * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED}
4198 * intents to indicate whether this represents a full uninstall (removing
4199 * both the code and its data) or a partial uninstall (leaving its data,
4200 * implying that this is an update).
4201 */
4202 public static final String EXTRA_DATA_REMOVED = "android.intent.extra.DATA_REMOVED";
The Android Open Source Project10592532009-03-18 17:39:46 -07004203
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004204 /**
Dianne Hackbornc72fc672012-09-20 13:12:03 -07004205 * @hide
4206 * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED}
4207 * intents to indicate that at this point the package has been removed for
4208 * all users on the device.
4209 */
4210 public static final String EXTRA_REMOVED_FOR_ALL_USERS
4211 = "android.intent.extra.REMOVED_FOR_ALL_USERS";
4212
4213 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004214 * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED}
4215 * intents to indicate that this is a replacement of the package, so this
4216 * broadcast will immediately be followed by an add broadcast for a
4217 * different version of the same package.
4218 */
4219 public static final String EXTRA_REPLACING = "android.intent.extra.REPLACING";
The Android Open Source Project10592532009-03-18 17:39:46 -07004220
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004221 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004222 * Used as an int extra field in {@link android.app.AlarmManager} intents
4223 * to tell the application being invoked how many pending alarms are being
4224 * delievered with the intent. For one-shot alarms this will always be 1.
4225 * For recurring alarms, this might be greater than 1 if the device was
4226 * asleep or powered off at the time an earlier alarm would have been
4227 * delivered.
4228 */
4229 public static final String EXTRA_ALARM_COUNT = "android.intent.extra.ALARM_COUNT";
Romain Guy4969af72009-06-17 10:53:19 -07004230
Jacek Surazski86b6c532009-05-13 14:38:28 +02004231 /**
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05004232 * Used as an int extra field in {@link android.content.Intent#ACTION_DOCK_EVENT}
4233 * intents to request the dock state. Possible values are
Mike Lockwood725fcbf2009-08-24 13:09:20 -07004234 * {@link android.content.Intent#EXTRA_DOCK_STATE_UNDOCKED},
4235 * {@link android.content.Intent#EXTRA_DOCK_STATE_DESK}, or
Praveen Bharathi21e941b2010-10-06 15:23:14 -05004236 * {@link android.content.Intent#EXTRA_DOCK_STATE_CAR}, or
4237 * {@link android.content.Intent#EXTRA_DOCK_STATE_LE_DESK}, or
4238 * {@link android.content.Intent#EXTRA_DOCK_STATE_HE_DESK}.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05004239 */
4240 public static final String EXTRA_DOCK_STATE = "android.intent.extra.DOCK_STATE";
4241
4242 /**
4243 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
4244 * to represent that the phone is not in any dock.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05004245 */
4246 public static final int EXTRA_DOCK_STATE_UNDOCKED = 0;
4247
4248 /**
4249 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
4250 * to represent that the phone is in a desk dock.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05004251 */
4252 public static final int EXTRA_DOCK_STATE_DESK = 1;
4253
4254 /**
4255 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
4256 * to represent that the phone is in a car dock.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05004257 */
4258 public static final int EXTRA_DOCK_STATE_CAR = 2;
4259
4260 /**
Praveen Bharathi21e941b2010-10-06 15:23:14 -05004261 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
4262 * to represent that the phone is in a analog (low end) dock.
4263 */
4264 public static final int EXTRA_DOCK_STATE_LE_DESK = 3;
4265
4266 /**
4267 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
4268 * to represent that the phone is in a digital (high end) dock.
4269 */
4270 public static final int EXTRA_DOCK_STATE_HE_DESK = 4;
4271
4272 /**
Dianne Hackborn9bfb7072009-09-22 11:37:40 -07004273 * Boolean that can be supplied as meta-data with a dock activity, to
4274 * indicate that the dock should take over the home key when it is active.
4275 */
4276 public static final String METADATA_DOCK_HOME = "android.dock_home";
Tom Taylord4a47292009-12-21 13:59:18 -08004277
Dianne Hackborn9bfb7072009-09-22 11:37:40 -07004278 /**
Jacek Surazski86b6c532009-05-13 14:38:28 +02004279 * Used as a parcelable extra field in {@link #ACTION_APP_ERROR}, containing
4280 * the bug report.
Jacek Surazski86b6c532009-05-13 14:38:28 +02004281 */
4282 public static final String EXTRA_BUG_REPORT = "android.intent.extra.BUG_REPORT";
4283
4284 /**
Wei Huang97ecc9c2009-05-11 17:44:20 -07004285 * Used in the extra field in the remote intent. It's astring token passed with the
4286 * remote intent.
4287 */
4288 public static final String EXTRA_REMOTE_INTENT_TOKEN =
4289 "android.intent.extra.remote_intent_token";
4290
Suchi Amalapurapu0214e942009-09-02 11:03:18 -07004291 /**
Dianne Hackborn1d62ea92009-11-17 12:49:50 -08004292 * @deprecated See {@link #EXTRA_CHANGED_COMPONENT_NAME_LIST}; this field
Dianne Hackborn86a72da2009-11-11 20:12:41 -08004293 * will contain only the first name in the list.
Suchi Amalapurapu0214e942009-09-02 11:03:18 -07004294 */
Dianne Hackborn1d62ea92009-11-17 12:49:50 -08004295 @Deprecated public static final String EXTRA_CHANGED_COMPONENT_NAME =
Suchi Amalapurapu0214e942009-09-02 11:03:18 -07004296 "android.intent.extra.changed_component_name";
4297
Dianne Hackborndd9b82c2009-09-03 00:18:47 -07004298 /**
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08004299 * This field is part of {@link android.content.Intent#ACTION_PACKAGE_CHANGED},
Dianne Hackbornfd7aded2013-01-22 17:10:23 -08004300 * and contains a string array of all of the components that have changed. If
4301 * the state of the overall package has changed, then it will contain an entry
4302 * with the package name itself.
Dianne Hackborn86a72da2009-11-11 20:12:41 -08004303 */
4304 public static final String EXTRA_CHANGED_COMPONENT_NAME_LIST =
4305 "android.intent.extra.changed_component_name_list";
4306
4307 /**
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08004308 * This field is part of
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08004309 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_AVAILABLE},
Andrei Stingaceanu69d5ebc2016-01-14 12:59:03 +00004310 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE},
4311 * {@link android.content.Intent#ACTION_PACKAGES_SUSPENDED},
4312 * {@link android.content.Intent#ACTION_PACKAGES_UNSUSPENDED}
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08004313 * and contains a string array of all of the components that have changed.
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08004314 */
4315 public static final String EXTRA_CHANGED_PACKAGE_LIST =
4316 "android.intent.extra.changed_package_list";
4317
4318 /**
4319 * This field is part of
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08004320 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_AVAILABLE},
4321 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE}
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08004322 * and contains an integer array of uids of all of the components
4323 * that have changed.
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08004324 */
4325 public static final String EXTRA_CHANGED_UID_LIST =
4326 "android.intent.extra.changed_uid_list";
4327
4328 /**
Dianne Hackborndd9b82c2009-09-03 00:18:47 -07004329 * @hide
4330 * Magic extra system code can use when binding, to give a label for
4331 * who it is that has bound to a service. This is an integer giving
4332 * a framework string resource that can be displayed to the user.
4333 */
4334 public static final String EXTRA_CLIENT_LABEL =
4335 "android.intent.extra.client_label";
4336
4337 /**
4338 * @hide
4339 * Magic extra system code can use when binding, to give a PendingIntent object
4340 * that can be launched for the user to disable the system's use of this
4341 * service.
4342 */
4343 public static final String EXTRA_CLIENT_INTENT =
4344 "android.intent.extra.client_intent";
4345
Dianne Hackbornc4d0e6f2011-01-25 14:55:06 -08004346 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004347 * Extra used to indicate that an intent should only return data that is on
4348 * the local device. This is a boolean extra; the default is false. If true,
4349 * an implementation should only allow the user to select data that is
4350 * already on the device, not requiring it be downloaded from a remote
4351 * service when opened.
4352 *
4353 * @see #ACTION_GET_CONTENT
4354 * @see #ACTION_OPEN_DOCUMENT
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07004355 * @see #ACTION_OPEN_DOCUMENT_TREE
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004356 * @see #ACTION_CREATE_DOCUMENT
Dianne Hackbornc4d0e6f2011-01-25 14:55:06 -08004357 */
4358 public static final String EXTRA_LOCAL_ONLY =
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004359 "android.intent.extra.LOCAL_ONLY";
Daniel Lehmanna5b58df2011-10-12 16:24:22 -07004360
Amith Yamasani13593602012-03-22 16:16:17 -07004361 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004362 * Extra used to indicate that an intent can allow the user to select and
4363 * return multiple items. This is a boolean extra; the default is false. If
4364 * true, an implementation is allowed to present the user with a UI where
4365 * they can pick multiple items that are all returned to the caller. When
4366 * this happens, they should be returned as the {@link #getClipData()} part
4367 * of the result Intent.
4368 *
4369 * @see #ACTION_GET_CONTENT
4370 * @see #ACTION_OPEN_DOCUMENT
Dianne Hackbornfdb3f092013-01-28 15:10:48 -08004371 */
4372 public static final String EXTRA_ALLOW_MULTIPLE =
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004373 "android.intent.extra.ALLOW_MULTIPLE";
Dianne Hackbornfdb3f092013-01-28 15:10:48 -08004374
4375 /**
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01004376 * The integer userHandle carried with broadcast intents related to addition, removal and
4377 * switching of users and managed profiles - {@link #ACTION_USER_ADDED},
4378 * {@link #ACTION_USER_REMOVED} and {@link #ACTION_USER_SWITCHED}.
4379 *
Amith Yamasani13593602012-03-22 16:16:17 -07004380 * @hide
4381 */
Amith Yamasani2a003292012-08-14 18:25:45 -07004382 public static final String EXTRA_USER_HANDLE =
4383 "android.intent.extra.user_handle";
Jean-Michel Trivi3114ce32012-06-11 15:03:52 -07004384
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08004385 /**
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01004386 * The UserHandle carried with broadcasts intents related to addition and removal of managed
4387 * profiles - {@link #ACTION_MANAGED_PROFILE_ADDED} and {@link #ACTION_MANAGED_PROFILE_REMOVED}.
4388 */
4389 public static final String EXTRA_USER =
Alexandra Gherghina3315f6b2014-09-05 15:48:06 +01004390 "android.intent.extra.USER";
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01004391
4392 /**
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08004393 * Extra used in the response from a BroadcastReceiver that handles
Amith Yamasani7e99bc02013-04-16 18:24:51 -07004394 * {@link #ACTION_GET_RESTRICTION_ENTRIES}. The type of the extra is
4395 * <code>ArrayList&lt;RestrictionEntry&gt;</code>.
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08004396 */
Amith Yamasani7e99bc02013-04-16 18:24:51 -07004397 public static final String EXTRA_RESTRICTIONS_LIST = "android.intent.extra.restrictions_list";
4398
4399 /**
4400 * Extra sent in the intent to the BroadcastReceiver that handles
4401 * {@link #ACTION_GET_RESTRICTION_ENTRIES}. The type of the extra is a Bundle containing
4402 * the restrictions as key/value pairs.
4403 */
4404 public static final String EXTRA_RESTRICTIONS_BUNDLE =
4405 "android.intent.extra.restrictions_bundle";
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08004406
Amith Yamasani86118ba2013-03-28 14:33:16 -07004407 /**
4408 * Extra used in the response from a BroadcastReceiver that handles
4409 * {@link #ACTION_GET_RESTRICTION_ENTRIES}.
4410 */
4411 public static final String EXTRA_RESTRICTIONS_INTENT =
4412 "android.intent.extra.restrictions_intent";
4413
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07004414 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004415 * Extra used to communicate a set of acceptable MIME types. The type of the
4416 * extra is {@code String[]}. Values may be a combination of concrete MIME
4417 * types (such as "image/png") and/or partial MIME types (such as
4418 * "audio/*").
4419 *
4420 * @see #ACTION_GET_CONTENT
4421 * @see #ACTION_OPEN_DOCUMENT
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07004422 */
4423 public static final String EXTRA_MIME_TYPES = "android.intent.extra.MIME_TYPES";
4424
Dianne Hackborn57a7f592013-07-22 18:21:32 -07004425 /**
4426 * Optional extra for {@link #ACTION_SHUTDOWN} that allows the sender to qualify that
4427 * this shutdown is only for the user space of the system, not a complete shutdown.
Dianne Hackbornd318e0b2013-09-03 14:34:12 -07004428 * When this is true, hardware devices can use this information to determine that
4429 * they shouldn't do a complete shutdown of their device since this is not a
4430 * complete shutdown down to the kernel, but only user space restarting.
4431 * The default if not supplied is false.
Dianne Hackborn57a7f592013-07-22 18:21:32 -07004432 */
4433 public static final String EXTRA_SHUTDOWN_USERSPACE_ONLY
4434 = "android.intent.extra.SHUTDOWN_USERSPACE_ONLY";
4435
Narayan Kamathccb2a0862013-12-19 14:49:36 +00004436 /**
Neil Fullerb7146fe2016-11-15 16:52:15 +00004437 * Optional int extra for {@link #ACTION_TIME_CHANGED} that indicates the
4438 * user has set their time format preference. See {@link #EXTRA_TIME_PREF_VALUE_USE_12_HOUR},
4439 * {@link #EXTRA_TIME_PREF_VALUE_USE_24_HOUR} and
4440 * {@link #EXTRA_TIME_PREF_VALUE_USE_LOCALE_DEFAULT}. The value must not be negative.
Narayan Kamathccb2a0862013-12-19 14:49:36 +00004441 *
4442 * @hide for internal use only.
4443 */
4444 public static final String EXTRA_TIME_PREF_24_HOUR_FORMAT =
4445 "android.intent.extra.TIME_PREF_24_HOUR_FORMAT";
Neil Fullerb7146fe2016-11-15 16:52:15 +00004446 /** @hide */
4447 public static final int EXTRA_TIME_PREF_VALUE_USE_12_HOUR = 0;
4448 /** @hide */
4449 public static final int EXTRA_TIME_PREF_VALUE_USE_24_HOUR = 1;
4450 /** @hide */
4451 public static final int EXTRA_TIME_PREF_VALUE_USE_LOCALE_DEFAULT = 2;
Narayan Kamathccb2a0862013-12-19 14:49:36 +00004452
Jeff Sharkey004a4b22014-09-24 11:45:24 -07004453 /** {@hide} */
4454 public static final String EXTRA_REASON = "android.intent.extra.REASON";
4455
Rubin Xue8490f12015-06-25 12:17:48 +01004456 /** {@hide} */
4457 public static final String EXTRA_WIPE_EXTERNAL_STORAGE = "android.intent.extra.WIPE_EXTERNAL_STORAGE";
4458
Santos Cordon15a13782015-03-31 18:32:31 -07004459 /**
4460 * Optional {@link android.app.PendingIntent} extra used to deliver the result of the SIM
4461 * activation request.
4462 * TODO: Add information about the structure and response data used with the pending intent.
4463 * @hide
4464 */
4465 public static final String EXTRA_SIM_ACTIVATION_RESPONSE =
4466 "android.intent.extra.SIM_ACTIVATION_RESPONSE";
4467
Tomasz Mikolajewski319fb492016-01-20 12:24:01 +09004468 /**
4469 * Optional index with semantics depending on the intent action.
Tomasz Mikolajewskife023132016-03-10 17:42:35 +09004470 *
4471 * <p>The value must be an integer greater or equal to 0.
Tomasz Mikolajewski867addf2017-02-01 14:16:39 +09004472 * @see ACTION_QUICK_VIEW
Tomasz Mikolajewski319fb492016-01-20 12:24:01 +09004473 */
Steve McKay6eaf38632015-08-04 10:11:01 -07004474 public static final String EXTRA_INDEX = "android.intent.extra.INDEX";
4475
Rubin Xu0a29ecd2015-11-04 15:11:48 +00004476 /**
Tomasz Mikolajewski17c50da2017-02-16 14:38:04 +09004477 * Tells the quick viewer to show additional UI actions suitable for the passed Uris,
4478 * such as opening in other apps, sharing, opening, editing, printing, deleting,
4479 * casting, etc.
Tomasz Mikolajewski867addf2017-02-01 14:16:39 +09004480 *
4481 * <p>The value is boolean. By default false.
4482 * @see ACTION_QUICK_VIEW
4483 */
Tomasz Mikolajewski17c50da2017-02-16 14:38:04 +09004484 public static final String EXTRA_QUICK_VIEW_ADVANCED =
4485 "android.intent.extra.QUICK_VIEW_ADVANCED";
Tomasz Mikolajewski867addf2017-02-01 14:16:39 +09004486
4487 /**
Rubin Xu0a29ecd2015-11-04 15:11:48 +00004488 * Optional boolean extra indicating whether quiet mode has been switched on or off.
Rubin Xue95057a2016-04-01 16:49:25 +01004489 * When a profile goes into quiet mode, all apps in the profile are killed and the
4490 * profile user is stopped. Widgets originating from the profile are masked, and app
4491 * launcher icons are grayed out.
Rubin Xu0a29ecd2015-11-04 15:11:48 +00004492 */
4493 public static final String EXTRA_QUIET_MODE = "android.intent.extra.QUIET_MODE";
Dongwon Kang2034a4c2015-12-14 21:57:34 +09004494
4495 /**
Dongwon Kang32cb9ab2016-01-13 18:11:10 -08004496 * Used as an int extra field in {@link #ACTION_MEDIA_RESOURCE_GRANTED}
Dongwon Kang2034a4c2015-12-14 21:57:34 +09004497 * intents to specify the resource type granted. Possible values are
Dongwon Kang32cb9ab2016-01-13 18:11:10 -08004498 * {@link #EXTRA_MEDIA_RESOURCE_TYPE_VIDEO_CODEC} or
4499 * {@link #EXTRA_MEDIA_RESOURCE_TYPE_AUDIO_CODEC}.
Dongwon Kang2034a4c2015-12-14 21:57:34 +09004500 *
4501 * @hide
4502 */
4503 public static final String EXTRA_MEDIA_RESOURCE_TYPE =
4504 "android.intent.extra.MEDIA_RESOURCE_TYPE";
4505
4506 /**
Ben Lin145b0ca2016-10-14 14:23:40 -07004507 * Used as a boolean extra field in {@link #ACTION_CHOOSER} intents to specify
4508 * whether to show the chooser or not when there is only one application available
4509 * to choose from.
4510 *
4511 * @hide
4512 */
4513 public static final String EXTRA_AUTO_LAUNCH_SINGLE_CHOICE =
4514 "android.intent.extra.AUTO_LAUNCH_SINGLE_CHOICE";
4515
4516 /**
Dongwon Kang32cb9ab2016-01-13 18:11:10 -08004517 * Used as an int value for {@link #EXTRA_MEDIA_RESOURCE_TYPE}
Dongwon Kang2034a4c2015-12-14 21:57:34 +09004518 * to represent that a video codec is allowed to use.
4519 *
4520 * @hide
4521 */
4522 public static final int EXTRA_MEDIA_RESOURCE_TYPE_VIDEO_CODEC = 0;
4523
4524 /**
Dongwon Kang32cb9ab2016-01-13 18:11:10 -08004525 * Used as an int value for {@link #EXTRA_MEDIA_RESOURCE_TYPE}
Dongwon Kang2034a4c2015-12-14 21:57:34 +09004526 * to represent that a audio codec is allowed to use.
4527 *
4528 * @hide
4529 */
4530 public static final int EXTRA_MEDIA_RESOURCE_TYPE_AUDIO_CODEC = 1;
4531
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004532 // ---------------------------------------------------------------------
4533 // ---------------------------------------------------------------------
4534 // Intent flags (see mFlags variable).
4535
Tor Norbyed9273d62013-05-30 15:59:53 -07004536 /** @hide */
Jeff Sharkey846318a2014-04-04 12:12:41 -07004537 @IntDef(flag = true, value = {
4538 FLAG_GRANT_READ_URI_PERMISSION, FLAG_GRANT_WRITE_URI_PERMISSION,
4539 FLAG_GRANT_PERSISTABLE_URI_PERMISSION, FLAG_GRANT_PREFIX_URI_PERMISSION })
Tor Norbyed9273d62013-05-30 15:59:53 -07004540 @Retention(RetentionPolicy.SOURCE)
4541 public @interface GrantUriMode {}
4542
Jeff Sharkey846318a2014-04-04 12:12:41 -07004543 /** @hide */
4544 @IntDef(flag = true, value = {
4545 FLAG_GRANT_READ_URI_PERMISSION, FLAG_GRANT_WRITE_URI_PERMISSION })
4546 @Retention(RetentionPolicy.SOURCE)
4547 public @interface AccessUriMode {}
4548
4549 /**
4550 * Test if given mode flags specify an access mode, which must be at least
4551 * read and/or write.
4552 *
4553 * @hide
4554 */
4555 public static boolean isAccessUriMode(int modeFlags) {
4556 return (modeFlags & (Intent.FLAG_GRANT_READ_URI_PERMISSION
4557 | Intent.FLAG_GRANT_WRITE_URI_PERMISSION)) != 0;
4558 }
4559
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004560 /**
4561 * If set, the recipient of this Intent will be granted permission to
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004562 * perform read operations on the URI in the Intent's data and any URIs
Dianne Hackborn21c241e2012-03-08 13:57:23 -08004563 * specified in its ClipData. When applying to an Intent's ClipData,
4564 * all URIs as well as recursive traversals through data or other ClipData
4565 * in Intent items will be granted; only the grant flags of the top-level
4566 * Intent are used.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004567 */
4568 public static final int FLAG_GRANT_READ_URI_PERMISSION = 0x00000001;
4569 /**
4570 * If set, the recipient of this Intent will be granted permission to
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004571 * perform write operations on the URI in the Intent's data and any URIs
Dianne Hackborn21c241e2012-03-08 13:57:23 -08004572 * specified in its ClipData. When applying to an Intent's ClipData,
4573 * all URIs as well as recursive traversals through data or other ClipData
4574 * in Intent items will be granted; only the grant flags of the top-level
4575 * Intent are used.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004576 */
4577 public static final int FLAG_GRANT_WRITE_URI_PERMISSION = 0x00000002;
4578 /**
4579 * Can be set by the caller to indicate that this Intent is coming from
4580 * a background operation, not from direct user interaction.
4581 */
4582 public static final int FLAG_FROM_BACKGROUND = 0x00000004;
4583 /**
4584 * A flag you can enable for debugging: when set, log messages will be
4585 * printed during the resolution of this intent to show you what has
4586 * been found to create the final resolved list.
4587 */
4588 public static final int FLAG_DEBUG_LOG_RESOLUTION = 0x00000008;
Dianne Hackborne7f97212011-02-24 14:40:20 -08004589 /**
4590 * If set, this intent will not match any components in packages that
4591 * are currently stopped. If this is not set, then the default behavior
4592 * is to include such applications in the result.
4593 */
4594 public static final int FLAG_EXCLUDE_STOPPED_PACKAGES = 0x00000010;
4595 /**
4596 * If set, this intent will always match any components in packages that
4597 * are currently stopped. This is the default behavior when
4598 * {@link #FLAG_EXCLUDE_STOPPED_PACKAGES} is not set. If both of these
4599 * flags are set, this one wins (it allows overriding of exclude for
4600 * places where the framework may automatically set the exclude flag).
4601 */
4602 public static final int FLAG_INCLUDE_STOPPED_PACKAGES = 0x00000020;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004603
4604 /**
Jeff Sharkey328ebf22013-03-21 18:09:39 -07004605 * When combined with {@link #FLAG_GRANT_READ_URI_PERMISSION} and/or
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004606 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, the URI permission grant can be
Jeff Sharkeye66c1772013-09-20 14:30:59 -07004607 * persisted across device reboots until explicitly revoked with
4608 * {@link Context#revokeUriPermission(Uri, int)}. This flag only offers the
4609 * grant for possible persisting; the receiving application must call
4610 * {@link ContentResolver#takePersistableUriPermission(Uri, int)} to
4611 * actually persist.
4612 *
4613 * @see ContentResolver#takePersistableUriPermission(Uri, int)
4614 * @see ContentResolver#releasePersistableUriPermission(Uri, int)
4615 * @see ContentResolver#getPersistedUriPermissions()
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004616 * @see ContentResolver#getOutgoingPersistedUriPermissions()
Jeff Sharkey328ebf22013-03-21 18:09:39 -07004617 */
Jeff Sharkeye66c1772013-09-20 14:30:59 -07004618 public static final int FLAG_GRANT_PERSISTABLE_URI_PERMISSION = 0x00000040;
Jeff Sharkey328ebf22013-03-21 18:09:39 -07004619
4620 /**
Jeff Sharkey846318a2014-04-04 12:12:41 -07004621 * When combined with {@link #FLAG_GRANT_READ_URI_PERMISSION} and/or
4622 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, the URI permission grant
4623 * applies to any URI that is a prefix match against the original granted
4624 * URI. (Without this flag, the URI must match exactly for access to be
4625 * granted.) Another URI is considered a prefix match only when scheme,
4626 * authority, and all path segments defined by the prefix are an exact
4627 * match.
4628 */
4629 public static final int FLAG_GRANT_PREFIX_URI_PERMISSION = 0x00000080;
4630
4631 /**
Jeff Sharkey2a9e3f82015-12-18 10:57:58 -07004632 * Internal flag used to indicate that a system component has done their
Jeff Sharkey2f3e3532015-12-21 14:16:43 -07004633 * homework and verified that they correctly handle packages and components
4634 * that come and go over time. In particular:
4635 * <ul>
4636 * <li>Apps installed on external storage, which will appear to be
4637 * uninstalled while the the device is ejected.
4638 * <li>Apps with encryption unaware components, which will appear to not
4639 * exist while the device is locked.
4640 * </ul>
Jeff Sharkey2a9e3f82015-12-18 10:57:58 -07004641 *
4642 * @hide
4643 */
Jeff Sharkey2f3e3532015-12-21 14:16:43 -07004644 public static final int FLAG_DEBUG_TRIAGED_MISSING = 0x00000100;
Jeff Sharkey2a9e3f82015-12-18 10:57:58 -07004645
4646 /**
Todd Kennedy8e2d9d12016-06-28 14:09:55 -07004647 * Internal flag used to indicate ephemeral applications should not be
4648 * considered when resolving the intent.
4649 *
4650 * @hide
4651 */
4652 public static final int FLAG_IGNORE_EPHEMERAL = 0x00000200;
4653
4654 /**
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08004655 * If set, the new activity is not kept in the history stack. As soon as
4656 * the user navigates away from it, the activity is finished. This may also
4657 * be set with the {@link android.R.styleable#AndroidManifestActivity_noHistory
4658 * noHistory} attribute.
Ricardo Cervera92f6a742014-04-04 11:17:06 -07004659 *
4660 * <p>If set, {@link android.app.Activity#onActivityResult onActivityResult()}
4661 * is never invoked when the current activity starts a new activity which
4662 * sets a result and finishes.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004663 */
4664 public static final int FLAG_ACTIVITY_NO_HISTORY = 0x40000000;
4665 /**
4666 * If set, the activity will not be launched if it is already running
4667 * at the top of the history stack.
4668 */
4669 public static final int FLAG_ACTIVITY_SINGLE_TOP = 0x20000000;
4670 /**
4671 * If set, this activity will become the start of a new task on this
4672 * history stack. A task (from the activity that started it to the
4673 * next task activity) defines an atomic group of activities that the
4674 * user can move to. Tasks can be moved to the foreground and background;
4675 * all of the activities inside of a particular task always remain in
The Android Open Source Project10592532009-03-18 17:39:46 -07004676 * the same order. See
Scott Main7aee61f2011-02-08 11:25:01 -08004677 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
4678 * Stack</a> for more information about tasks.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004679 *
4680 * <p>This flag is generally used by activities that want
4681 * to present a "launcher" style behavior: they give the user a list of
4682 * separate things that can be done, which otherwise run completely
4683 * independently of the activity launching them.
4684 *
4685 * <p>When using this flag, if a task is already running for the activity
4686 * you are now starting, then a new activity will not be started; instead,
4687 * the current task will simply be brought to the front of the screen with
4688 * the state it was last in. See {@link #FLAG_ACTIVITY_MULTIPLE_TASK} for a flag
4689 * to disable this behavior.
4690 *
4691 * <p>This flag can not be used when the caller is requesting a result from
4692 * the activity being launched.
4693 */
4694 public static final int FLAG_ACTIVITY_NEW_TASK = 0x10000000;
4695 /**
Craig Mautnerd00f4742014-03-12 14:17:26 -07004696 * This flag is used to create a new task and launch an activity into it.
4697 * This flag is always paired with either {@link #FLAG_ACTIVITY_NEW_DOCUMENT}
4698 * or {@link #FLAG_ACTIVITY_NEW_TASK}. In both cases these flags alone would
4699 * search through existing tasks for ones matching this Intent. Only if no such
4700 * task is found would a new task be created. When paired with
4701 * FLAG_ACTIVITY_MULTIPLE_TASK both of these behaviors are modified to skip
4702 * the search for a matching task and unconditionally start a new task.
4703 *
4704 * <strong>When used with {@link #FLAG_ACTIVITY_NEW_TASK} do not use this
4705 * flag unless you are implementing your own
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004706 * top-level application launcher.</strong> Used in conjunction with
4707 * {@link #FLAG_ACTIVITY_NEW_TASK} to disable the
4708 * behavior of bringing an existing task to the foreground. When set,
4709 * a new task is <em>always</em> started to host the Activity for the
4710 * Intent, regardless of whether there is already an existing task running
4711 * the same thing.
4712 *
4713 * <p><strong>Because the default system does not include graphical task management,
4714 * you should not use this flag unless you provide some way for a user to
4715 * return back to the tasks you have launched.</strong>
The Android Open Source Project10592532009-03-18 17:39:46 -07004716 *
Craig Mautnerd00f4742014-03-12 14:17:26 -07004717 * See {@link #FLAG_ACTIVITY_NEW_DOCUMENT} for details of this flag's use for
4718 * creating new document tasks.
4719 *
4720 * <p>This flag is ignored if one of {@link #FLAG_ACTIVITY_NEW_TASK} or
Paul Soulos628cb742014-09-19 11:00:52 -07004721 * {@link #FLAG_ACTIVITY_NEW_DOCUMENT} is not also set.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004722 *
Scott Main7aee61f2011-02-08 11:25:01 -08004723 * <p>See
4724 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
4725 * Stack</a> for more information about tasks.
Craig Mautnerd00f4742014-03-12 14:17:26 -07004726 *
4727 * @see #FLAG_ACTIVITY_NEW_DOCUMENT
4728 * @see #FLAG_ACTIVITY_NEW_TASK
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004729 */
4730 public static final int FLAG_ACTIVITY_MULTIPLE_TASK = 0x08000000;
4731 /**
4732 * If set, and the activity being launched is already running in the
4733 * current task, then instead of launching a new instance of that activity,
4734 * all of the other activities on top of it will be closed and this Intent
4735 * will be delivered to the (now on top) old activity as a new Intent.
4736 *
4737 * <p>For example, consider a task consisting of the activities: A, B, C, D.
4738 * If D calls startActivity() with an Intent that resolves to the component
4739 * of activity B, then C and D will be finished and B receive the given
4740 * Intent, resulting in the stack now being: A, B.
4741 *
Dianne Hackbornaa52f9a2009-08-25 16:01:15 -07004742 * <p>The currently running instance of activity B in the above example will
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004743 * either receive the new intent you are starting here in its
4744 * onNewIntent() method, or be itself finished and restarted with the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004745 * new intent. If it has declared its launch mode to be "multiple" (the
Dianne Hackbornaa52f9a2009-08-25 16:01:15 -07004746 * default) and you have not set {@link #FLAG_ACTIVITY_SINGLE_TOP} in
4747 * the same intent, then it will be finished and re-created; for all other
4748 * launch modes or if {@link #FLAG_ACTIVITY_SINGLE_TOP} is set then this
4749 * Intent will be delivered to the current instance's onNewIntent().
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004750 *
4751 * <p>This launch mode can also be used to good effect in conjunction with
4752 * {@link #FLAG_ACTIVITY_NEW_TASK}: if used to start the root activity
4753 * of a task, it will bring any currently running instance of that task
4754 * to the foreground, and then clear it to its root state. This is
4755 * especially useful, for example, when launching an activity from the
4756 * notification manager.
4757 *
Scott Main7aee61f2011-02-08 11:25:01 -08004758 * <p>See
4759 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
4760 * Stack</a> for more information about tasks.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004761 */
4762 public static final int FLAG_ACTIVITY_CLEAR_TOP = 0x04000000;
4763 /**
4764 * If set and this intent is being used to launch a new activity from an
4765 * existing one, then the reply target of the existing activity will be
4766 * transfered to the new activity. This way the new activity can call
4767 * {@link android.app.Activity#setResult} and have that result sent back to
4768 * the reply target of the original activity.
4769 */
4770 public static final int FLAG_ACTIVITY_FORWARD_RESULT = 0x02000000;
4771 /**
4772 * If set and this intent is being used to launch a new activity from an
4773 * existing one, the current activity will not be counted as the top
4774 * activity for deciding whether the new intent should be delivered to
4775 * the top instead of starting a new one. The previous activity will
4776 * be used as the top, with the assumption being that the current activity
4777 * will finish itself immediately.
4778 */
4779 public static final int FLAG_ACTIVITY_PREVIOUS_IS_TOP = 0x01000000;
4780 /**
4781 * If set, the new activity is not kept in the list of recently launched
4782 * activities.
4783 */
4784 public static final int FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS = 0x00800000;
4785 /**
4786 * This flag is not normally set by application code, but set for you by
4787 * the system as described in the
4788 * {@link android.R.styleable#AndroidManifestActivity_launchMode
4789 * launchMode} documentation for the singleTask mode.
4790 */
4791 public static final int FLAG_ACTIVITY_BROUGHT_TO_FRONT = 0x00400000;
4792 /**
4793 * If set, and this activity is either being started in a new task or
4794 * bringing to the top an existing task, then it will be launched as
4795 * the front door of the task. This will result in the application of
4796 * any affinities needed to have that task in the proper state (either
4797 * moving activities to or from it), or simply resetting that task to
4798 * its initial state if needed.
4799 */
4800 public static final int FLAG_ACTIVITY_RESET_TASK_IF_NEEDED = 0x00200000;
4801 /**
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08004802 * This flag is not normally set by application code, but set for you by
4803 * the system if this activity is being launched from history
4804 * (longpress home key).
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004805 */
4806 public static final int FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY = 0x00100000;
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08004807 /**
Craig Mautnerf357c0c2014-06-09 09:23:27 -07004808 * @deprecated As of API 21 this performs identically to
4809 * {@link #FLAG_ACTIVITY_NEW_DOCUMENT} which should be used instead of this.
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08004810 */
Aurimas Liutikas514c5ef2016-05-24 15:22:55 -07004811 @Deprecated
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08004812 public static final int FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET = 0x00080000;
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08004813 /**
Craig Mautner026596b2014-05-21 15:35:44 -07004814 * This flag is used to open a document into a new task rooted at the activity launched
4815 * by this Intent. Through the use of this flag, or its equivalent attribute,
4816 * {@link android.R.attr#documentLaunchMode} multiple instances of the same activity
Chet Haase0d1c27a2014-11-03 18:35:16 +00004817 * containing different documents will appear in the recent tasks list.
Craig Mautnerd00f4742014-03-12 14:17:26 -07004818 *
Craig Mautner026596b2014-05-21 15:35:44 -07004819 * <p>The use of the activity attribute form of this,
4820 * {@link android.R.attr#documentLaunchMode}, is
4821 * preferred over the Intent flag described here. The attribute form allows the
4822 * Activity to specify multiple document behavior for all launchers of the Activity
4823 * whereas using this flag requires each Intent that launches the Activity to specify it.
Craig Mautnerd00f4742014-03-12 14:17:26 -07004824 *
Dianne Hackborn13420f22014-07-18 15:43:56 -07004825 * <p>Note that the default semantics of this flag w.r.t. whether the recents entry for
4826 * it is kept after the activity is finished is different than the use of
4827 * {@link #FLAG_ACTIVITY_NEW_TASK} and {@link android.R.attr#documentLaunchMode} -- if
4828 * this flag is being used to create a new recents entry, then by default that entry
4829 * will be removed once the activity is finished. You can modify this behavior with
4830 * {@link #FLAG_ACTIVITY_RETAIN_IN_RECENTS}.
4831 *
Craig Mautner026596b2014-05-21 15:35:44 -07004832 * <p>FLAG_ACTIVITY_NEW_DOCUMENT may be used in conjunction with {@link
4833 * #FLAG_ACTIVITY_MULTIPLE_TASK}. When used alone it is the
4834 * equivalent of the Activity manifest specifying {@link
4835 * android.R.attr#documentLaunchMode}="intoExisting". When used with
4836 * FLAG_ACTIVITY_MULTIPLE_TASK it is the equivalent of the Activity manifest specifying
4837 * {@link android.R.attr#documentLaunchMode}="always".
Craig Mautnerd00f4742014-03-12 14:17:26 -07004838 *
Craig Mautner026596b2014-05-21 15:35:44 -07004839 * Refer to {@link android.R.attr#documentLaunchMode} for more information.
Craig Mautnerd00f4742014-03-12 14:17:26 -07004840 *
Craig Mautner026596b2014-05-21 15:35:44 -07004841 * @see android.R.attr#documentLaunchMode
Craig Mautnerd00f4742014-03-12 14:17:26 -07004842 * @see #FLAG_ACTIVITY_MULTIPLE_TASK
4843 */
Craig Mautnerf357c0c2014-06-09 09:23:27 -07004844 public static final int FLAG_ACTIVITY_NEW_DOCUMENT = FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET;
Craig Mautnerd00f4742014-03-12 14:17:26 -07004845 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004846 * If set, this flag will prevent the normal {@link android.app.Activity#onUserLeaveHint}
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08004847 * callback from occurring on the current frontmost activity before it is
4848 * paused as the newly-started activity is brought to the front.
The Android Open Source Project10592532009-03-18 17:39:46 -07004849 *
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08004850 * <p>Typically, an activity can rely on that callback to indicate that an
4851 * explicit user action has caused their activity to be moved out of the
4852 * foreground. The callback marks an appropriate point in the activity's
4853 * lifecycle for it to dismiss any notifications that it intends to display
4854 * "until the user has seen them," such as a blinking LED.
The Android Open Source Project10592532009-03-18 17:39:46 -07004855 *
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08004856 * <p>If an activity is ever started via any non-user-driven events such as
4857 * phone-call receipt or an alarm handler, this flag should be passed to {@link
4858 * Context#startActivity Context.startActivity}, ensuring that the pausing
The Android Open Source Project10592532009-03-18 17:39:46 -07004859 * activity does not think the user has acknowledged its notification.
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08004860 */
4861 public static final int FLAG_ACTIVITY_NO_USER_ACTION = 0x00040000;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004862 /**
4863 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
4864 * this flag will cause the launched activity to be brought to the front of its
4865 * task's history stack if it is already running.
The Android Open Source Project10592532009-03-18 17:39:46 -07004866 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004867 * <p>For example, consider a task consisting of four activities: A, B, C, D.
4868 * If D calls startActivity() with an Intent that resolves to the component
4869 * of activity B, then B will be brought to the front of the history stack,
4870 * with this resulting order: A, C, D, B.
The Android Open Source Project10592532009-03-18 17:39:46 -07004871 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004872 * This flag will be ignored if {@link #FLAG_ACTIVITY_CLEAR_TOP} is also
The Android Open Source Project10592532009-03-18 17:39:46 -07004873 * specified.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004874 */
4875 public static final int FLAG_ACTIVITY_REORDER_TO_FRONT = 0X00020000;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004876 /**
Dianne Hackbornbfe319e2009-09-21 00:34:05 -07004877 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
4878 * this flag will prevent the system from applying an activity transition
4879 * animation to go to the next activity state. This doesn't mean an
4880 * animation will never run -- if another activity change happens that doesn't
4881 * specify this flag before the activity started here is displayed, then
Dianne Hackborn621e17d2010-11-22 15:59:56 -08004882 * that transition will be used. This flag can be put to good use
Dianne Hackbornbfe319e2009-09-21 00:34:05 -07004883 * when you are going to do a series of activity operations but the
4884 * animation seen by the user shouldn't be driven by the first activity
4885 * change but rather a later one.
4886 */
4887 public static final int FLAG_ACTIVITY_NO_ANIMATION = 0X00010000;
4888 /**
Dianne Hackborn621e17d2010-11-22 15:59:56 -08004889 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
4890 * this flag will cause any existing task that would be associated with the
4891 * activity to be cleared before the activity is started. That is, the activity
4892 * becomes the new root of an otherwise empty task, and any old activities
4893 * are finished. This can only be used in conjunction with {@link #FLAG_ACTIVITY_NEW_TASK}.
4894 */
4895 public static final int FLAG_ACTIVITY_CLEAR_TASK = 0X00008000;
4896 /**
4897 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
4898 * this flag will cause a newly launching task to be placed on top of the current
4899 * home activity task (if there is one). That is, pressing back from the task
4900 * will always return the user to home even if that was not the last activity they
4901 * saw. This can only be used in conjunction with {@link #FLAG_ACTIVITY_NEW_TASK}.
4902 */
4903 public static final int FLAG_ACTIVITY_TASK_ON_HOME = 0X00004000;
4904 /**
Dianne Hackborn13420f22014-07-18 15:43:56 -07004905 * By default a document created by {@link #FLAG_ACTIVITY_NEW_DOCUMENT} will
4906 * have its entry in recent tasks removed when the user closes it (with back
Jeff Sharkey9f991a22014-08-13 11:37:41 -07004907 * or however else it may finish()). If you would like to instead allow the
Dianne Hackborn13420f22014-07-18 15:43:56 -07004908 * document to be kept in recents so that it can be re-launched, you can use
Jeff Sharkey9f991a22014-08-13 11:37:41 -07004909 * this flag. When set and the task's activity is finished, the recents
4910 * entry will remain in the interface for the user to re-launch it, like a
4911 * recents entry for a top-level application.
4912 * <p>
4913 * The receiving activity can override this request with
4914 * {@link android.R.attr#autoRemoveFromRecents} or by explcitly calling
4915 * {@link android.app.Activity#finishAndRemoveTask()
Dianne Hackborn13420f22014-07-18 15:43:56 -07004916 * Activity.finishAndRemoveTask()}.
Craig Mautner2dac0562014-05-06 09:06:44 -07004917 */
Dianne Hackborn13420f22014-07-18 15:43:56 -07004918 public static final int FLAG_ACTIVITY_RETAIN_IN_RECENTS = 0x00002000;
Craig Mautnera228ae92014-07-09 05:44:55 -07004919
4920 /**
Wale Ogunwale2a25a622016-01-30 11:27:21 -08004921 * This flag is only used in split-screen multi-window mode. The new activity will be displayed
4922 * adjacent to the one launching it. This can only be used in conjunction with
Wale Ogunwale6bdf2572016-03-11 15:22:38 -08004923 * {@link #FLAG_ACTIVITY_NEW_TASK}. Also, setting {@link #FLAG_ACTIVITY_MULTIPLE_TASK} is
4924 * required if you want a new instance of an existing activity to be created.
Filip Gruszczynski80e29f12015-12-14 14:58:30 -08004925 */
Wale Ogunwale2a25a622016-01-30 11:27:21 -08004926 public static final int FLAG_ACTIVITY_LAUNCH_ADJACENT = 0x00001000;
Filip Gruszczynski80e29f12015-12-14 14:58:30 -08004927
4928 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004929 * If set, when sending a broadcast only registered receivers will be
4930 * called -- no BroadcastReceiver components will be launched.
4931 */
4932 public static final int FLAG_RECEIVER_REGISTERED_ONLY = 0x40000000;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004933 /**
Dianne Hackborn1c633fc2009-12-08 19:45:14 -08004934 * If set, when sending a broadcast the new broadcast will replace
4935 * any existing pending broadcast that matches it. Matching is defined
4936 * by {@link Intent#filterEquals(Intent) Intent.filterEquals} returning
4937 * true for the intents of the two broadcasts. When a match is found,
4938 * the new broadcast (and receivers associated with it) will replace the
4939 * existing one in the pending broadcast list, remaining at the same
4940 * position in the list.
Tom Taylord4a47292009-12-21 13:59:18 -08004941 *
Dianne Hackborn1c633fc2009-12-08 19:45:14 -08004942 * <p>This flag is most typically used with sticky broadcasts, which
4943 * only care about delivering the most recent values of the broadcast
4944 * to their receivers.
4945 */
4946 public static final int FLAG_RECEIVER_REPLACE_PENDING = 0x20000000;
4947 /**
Christopher Tatef46723b2012-01-26 14:19:24 -08004948 * If set, when sending a broadcast the recipient is allowed to run at
4949 * foreground priority, with a shorter timeout interval. During normal
4950 * broadcasts the receivers are not automatically hoisted out of the
4951 * background priority class.
4952 */
4953 public static final int FLAG_RECEIVER_FOREGROUND = 0x10000000;
4954 /**
Dianne Hackborn6285a322013-09-18 12:09:47 -07004955 * If this is an ordered broadcast, don't allow receivers to abort the broadcast.
4956 * They can still propagate results through to later receivers, but they can not prevent
4957 * later receivers from seeing the broadcast.
4958 */
4959 public static final int FLAG_RECEIVER_NO_ABORT = 0x08000000;
4960 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004961 * If set, when sending a broadcast <i>before boot has completed</i> only
4962 * registered receivers will be called -- no BroadcastReceiver components
4963 * will be launched. Sticky intent state will be recorded properly even
4964 * if no receivers wind up being called. If {@link #FLAG_RECEIVER_REGISTERED_ONLY}
4965 * is specified in the broadcast intent, this flag is unnecessary.
The Android Open Source Project10592532009-03-18 17:39:46 -07004966 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004967 * <p>This flag is only for use by system sevices as a convenience to
4968 * avoid having to implement a more complex mechanism around detection
4969 * of boot completion.
The Android Open Source Project10592532009-03-18 17:39:46 -07004970 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004971 * @hide
4972 */
Dianne Hackborn6285a322013-09-18 12:09:47 -07004973 public static final int FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT = 0x04000000;
Dianne Hackborn9acc0302009-08-25 00:27:12 -07004974 /**
4975 * Set when this broadcast is for a boot upgrade, a special mode that
4976 * allows the broadcast to be sent before the system is ready and launches
4977 * the app process with no providers running in it.
4978 * @hide
4979 */
Dianne Hackborn6285a322013-09-18 12:09:47 -07004980 public static final int FLAG_RECEIVER_BOOT_UPGRADE = 0x02000000;
Dianne Hackborn6ac42ae2015-12-08 17:22:10 -08004981 /**
4982 * If set, the broadcast will always go to manifest receivers in background (cached
4983 * or not running) apps, regardless of whether that would be done by default. By
4984 * default they will only receive broadcasts if the broadcast has specified an
4985 * explicit component or package name.
Christopher Tatebdc39412017-01-23 12:21:13 -08004986 *
4987 * NOTE: dumpstate uses this flag numerically, so when its value is changed
4988 * the broadcast code there must also be changed to match.
4989 *
Dianne Hackborn6ac42ae2015-12-08 17:22:10 -08004990 * @hide
4991 */
4992 public static final int FLAG_RECEIVER_INCLUDE_BACKGROUND = 0x01000000;
4993 /**
4994 * If set, the broadcast will never go to manifest receivers in background (cached
4995 * or not running) apps, regardless of whether that would be done by default. By
4996 * default they will receive broadcasts if the broadcast has specified an
4997 * explicit component or package name.
4998 * @hide
4999 */
5000 public static final int FLAG_RECEIVER_EXCLUDE_BACKGROUND = 0x00800000;
Jeff Sharkey6a34e562016-12-21 09:56:00 -07005001 /**
5002 * If set, this broadcast is being sent from the shell.
5003 * @hide
5004 */
5005 public static final int FLAG_RECEIVER_FROM_SHELL = 0x00400000;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005006
Dianne Hackbornfa82f222009-09-17 15:14:12 -07005007 /**
5008 * @hide Flags that can't be changed with PendingIntent.
5009 */
Jeff Sharkey846318a2014-04-04 12:12:41 -07005010 public static final int IMMUTABLE_FLAGS = FLAG_GRANT_READ_URI_PERMISSION
5011 | FLAG_GRANT_WRITE_URI_PERMISSION | FLAG_GRANT_PERSISTABLE_URI_PERMISSION
5012 | FLAG_GRANT_PREFIX_URI_PERMISSION;
Tom Taylord4a47292009-12-21 13:59:18 -08005013
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005014 // ---------------------------------------------------------------------
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005015 // ---------------------------------------------------------------------
5016 // toUri() and parseUri() options.
5017
5018 /**
5019 * Flag for use with {@link #toUri} and {@link #parseUri}: the URI string
5020 * always has the "intent:" scheme. This syntax can be used when you want
5021 * to later disambiguate between URIs that are intended to describe an
5022 * Intent vs. all others that should be treated as raw URIs. When used
5023 * with {@link #parseUri}, any other scheme will result in a generic
5024 * VIEW action for that raw URI.
5025 */
5026 public static final int URI_INTENT_SCHEME = 1<<0;
Tom Taylord4a47292009-12-21 13:59:18 -08005027
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005028 /**
5029 * Flag for use with {@link #toUri} and {@link #parseUri}: the URI string
5030 * always has the "android-app:" scheme. This is a variation of
5031 * {@link #URI_INTENT_SCHEME} whose format is simpler for the case of an
5032 * http/https URI being delivered to a specific package name. The format
5033 * is:
5034 *
5035 * <pre class="prettyprint">
Dianne Hackborn0ee10f62015-01-14 16:16:13 -08005036 * android-app://{package_id}[/{scheme}[/{host}[/{path}]]][#Intent;{...}]</pre>
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005037 *
Dianne Hackborn0ee10f62015-01-14 16:16:13 -08005038 * <p>In this scheme, only the <code>package_id</code> is required. If you include a host,
5039 * you must also include a scheme; including a path also requires both a host and a scheme.
5040 * The final #Intent; fragment can be used without a scheme, host, or path.
5041 * Note that this can not be
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005042 * used with intents that have a {@link #setSelector}, since the base intent
5043 * will always have an explicit package name.</p>
5044 *
5045 * <p>Some examples of how this scheme maps to Intent objects:</p>
5046 * <table border="2" width="85%" align="center" frame="hsides" rules="rows">
5047 * <colgroup align="left" />
5048 * <colgroup align="left" />
5049 * <thead>
5050 * <tr><th>URI</th> <th>Intent</th></tr>
5051 * </thead>
5052 *
5053 * <tbody>
5054 * <tr><td><code>android-app://com.example.app</code></td>
5055 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
5056 * <tr><td>Action: </td><td>{@link #ACTION_MAIN}</td></tr>
5057 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
5058 * </table></td>
5059 * </tr>
5060 * <tr><td><code>android-app://com.example.app/http/example.com</code></td>
5061 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
5062 * <tr><td>Action: </td><td>{@link #ACTION_VIEW}</td></tr>
5063 * <tr><td>Data: </td><td><code>http://example.com/</code></td></tr>
5064 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
5065 * </table></td>
5066 * </tr>
5067 * <tr><td><code>android-app://com.example.app/http/example.com/foo?1234</code></td>
5068 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
5069 * <tr><td>Action: </td><td>{@link #ACTION_VIEW}</td></tr>
5070 * <tr><td>Data: </td><td><code>http://example.com/foo?1234</code></td></tr>
5071 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
5072 * </table></td>
5073 * </tr>
5074 * <tr><td><code>android-app://com.example.app/<br />#Intent;action=com.example.MY_ACTION;end</code></td>
5075 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
5076 * <tr><td>Action: </td><td><code>com.example.MY_ACTION</code></td></tr>
5077 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
5078 * </table></td>
5079 * </tr>
5080 * <tr><td><code>android-app://com.example.app/http/example.com/foo?1234<br />#Intent;action=com.example.MY_ACTION;end</code></td>
5081 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
5082 * <tr><td>Action: </td><td><code>com.example.MY_ACTION</code></td></tr>
5083 * <tr><td>Data: </td><td><code>http://example.com/foo?1234</code></td></tr>
5084 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
5085 * </table></td>
5086 * </tr>
5087 * <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>
5088 * <td><table border="" style="margin:0" >
5089 * <tr><td>Action: </td><td><code>com.example.MY_ACTION</code></td></tr>
5090 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
5091 * <tr><td>Extras: </td><td><code>some_int=(int)100<br />some_str=(String)hello</code></td></tr>
5092 * </table></td>
5093 * </tr>
5094 * </tbody>
5095 * </table>
5096 */
5097 public static final int URI_ANDROID_APP_SCHEME = 1<<1;
5098
Dianne Hackborn24b1c232014-11-20 17:17:39 -08005099 /**
5100 * Flag for use with {@link #toUri} and {@link #parseUri}: allow parsing
5101 * of unsafe information. In particular, the flags {@link #FLAG_GRANT_READ_URI_PERMISSION},
5102 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, {@link #FLAG_GRANT_PERSISTABLE_URI_PERMISSION},
5103 * and {@link #FLAG_GRANT_PREFIX_URI_PERMISSION} flags can not be set, so that the
5104 * generated Intent can not cause unexpected data access to happen.
5105 *
5106 * <p>If you do not trust the source of the URI being parsed, you should still do further
5107 * processing to protect yourself from it. In particular, when using it to start an
5108 * activity you should usually add in {@link #CATEGORY_BROWSABLE} to limit the activities
5109 * that can handle it.</p>
5110 */
5111 public static final int URI_ALLOW_UNSAFE = 1<<2;
5112
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005113 // ---------------------------------------------------------------------
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005114
5115 private String mAction;
5116 private Uri mData;
5117 private String mType;
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005118 private String mPackage;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005119 private ComponentName mComponent;
5120 private int mFlags;
Dianne Hackbornadd005c2013-07-17 18:43:12 -07005121 private ArraySet<String> mCategories;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005122 private Bundle mExtras;
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08005123 private Rect mSourceBounds;
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005124 private Intent mSelector;
Dianne Hackborn21c241e2012-03-08 13:57:23 -08005125 private ClipData mClipData;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01005126 private int mContentUserHint = UserHandle.USER_CURRENT;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005127
5128 // ---------------------------------------------------------------------
5129
5130 /**
5131 * Create an empty intent.
5132 */
5133 public Intent() {
5134 }
5135
5136 /**
5137 * Copy constructor.
5138 */
5139 public Intent(Intent o) {
5140 this.mAction = o.mAction;
5141 this.mData = o.mData;
5142 this.mType = o.mType;
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005143 this.mPackage = o.mPackage;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005144 this.mComponent = o.mComponent;
5145 this.mFlags = o.mFlags;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01005146 this.mContentUserHint = o.mContentUserHint;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005147 if (o.mCategories != null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07005148 this.mCategories = new ArraySet<String>(o.mCategories);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005149 }
5150 if (o.mExtras != null) {
5151 this.mExtras = new Bundle(o.mExtras);
5152 }
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08005153 if (o.mSourceBounds != null) {
5154 this.mSourceBounds = new Rect(o.mSourceBounds);
5155 }
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005156 if (o.mSelector != null) {
5157 this.mSelector = new Intent(o.mSelector);
5158 }
Dianne Hackborn21c241e2012-03-08 13:57:23 -08005159 if (o.mClipData != null) {
5160 this.mClipData = new ClipData(o.mClipData);
5161 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005162 }
5163
5164 @Override
5165 public Object clone() {
5166 return new Intent(this);
5167 }
5168
5169 private Intent(Intent o, boolean all) {
5170 this.mAction = o.mAction;
5171 this.mData = o.mData;
5172 this.mType = o.mType;
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005173 this.mPackage = o.mPackage;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005174 this.mComponent = o.mComponent;
5175 if (o.mCategories != null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07005176 this.mCategories = new ArraySet<String>(o.mCategories);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005177 }
5178 }
5179
5180 /**
5181 * Make a clone of only the parts of the Intent that are relevant for
5182 * filter matching: the action, data, type, component, and categories.
5183 */
5184 public Intent cloneFilter() {
5185 return new Intent(this, false);
5186 }
5187
5188 /**
5189 * Create an intent with a given action. All other fields (data, type,
5190 * class) are null. Note that the action <em>must</em> be in a
5191 * namespace because Intents are used globally in the system -- for
5192 * example the system VIEW action is android.intent.action.VIEW; an
5193 * application's custom action would be something like
5194 * com.google.app.myapp.CUSTOM_ACTION.
5195 *
5196 * @param action The Intent action, such as ACTION_VIEW.
5197 */
5198 public Intent(String action) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08005199 setAction(action);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005200 }
5201
5202 /**
5203 * Create an intent with a given action and for a given data url. Note
5204 * that the action <em>must</em> be in a namespace because Intents are
5205 * used globally in the system -- for example the system VIEW action is
5206 * android.intent.action.VIEW; an application's custom action would be
5207 * something like com.google.app.myapp.CUSTOM_ACTION.
5208 *
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07005209 * <p><em>Note: scheme and host name matching in the Android framework is
5210 * case-sensitive, unlike the formal RFC. As a result,
5211 * you should always ensure that you write your Uri with these elements
5212 * using lower case letters, and normalize any Uris you receive from
5213 * outside of Android to ensure the scheme and host is lower case.</em></p>
5214 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005215 * @param action The Intent action, such as ACTION_VIEW.
5216 * @param uri The Intent data URI.
5217 */
5218 public Intent(String action, Uri uri) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08005219 setAction(action);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005220 mData = uri;
5221 }
5222
5223 /**
5224 * Create an intent for a specific component. All other fields (action, data,
5225 * type, class) are null, though they can be modified later with explicit
5226 * calls. This provides a convenient way to create an intent that is
5227 * intended to execute a hard-coded class name, rather than relying on the
5228 * system to find an appropriate class for you; see {@link #setComponent}
5229 * for more information on the repercussions of this.
5230 *
5231 * @param packageContext A Context of the application package implementing
5232 * this class.
5233 * @param cls The component class that is to be used for the intent.
5234 *
5235 * @see #setClass
5236 * @see #setComponent
5237 * @see #Intent(String, android.net.Uri , Context, Class)
5238 */
5239 public Intent(Context packageContext, Class<?> cls) {
5240 mComponent = new ComponentName(packageContext, cls);
5241 }
5242
5243 /**
5244 * Create an intent for a specific component with a specified action and data.
Craig Mautner2dac0562014-05-06 09:06:44 -07005245 * This is equivalent to using {@link #Intent(String, android.net.Uri)} to
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005246 * construct the Intent and then calling {@link #setClass} to set its
5247 * class.
5248 *
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07005249 * <p><em>Note: scheme and host name matching in the Android framework is
5250 * case-sensitive, unlike the formal RFC. As a result,
5251 * you should always ensure that you write your Uri with these elements
5252 * using lower case letters, and normalize any Uris you receive from
5253 * outside of Android to ensure the scheme and host is lower case.</em></p>
5254 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005255 * @param action The Intent action, such as ACTION_VIEW.
5256 * @param uri The Intent data URI.
5257 * @param packageContext A Context of the application package implementing
5258 * this class.
5259 * @param cls The component class that is to be used for the intent.
5260 *
5261 * @see #Intent(String, android.net.Uri)
5262 * @see #Intent(Context, Class)
5263 * @see #setClass
5264 * @see #setComponent
5265 */
5266 public Intent(String action, Uri uri,
5267 Context packageContext, Class<?> cls) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08005268 setAction(action);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005269 mData = uri;
5270 mComponent = new ComponentName(packageContext, cls);
5271 }
5272
5273 /**
Dianne Hackborn30d71892010-12-11 10:37:55 -08005274 * Create an intent to launch the main (root) activity of a task. This
5275 * is the Intent that is started when the application's is launched from
5276 * Home. For anything else that wants to launch an application in the
5277 * same way, it is important that they use an Intent structured the same
5278 * way, and can use this function to ensure this is the case.
5279 *
5280 * <p>The returned Intent has the given Activity component as its explicit
5281 * component, {@link #ACTION_MAIN} as its action, and includes the
5282 * category {@link #CATEGORY_LAUNCHER}. This does <em>not</em> have
5283 * {@link #FLAG_ACTIVITY_NEW_TASK} set, though typically you will want
5284 * to do that through {@link #addFlags(int)} on the returned Intent.
5285 *
5286 * @param mainActivity The main activity component that this Intent will
5287 * launch.
5288 * @return Returns a newly created Intent that can be used to launch the
5289 * activity as a main application entry.
5290 *
5291 * @see #setClass
5292 * @see #setComponent
5293 */
5294 public static Intent makeMainActivity(ComponentName mainActivity) {
5295 Intent intent = new Intent(ACTION_MAIN);
5296 intent.setComponent(mainActivity);
5297 intent.addCategory(CATEGORY_LAUNCHER);
5298 return intent;
5299 }
5300
5301 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005302 * Make an Intent for the main activity of an application, without
5303 * specifying a specific activity to run but giving a selector to find
5304 * the activity. This results in a final Intent that is structured
5305 * the same as when the application is launched from
5306 * Home. For anything else that wants to launch an application in the
5307 * same way, it is important that they use an Intent structured the same
5308 * way, and can use this function to ensure this is the case.
5309 *
5310 * <p>The returned Intent has {@link #ACTION_MAIN} as its action, and includes the
5311 * category {@link #CATEGORY_LAUNCHER}. This does <em>not</em> have
5312 * {@link #FLAG_ACTIVITY_NEW_TASK} set, though typically you will want
5313 * to do that through {@link #addFlags(int)} on the returned Intent.
5314 *
5315 * @param selectorAction The action name of the Intent's selector.
5316 * @param selectorCategory The name of a category to add to the Intent's
5317 * selector.
5318 * @return Returns a newly created Intent that can be used to launch the
5319 * activity as a main application entry.
5320 *
5321 * @see #setSelector(Intent)
5322 */
5323 public static Intent makeMainSelectorActivity(String selectorAction,
5324 String selectorCategory) {
5325 Intent intent = new Intent(ACTION_MAIN);
5326 intent.addCategory(CATEGORY_LAUNCHER);
5327 Intent selector = new Intent();
5328 selector.setAction(selectorAction);
5329 selector.addCategory(selectorCategory);
5330 intent.setSelector(selector);
5331 return intent;
5332 }
5333
5334 /**
Dianne Hackborn30d71892010-12-11 10:37:55 -08005335 * Make an Intent that can be used to re-launch an application's task
5336 * in its base state. This is like {@link #makeMainActivity(ComponentName)},
5337 * but also sets the flags {@link #FLAG_ACTIVITY_NEW_TASK} and
5338 * {@link #FLAG_ACTIVITY_CLEAR_TASK}.
5339 *
5340 * @param mainActivity The activity component that is the root of the
5341 * task; this is the activity that has been published in the application's
5342 * manifest as the main launcher icon.
5343 *
5344 * @return Returns a newly created Intent that can be used to relaunch the
5345 * activity's task in its root state.
5346 */
5347 public static Intent makeRestartActivityTask(ComponentName mainActivity) {
5348 Intent intent = makeMainActivity(mainActivity);
5349 intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK
5350 | Intent.FLAG_ACTIVITY_CLEAR_TASK);
5351 return intent;
5352 }
5353
5354 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005355 * Call {@link #parseUri} with 0 flags.
5356 * @deprecated Use {@link #parseUri} instead.
5357 */
5358 @Deprecated
5359 public static Intent getIntent(String uri) throws URISyntaxException {
5360 return parseUri(uri, 0);
5361 }
Tom Taylord4a47292009-12-21 13:59:18 -08005362
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005363 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005364 * Create an intent from a URI. This URI may encode the action,
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005365 * category, and other intent fields, if it was returned by
Dianne Hackborn7f205432009-07-28 00:13:47 -07005366 * {@link #toUri}. If the Intent was not generate by toUri(), its data
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005367 * will be the entire URI and its action will be ACTION_VIEW.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005368 *
5369 * <p>The URI given here must not be relative -- that is, it must include
5370 * the scheme and full path.
5371 *
5372 * @param uri The URI to turn into an Intent.
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005373 * @param flags Additional processing flags. Either 0,
5374 * {@link #URI_INTENT_SCHEME}, or {@link #URI_ANDROID_APP_SCHEME}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005375 *
5376 * @return Intent The newly created Intent object.
5377 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005378 * @throws URISyntaxException Throws URISyntaxError if the basic URI syntax
5379 * it bad (as parsed by the Uri class) or the Intent data within the
5380 * URI is invalid.
Tom Taylord4a47292009-12-21 13:59:18 -08005381 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005382 * @see #toUri
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005383 */
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005384 public static Intent parseUri(String uri, int flags) throws URISyntaxException {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005385 int i = 0;
5386 try {
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005387 final boolean androidApp = uri.startsWith("android-app:");
5388
5389 // Validate intent scheme if requested.
5390 if ((flags&(URI_INTENT_SCHEME|URI_ANDROID_APP_SCHEME)) != 0) {
5391 if (!uri.startsWith("intent:") && !androidApp) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005392 Intent intent = new Intent(ACTION_VIEW);
5393 try {
5394 intent.setData(Uri.parse(uri));
5395 } catch (IllegalArgumentException e) {
5396 throw new URISyntaxException(uri, e.getMessage());
5397 }
5398 return intent;
5399 }
5400 }
Tom Taylord4a47292009-12-21 13:59:18 -08005401
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005402 i = uri.lastIndexOf("#");
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005403 // simple case
5404 if (i == -1) {
5405 if (!androidApp) {
5406 return new Intent(ACTION_VIEW, Uri.parse(uri));
5407 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005408
5409 // old format Intent URI
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005410 } else if (!uri.startsWith("#Intent;", i)) {
5411 if (!androidApp) {
Dianne Hackborn24b1c232014-11-20 17:17:39 -08005412 return getIntentOld(uri, flags);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005413 } else {
5414 i = -1;
5415 }
5416 }
The Android Open Source Project10592532009-03-18 17:39:46 -07005417
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005418 // new format
5419 Intent intent = new Intent(ACTION_VIEW);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005420 Intent baseIntent = intent;
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005421 boolean explicitAction = false;
5422 boolean inSelector = false;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005423
5424 // fetch data part, if present
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005425 String scheme = null;
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005426 String data;
5427 if (i >= 0) {
5428 data = uri.substring(0, i);
5429 i += 8; // length of "#Intent;"
5430 } else {
5431 data = uri;
5432 }
The Android Open Source Project10592532009-03-18 17:39:46 -07005433
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005434 // loop over contents of Intent, all name=value;
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005435 while (i >= 0 && !uri.startsWith("end", i)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005436 int eq = uri.indexOf('=', i);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005437 if (eq < 0) eq = i-1;
5438 int semi = uri.indexOf(';', i);
5439 String value = eq < semi ? Uri.decode(uri.substring(eq + 1, semi)) : "";
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005440
5441 // action
5442 if (uri.startsWith("action=", i)) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08005443 intent.setAction(value);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005444 if (!inSelector) {
5445 explicitAction = true;
5446 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005447 }
5448
5449 // categories
5450 else if (uri.startsWith("category=", i)) {
5451 intent.addCategory(value);
5452 }
5453
5454 // type
5455 else if (uri.startsWith("type=", i)) {
5456 intent.mType = value;
5457 }
5458
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08005459 // launch flags
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005460 else if (uri.startsWith("launchFlags=", i)) {
5461 intent.mFlags = Integer.decode(value).intValue();
Dianne Hackborn24b1c232014-11-20 17:17:39 -08005462 if ((flags& URI_ALLOW_UNSAFE) == 0) {
5463 intent.mFlags &= ~IMMUTABLE_FLAGS;
5464 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005465 }
5466
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005467 // package
5468 else if (uri.startsWith("package=", i)) {
5469 intent.mPackage = value;
5470 }
5471
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005472 // component
5473 else if (uri.startsWith("component=", i)) {
5474 intent.mComponent = ComponentName.unflattenFromString(value);
5475 }
The Android Open Source Project10592532009-03-18 17:39:46 -07005476
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005477 // scheme
5478 else if (uri.startsWith("scheme=", i)) {
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005479 if (inSelector) {
Dianne Hackborn80b1c562014-12-09 20:22:08 -08005480 intent.mData = Uri.parse(value + ":");
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005481 } else {
5482 scheme = value;
5483 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005484 }
5485
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08005486 // source bounds
5487 else if (uri.startsWith("sourceBounds=", i)) {
5488 intent.mSourceBounds = Rect.unflattenFromString(value);
5489 }
5490
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005491 // selector
5492 else if (semi == (i+3) && uri.startsWith("SEL", i)) {
5493 intent = new Intent();
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005494 inSelector = true;
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005495 }
5496
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005497 // extra
5498 else {
5499 String key = Uri.decode(uri.substring(i + 2, eq));
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005500 // create Bundle if it doesn't already exist
5501 if (intent.mExtras == null) intent.mExtras = new Bundle();
5502 Bundle b = intent.mExtras;
5503 // add EXTRA
5504 if (uri.startsWith("S.", i)) b.putString(key, value);
5505 else if (uri.startsWith("B.", i)) b.putBoolean(key, Boolean.parseBoolean(value));
5506 else if (uri.startsWith("b.", i)) b.putByte(key, Byte.parseByte(value));
5507 else if (uri.startsWith("c.", i)) b.putChar(key, value.charAt(0));
5508 else if (uri.startsWith("d.", i)) b.putDouble(key, Double.parseDouble(value));
5509 else if (uri.startsWith("f.", i)) b.putFloat(key, Float.parseFloat(value));
5510 else if (uri.startsWith("i.", i)) b.putInt(key, Integer.parseInt(value));
5511 else if (uri.startsWith("l.", i)) b.putLong(key, Long.parseLong(value));
5512 else if (uri.startsWith("s.", i)) b.putShort(key, Short.parseShort(value));
5513 else throw new URISyntaxException(uri, "unknown EXTRA type", i);
5514 }
The Android Open Source Project10592532009-03-18 17:39:46 -07005515
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005516 // move to the next item
5517 i = semi + 1;
5518 }
5519
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005520 if (inSelector) {
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005521 // The Intent had a selector; fix it up.
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005522 if (baseIntent.mPackage == null) {
5523 baseIntent.setSelector(intent);
5524 }
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005525 intent = baseIntent;
5526 }
5527
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005528 if (data != null) {
5529 if (data.startsWith("intent:")) {
5530 data = data.substring(7);
5531 if (scheme != null) {
5532 data = scheme + ':' + data;
5533 }
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005534 } else if (data.startsWith("android-app:")) {
5535 if (data.charAt(12) == '/' && data.charAt(13) == '/') {
5536 // Correctly formed android-app, first part is package name.
5537 int end = data.indexOf('/', 14);
5538 if (end < 0) {
5539 // All we have is a package name.
5540 intent.mPackage = data.substring(14);
5541 if (!explicitAction) {
5542 intent.setAction(ACTION_MAIN);
5543 }
5544 data = "";
5545 } else {
5546 // Target the Intent at the given package name always.
5547 String authority = null;
5548 intent.mPackage = data.substring(14, end);
5549 int newEnd;
Dianne Hackborn80b1c562014-12-09 20:22:08 -08005550 if ((end+1) < data.length()) {
5551 if ((newEnd=data.indexOf('/', end+1)) >= 0) {
5552 // Found a scheme, remember it.
5553 scheme = data.substring(end+1, newEnd);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005554 end = newEnd;
Dianne Hackborn80b1c562014-12-09 20:22:08 -08005555 if (end < data.length() && (newEnd=data.indexOf('/', end+1)) >= 0) {
5556 // Found a authority, remember it.
5557 authority = data.substring(end+1, newEnd);
5558 end = newEnd;
5559 }
5560 } else {
5561 // All we have is a scheme.
5562 scheme = data.substring(end+1);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005563 }
5564 }
5565 if (scheme == null) {
5566 // If there was no scheme, then this just targets the package.
5567 if (!explicitAction) {
5568 intent.setAction(ACTION_MAIN);
5569 }
5570 data = "";
5571 } else if (authority == null) {
5572 data = scheme + ":";
5573 } else {
5574 data = scheme + "://" + authority + data.substring(end);
5575 }
5576 }
5577 } else {
5578 data = "";
5579 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005580 }
Tom Taylord4a47292009-12-21 13:59:18 -08005581
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005582 if (data.length() > 0) {
5583 try {
5584 intent.mData = Uri.parse(data);
5585 } catch (IllegalArgumentException e) {
5586 throw new URISyntaxException(uri, e.getMessage());
5587 }
5588 }
5589 }
Tom Taylord4a47292009-12-21 13:59:18 -08005590
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005591 return intent;
The Android Open Source Project10592532009-03-18 17:39:46 -07005592
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005593 } catch (IndexOutOfBoundsException e) {
5594 throw new URISyntaxException(uri, "illegal Intent URI format", i);
5595 }
5596 }
The Android Open Source Project10592532009-03-18 17:39:46 -07005597
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005598 public static Intent getIntentOld(String uri) throws URISyntaxException {
Dianne Hackborn24b1c232014-11-20 17:17:39 -08005599 return getIntentOld(uri, 0);
5600 }
5601
5602 private static Intent getIntentOld(String uri, int flags) throws URISyntaxException {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005603 Intent intent;
5604
5605 int i = uri.lastIndexOf('#');
5606 if (i >= 0) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005607 String action = null;
Dianne Hackborn6cca1592009-09-20 12:40:03 -07005608 final int intentFragmentStart = i;
5609 boolean isIntentFragment = false;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005610
5611 i++;
5612
5613 if (uri.regionMatches(i, "action(", 0, 7)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07005614 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005615 i += 7;
5616 int j = uri.indexOf(')', i);
5617 action = uri.substring(i, j);
5618 i = j + 1;
5619 }
5620
Dianne Hackborn6cca1592009-09-20 12:40:03 -07005621 intent = new Intent(action);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005622
5623 if (uri.regionMatches(i, "categories(", 0, 11)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07005624 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005625 i += 11;
5626 int j = uri.indexOf(')', i);
5627 while (i < j) {
5628 int sep = uri.indexOf('!', i);
Alan Viverette0adf32b2014-09-18 12:53:16 -07005629 if (sep < 0 || sep > j) sep = j;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005630 if (i < sep) {
5631 intent.addCategory(uri.substring(i, sep));
5632 }
5633 i = sep + 1;
5634 }
5635 i = j + 1;
5636 }
5637
5638 if (uri.regionMatches(i, "type(", 0, 5)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07005639 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005640 i += 5;
5641 int j = uri.indexOf(')', i);
5642 intent.mType = uri.substring(i, j);
5643 i = j + 1;
5644 }
5645
5646 if (uri.regionMatches(i, "launchFlags(", 0, 12)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07005647 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005648 i += 12;
5649 int j = uri.indexOf(')', i);
5650 intent.mFlags = Integer.decode(uri.substring(i, j)).intValue();
Dianne Hackborn24b1c232014-11-20 17:17:39 -08005651 if ((flags& URI_ALLOW_UNSAFE) == 0) {
5652 intent.mFlags &= ~IMMUTABLE_FLAGS;
5653 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005654 i = j + 1;
5655 }
5656
5657 if (uri.regionMatches(i, "component(", 0, 10)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07005658 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005659 i += 10;
5660 int j = uri.indexOf(')', i);
5661 int sep = uri.indexOf('!', i);
5662 if (sep >= 0 && sep < j) {
5663 String pkg = uri.substring(i, sep);
5664 String cls = uri.substring(sep + 1, j);
5665 intent.mComponent = new ComponentName(pkg, cls);
5666 }
5667 i = j + 1;
5668 }
5669
5670 if (uri.regionMatches(i, "extras(", 0, 7)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07005671 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005672 i += 7;
The Android Open Source Project10592532009-03-18 17:39:46 -07005673
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005674 final int closeParen = uri.indexOf(')', i);
5675 if (closeParen == -1) throw new URISyntaxException(uri,
5676 "EXTRA missing trailing ')'", i);
5677
5678 while (i < closeParen) {
5679 // fetch the key value
5680 int j = uri.indexOf('=', i);
5681 if (j <= i + 1 || i >= closeParen) {
5682 throw new URISyntaxException(uri, "EXTRA missing '='", i);
5683 }
5684 char type = uri.charAt(i);
5685 i++;
5686 String key = uri.substring(i, j);
5687 i = j + 1;
The Android Open Source Project10592532009-03-18 17:39:46 -07005688
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005689 // get type-value
5690 j = uri.indexOf('!', i);
5691 if (j == -1 || j >= closeParen) j = closeParen;
5692 if (i >= j) throw new URISyntaxException(uri, "EXTRA missing '!'", i);
5693 String value = uri.substring(i, j);
5694 i = j;
5695
5696 // create Bundle if it doesn't already exist
5697 if (intent.mExtras == null) intent.mExtras = new Bundle();
The Android Open Source Project10592532009-03-18 17:39:46 -07005698
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005699 // add item to bundle
5700 try {
5701 switch (type) {
5702 case 'S':
5703 intent.mExtras.putString(key, Uri.decode(value));
5704 break;
5705 case 'B':
5706 intent.mExtras.putBoolean(key, Boolean.parseBoolean(value));
5707 break;
5708 case 'b':
5709 intent.mExtras.putByte(key, Byte.parseByte(value));
5710 break;
5711 case 'c':
5712 intent.mExtras.putChar(key, Uri.decode(value).charAt(0));
5713 break;
5714 case 'd':
5715 intent.mExtras.putDouble(key, Double.parseDouble(value));
5716 break;
5717 case 'f':
5718 intent.mExtras.putFloat(key, Float.parseFloat(value));
5719 break;
5720 case 'i':
5721 intent.mExtras.putInt(key, Integer.parseInt(value));
5722 break;
5723 case 'l':
5724 intent.mExtras.putLong(key, Long.parseLong(value));
5725 break;
5726 case 's':
5727 intent.mExtras.putShort(key, Short.parseShort(value));
5728 break;
5729 default:
5730 throw new URISyntaxException(uri, "EXTRA has unknown type", i);
5731 }
5732 } catch (NumberFormatException e) {
5733 throw new URISyntaxException(uri, "EXTRA value can't be parsed", i);
5734 }
The Android Open Source Project10592532009-03-18 17:39:46 -07005735
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005736 char ch = uri.charAt(i);
5737 if (ch == ')') break;
5738 if (ch != '!') throw new URISyntaxException(uri, "EXTRA missing '!'", i);
5739 i++;
5740 }
5741 }
5742
Dianne Hackborn6cca1592009-09-20 12:40:03 -07005743 if (isIntentFragment) {
5744 intent.mData = Uri.parse(uri.substring(0, intentFragmentStart));
5745 } else {
5746 intent.mData = Uri.parse(uri);
5747 }
Tom Taylord4a47292009-12-21 13:59:18 -08005748
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005749 if (intent.mAction == null) {
5750 // By default, if no action is specified, then use VIEW.
5751 intent.mAction = ACTION_VIEW;
5752 }
5753
5754 } else {
5755 intent = new Intent(ACTION_VIEW, Uri.parse(uri));
5756 }
5757
5758 return intent;
5759 }
5760
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08005761 /** @hide */
5762 public interface CommandOptionHandler {
5763 boolean handleOption(String opt, ShellCommand cmd);
5764 }
5765
5766 /** @hide */
5767 public static Intent parseCommandArgs(ShellCommand cmd, CommandOptionHandler optionHandler)
5768 throws URISyntaxException {
5769 Intent intent = new Intent();
5770 Intent baseIntent = intent;
5771 boolean hasIntentInfo = false;
5772
5773 Uri data = null;
5774 String type = null;
5775
5776 String opt;
5777 while ((opt=cmd.getNextOption()) != null) {
5778 switch (opt) {
5779 case "-a":
5780 intent.setAction(cmd.getNextArgRequired());
5781 if (intent == baseIntent) {
5782 hasIntentInfo = true;
5783 }
5784 break;
5785 case "-d":
5786 data = Uri.parse(cmd.getNextArgRequired());
5787 if (intent == baseIntent) {
5788 hasIntentInfo = true;
5789 }
5790 break;
5791 case "-t":
5792 type = cmd.getNextArgRequired();
5793 if (intent == baseIntent) {
5794 hasIntentInfo = true;
5795 }
5796 break;
5797 case "-c":
5798 intent.addCategory(cmd.getNextArgRequired());
5799 if (intent == baseIntent) {
5800 hasIntentInfo = true;
5801 }
5802 break;
5803 case "-e":
5804 case "--es": {
5805 String key = cmd.getNextArgRequired();
5806 String value = cmd.getNextArgRequired();
5807 intent.putExtra(key, value);
5808 }
5809 break;
5810 case "--esn": {
5811 String key = cmd.getNextArgRequired();
5812 intent.putExtra(key, (String) null);
5813 }
5814 break;
5815 case "--ei": {
5816 String key = cmd.getNextArgRequired();
5817 String value = cmd.getNextArgRequired();
5818 intent.putExtra(key, Integer.decode(value));
5819 }
5820 break;
5821 case "--eu": {
5822 String key = cmd.getNextArgRequired();
5823 String value = cmd.getNextArgRequired();
5824 intent.putExtra(key, Uri.parse(value));
5825 }
5826 break;
5827 case "--ecn": {
5828 String key = cmd.getNextArgRequired();
5829 String value = cmd.getNextArgRequired();
5830 ComponentName cn = ComponentName.unflattenFromString(value);
5831 if (cn == null)
5832 throw new IllegalArgumentException("Bad component name: " + value);
5833 intent.putExtra(key, cn);
5834 }
5835 break;
5836 case "--eia": {
5837 String key = cmd.getNextArgRequired();
5838 String value = cmd.getNextArgRequired();
5839 String[] strings = value.split(",");
5840 int[] list = new int[strings.length];
5841 for (int i = 0; i < strings.length; i++) {
5842 list[i] = Integer.decode(strings[i]);
5843 }
5844 intent.putExtra(key, list);
5845 }
5846 break;
5847 case "--eial": {
5848 String key = cmd.getNextArgRequired();
5849 String value = cmd.getNextArgRequired();
5850 String[] strings = value.split(",");
5851 ArrayList<Integer> list = new ArrayList<>(strings.length);
5852 for (int i = 0; i < strings.length; i++) {
5853 list.add(Integer.decode(strings[i]));
5854 }
5855 intent.putExtra(key, list);
5856 }
5857 break;
5858 case "--el": {
5859 String key = cmd.getNextArgRequired();
5860 String value = cmd.getNextArgRequired();
5861 intent.putExtra(key, Long.valueOf(value));
5862 }
5863 break;
5864 case "--ela": {
5865 String key = cmd.getNextArgRequired();
5866 String value = cmd.getNextArgRequired();
5867 String[] strings = value.split(",");
5868 long[] list = new long[strings.length];
5869 for (int i = 0; i < strings.length; i++) {
5870 list[i] = Long.valueOf(strings[i]);
5871 }
5872 intent.putExtra(key, list);
5873 hasIntentInfo = true;
5874 }
5875 break;
5876 case "--elal": {
5877 String key = cmd.getNextArgRequired();
5878 String value = cmd.getNextArgRequired();
5879 String[] strings = value.split(",");
5880 ArrayList<Long> list = new ArrayList<>(strings.length);
5881 for (int i = 0; i < strings.length; i++) {
5882 list.add(Long.valueOf(strings[i]));
5883 }
5884 intent.putExtra(key, list);
5885 hasIntentInfo = true;
5886 }
5887 break;
5888 case "--ef": {
5889 String key = cmd.getNextArgRequired();
5890 String value = cmd.getNextArgRequired();
5891 intent.putExtra(key, Float.valueOf(value));
5892 hasIntentInfo = true;
5893 }
5894 break;
5895 case "--efa": {
5896 String key = cmd.getNextArgRequired();
5897 String value = cmd.getNextArgRequired();
5898 String[] strings = value.split(",");
5899 float[] list = new float[strings.length];
5900 for (int i = 0; i < strings.length; i++) {
5901 list[i] = Float.valueOf(strings[i]);
5902 }
5903 intent.putExtra(key, list);
5904 hasIntentInfo = true;
5905 }
5906 break;
5907 case "--efal": {
5908 String key = cmd.getNextArgRequired();
5909 String value = cmd.getNextArgRequired();
5910 String[] strings = value.split(",");
5911 ArrayList<Float> list = new ArrayList<>(strings.length);
5912 for (int i = 0; i < strings.length; i++) {
5913 list.add(Float.valueOf(strings[i]));
5914 }
5915 intent.putExtra(key, list);
5916 hasIntentInfo = true;
5917 }
5918 break;
5919 case "--esa": {
5920 String key = cmd.getNextArgRequired();
5921 String value = cmd.getNextArgRequired();
5922 // Split on commas unless they are preceeded by an escape.
5923 // The escape character must be escaped for the string and
5924 // again for the regex, thus four escape characters become one.
5925 String[] strings = value.split("(?<!\\\\),");
5926 intent.putExtra(key, strings);
5927 hasIntentInfo = true;
5928 }
5929 break;
5930 case "--esal": {
5931 String key = cmd.getNextArgRequired();
5932 String value = cmd.getNextArgRequired();
5933 // Split on commas unless they are preceeded by an escape.
5934 // The escape character must be escaped for the string and
5935 // again for the regex, thus four escape characters become one.
5936 String[] strings = value.split("(?<!\\\\),");
5937 ArrayList<String> list = new ArrayList<>(strings.length);
5938 for (int i = 0; i < strings.length; i++) {
5939 list.add(strings[i]);
5940 }
5941 intent.putExtra(key, list);
5942 hasIntentInfo = true;
5943 }
5944 break;
5945 case "--ez": {
5946 String key = cmd.getNextArgRequired();
5947 String value = cmd.getNextArgRequired().toLowerCase();
5948 // Boolean.valueOf() results in false for anything that is not "true", which is
5949 // error-prone in shell commands
5950 boolean arg;
5951 if ("true".equals(value) || "t".equals(value)) {
5952 arg = true;
5953 } else if ("false".equals(value) || "f".equals(value)) {
5954 arg = false;
5955 } else {
5956 try {
5957 arg = Integer.decode(value) != 0;
5958 } catch (NumberFormatException ex) {
5959 throw new IllegalArgumentException("Invalid boolean value: " + value);
5960 }
5961 }
5962
5963 intent.putExtra(key, arg);
5964 }
5965 break;
5966 case "-n": {
5967 String str = cmd.getNextArgRequired();
5968 ComponentName cn = ComponentName.unflattenFromString(str);
5969 if (cn == null)
5970 throw new IllegalArgumentException("Bad component name: " + str);
5971 intent.setComponent(cn);
5972 if (intent == baseIntent) {
5973 hasIntentInfo = true;
5974 }
5975 }
5976 break;
5977 case "-p": {
5978 String str = cmd.getNextArgRequired();
5979 intent.setPackage(str);
5980 if (intent == baseIntent) {
5981 hasIntentInfo = true;
5982 }
5983 }
5984 break;
5985 case "-f":
5986 String str = cmd.getNextArgRequired();
5987 intent.setFlags(Integer.decode(str).intValue());
5988 break;
5989 case "--grant-read-uri-permission":
5990 intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
5991 break;
5992 case "--grant-write-uri-permission":
5993 intent.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
5994 break;
5995 case "--grant-persistable-uri-permission":
5996 intent.addFlags(Intent.FLAG_GRANT_PERSISTABLE_URI_PERMISSION);
5997 break;
5998 case "--grant-prefix-uri-permission":
5999 intent.addFlags(Intent.FLAG_GRANT_PREFIX_URI_PERMISSION);
6000 break;
6001 case "--exclude-stopped-packages":
6002 intent.addFlags(Intent.FLAG_EXCLUDE_STOPPED_PACKAGES);
6003 break;
6004 case "--include-stopped-packages":
6005 intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
6006 break;
6007 case "--debug-log-resolution":
6008 intent.addFlags(Intent.FLAG_DEBUG_LOG_RESOLUTION);
6009 break;
6010 case "--activity-brought-to-front":
6011 intent.addFlags(Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT);
6012 break;
6013 case "--activity-clear-top":
6014 intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
6015 break;
6016 case "--activity-clear-when-task-reset":
6017 intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
6018 break;
6019 case "--activity-exclude-from-recents":
6020 intent.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
6021 break;
6022 case "--activity-launched-from-history":
6023 intent.addFlags(Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY);
6024 break;
6025 case "--activity-multiple-task":
6026 intent.addFlags(Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
6027 break;
6028 case "--activity-no-animation":
6029 intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
6030 break;
6031 case "--activity-no-history":
6032 intent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
6033 break;
6034 case "--activity-no-user-action":
6035 intent.addFlags(Intent.FLAG_ACTIVITY_NO_USER_ACTION);
6036 break;
6037 case "--activity-previous-is-top":
6038 intent.addFlags(Intent.FLAG_ACTIVITY_PREVIOUS_IS_TOP);
6039 break;
6040 case "--activity-reorder-to-front":
6041 intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
6042 break;
6043 case "--activity-reset-task-if-needed":
6044 intent.addFlags(Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
6045 break;
6046 case "--activity-single-top":
6047 intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
6048 break;
6049 case "--activity-clear-task":
6050 intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
6051 break;
6052 case "--activity-task-on-home":
6053 intent.addFlags(Intent.FLAG_ACTIVITY_TASK_ON_HOME);
6054 break;
6055 case "--receiver-registered-only":
6056 intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY);
6057 break;
6058 case "--receiver-replace-pending":
6059 intent.addFlags(Intent.FLAG_RECEIVER_REPLACE_PENDING);
6060 break;
Felipe Leme3cb48cd2016-01-27 08:39:09 -08006061 case "--receiver-foreground":
6062 intent.addFlags(Intent.FLAG_RECEIVER_FOREGROUND);
6063 break;
Dianne Hackborn797772b12017-02-08 16:33:43 -08006064 case "--receiver-no-abort":
6065 intent.addFlags(Intent.FLAG_RECEIVER_NO_ABORT);
6066 break;
6067 case "--receiver-include-background":
6068 intent.addFlags(Intent.FLAG_RECEIVER_INCLUDE_BACKGROUND);
6069 break;
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08006070 case "--selector":
6071 intent.setDataAndType(data, type);
6072 intent = new Intent();
6073 break;
6074 default:
6075 if (optionHandler != null && optionHandler.handleOption(opt, cmd)) {
6076 // Okay, caller handled this option.
6077 } else {
6078 throw new IllegalArgumentException("Unknown option: " + opt);
6079 }
6080 break;
6081 }
6082 }
6083 intent.setDataAndType(data, type);
6084
6085 final boolean hasSelector = intent != baseIntent;
6086 if (hasSelector) {
6087 // A selector was specified; fix up.
6088 baseIntent.setSelector(intent);
6089 intent = baseIntent;
6090 }
6091
6092 String arg = cmd.getNextArg();
6093 baseIntent = null;
6094 if (arg == null) {
6095 if (hasSelector) {
6096 // If a selector has been specified, and no arguments
6097 // have been supplied for the main Intent, then we can
6098 // assume it is ACTION_MAIN CATEGORY_LAUNCHER; we don't
6099 // need to have a component name specified yet, the
6100 // selector will take care of that.
6101 baseIntent = new Intent(Intent.ACTION_MAIN);
6102 baseIntent.addCategory(Intent.CATEGORY_LAUNCHER);
6103 }
6104 } else if (arg.indexOf(':') >= 0) {
6105 // The argument is a URI. Fully parse it, and use that result
6106 // to fill in any data not specified so far.
6107 baseIntent = Intent.parseUri(arg, Intent.URI_INTENT_SCHEME
6108 | Intent.URI_ANDROID_APP_SCHEME | Intent.URI_ALLOW_UNSAFE);
6109 } else if (arg.indexOf('/') >= 0) {
6110 // The argument is a component name. Build an Intent to launch
6111 // it.
6112 baseIntent = new Intent(Intent.ACTION_MAIN);
6113 baseIntent.addCategory(Intent.CATEGORY_LAUNCHER);
6114 baseIntent.setComponent(ComponentName.unflattenFromString(arg));
6115 } else {
6116 // Assume the argument is a package name.
6117 baseIntent = new Intent(Intent.ACTION_MAIN);
6118 baseIntent.addCategory(Intent.CATEGORY_LAUNCHER);
6119 baseIntent.setPackage(arg);
6120 }
6121 if (baseIntent != null) {
6122 Bundle extras = intent.getExtras();
6123 intent.replaceExtras((Bundle)null);
6124 Bundle uriExtras = baseIntent.getExtras();
6125 baseIntent.replaceExtras((Bundle)null);
6126 if (intent.getAction() != null && baseIntent.getCategories() != null) {
6127 HashSet<String> cats = new HashSet<String>(baseIntent.getCategories());
6128 for (String c : cats) {
6129 baseIntent.removeCategory(c);
6130 }
6131 }
6132 intent.fillIn(baseIntent, Intent.FILL_IN_COMPONENT | Intent.FILL_IN_SELECTOR);
6133 if (extras == null) {
6134 extras = uriExtras;
6135 } else if (uriExtras != null) {
6136 uriExtras.putAll(extras);
6137 extras = uriExtras;
6138 }
6139 intent.replaceExtras(extras);
6140 hasIntentInfo = true;
6141 }
6142
6143 if (!hasIntentInfo) throw new IllegalArgumentException("No intent supplied");
6144 return intent;
6145 }
6146
6147 /** @hide */
6148 public static void printIntentArgsHelp(PrintWriter pw, String prefix) {
6149 final String[] lines = new String[] {
6150 "<INTENT> specifications include these flags and arguments:",
6151 " [-a <ACTION>] [-d <DATA_URI>] [-t <MIME_TYPE>]",
6152 " [-c <CATEGORY> [-c <CATEGORY>] ...]",
6153 " [-e|--es <EXTRA_KEY> <EXTRA_STRING_VALUE> ...]",
6154 " [--esn <EXTRA_KEY> ...]",
6155 " [--ez <EXTRA_KEY> <EXTRA_BOOLEAN_VALUE> ...]",
6156 " [--ei <EXTRA_KEY> <EXTRA_INT_VALUE> ...]",
6157 " [--el <EXTRA_KEY> <EXTRA_LONG_VALUE> ...]",
6158 " [--ef <EXTRA_KEY> <EXTRA_FLOAT_VALUE> ...]",
6159 " [--eu <EXTRA_KEY> <EXTRA_URI_VALUE> ...]",
6160 " [--ecn <EXTRA_KEY> <EXTRA_COMPONENT_NAME_VALUE>]",
6161 " [--eia <EXTRA_KEY> <EXTRA_INT_VALUE>[,<EXTRA_INT_VALUE...]]",
6162 " (mutiple extras passed as Integer[])",
6163 " [--eial <EXTRA_KEY> <EXTRA_INT_VALUE>[,<EXTRA_INT_VALUE...]]",
6164 " (mutiple extras passed as List<Integer>)",
6165 " [--ela <EXTRA_KEY> <EXTRA_LONG_VALUE>[,<EXTRA_LONG_VALUE...]]",
6166 " (mutiple extras passed as Long[])",
6167 " [--elal <EXTRA_KEY> <EXTRA_LONG_VALUE>[,<EXTRA_LONG_VALUE...]]",
6168 " (mutiple extras passed as List<Long>)",
6169 " [--efa <EXTRA_KEY> <EXTRA_FLOAT_VALUE>[,<EXTRA_FLOAT_VALUE...]]",
6170 " (mutiple extras passed as Float[])",
6171 " [--efal <EXTRA_KEY> <EXTRA_FLOAT_VALUE>[,<EXTRA_FLOAT_VALUE...]]",
6172 " (mutiple extras passed as List<Float>)",
6173 " [--esa <EXTRA_KEY> <EXTRA_STRING_VALUE>[,<EXTRA_STRING_VALUE...]]",
6174 " (mutiple extras passed as String[]; to embed a comma into a string,",
6175 " escape it using \"\\,\")",
6176 " [--esal <EXTRA_KEY> <EXTRA_STRING_VALUE>[,<EXTRA_STRING_VALUE...]]",
6177 " (mutiple extras passed as List<String>; to embed a comma into a string,",
6178 " escape it using \"\\,\")",
Felipe Leme545569d2016-01-11 16:27:58 -08006179 " [-f <FLAG>]",
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08006180 " [--grant-read-uri-permission] [--grant-write-uri-permission]",
6181 " [--grant-persistable-uri-permission] [--grant-prefix-uri-permission]",
6182 " [--debug-log-resolution] [--exclude-stopped-packages]",
6183 " [--include-stopped-packages]",
6184 " [--activity-brought-to-front] [--activity-clear-top]",
6185 " [--activity-clear-when-task-reset] [--activity-exclude-from-recents]",
6186 " [--activity-launched-from-history] [--activity-multiple-task]",
6187 " [--activity-no-animation] [--activity-no-history]",
6188 " [--activity-no-user-action] [--activity-previous-is-top]",
6189 " [--activity-reorder-to-front] [--activity-reset-task-if-needed]",
6190 " [--activity-single-top] [--activity-clear-task]",
6191 " [--activity-task-on-home]",
6192 " [--receiver-registered-only] [--receiver-replace-pending]",
Dianne Hackborn797772b12017-02-08 16:33:43 -08006193 " [--receiver-foreground] [--receiver-no-abort]",
6194 " [--receiver-include-background]",
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08006195 " [--selector]",
6196 " [<URI> | <PACKAGE> | <COMPONENT>]"
6197 };
6198 for (String line : lines) {
6199 pw.print(prefix);
6200 pw.println(line);
6201 }
6202 }
6203
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006204 /**
6205 * Retrieve the general action to be performed, such as
6206 * {@link #ACTION_VIEW}. The action describes the general way the rest of
6207 * the information in the intent should be interpreted -- most importantly,
6208 * what to do with the data returned by {@link #getData}.
6209 *
6210 * @return The action of this intent or null if none is specified.
6211 *
6212 * @see #setAction
6213 */
6214 public String getAction() {
6215 return mAction;
6216 }
6217
6218 /**
6219 * Retrieve data this intent is operating on. This URI specifies the name
6220 * of the data; often it uses the content: scheme, specifying data in a
6221 * content provider. Other schemes may be handled by specific activities,
6222 * such as http: by the web browser.
6223 *
6224 * @return The URI of the data this intent is targeting or null.
6225 *
6226 * @see #getScheme
6227 * @see #setData
6228 */
6229 public Uri getData() {
6230 return mData;
6231 }
6232
6233 /**
6234 * The same as {@link #getData()}, but returns the URI as an encoded
6235 * String.
6236 */
6237 public String getDataString() {
6238 return mData != null ? mData.toString() : null;
6239 }
6240
6241 /**
6242 * Return the scheme portion of the intent's data. If the data is null or
6243 * does not include a scheme, null is returned. Otherwise, the scheme
6244 * prefix without the final ':' is returned, i.e. "http".
6245 *
6246 * <p>This is the same as calling getData().getScheme() (and checking for
6247 * null data).
6248 *
6249 * @return The scheme of this intent.
6250 *
6251 * @see #getData
6252 */
6253 public String getScheme() {
6254 return mData != null ? mData.getScheme() : null;
6255 }
6256
6257 /**
6258 * Retrieve any explicit MIME type included in the intent. This is usually
6259 * null, as the type is determined by the intent data.
6260 *
6261 * @return If a type was manually set, it is returned; else null is
6262 * returned.
6263 *
6264 * @see #resolveType(ContentResolver)
6265 * @see #setType
6266 */
6267 public String getType() {
6268 return mType;
6269 }
6270
6271 /**
6272 * Return the MIME data type of this intent. If the type field is
6273 * explicitly set, that is simply returned. Otherwise, if the data is set,
6274 * the type of that data is returned. If neither fields are set, a null is
6275 * returned.
6276 *
6277 * @return The MIME type of this intent.
6278 *
6279 * @see #getType
6280 * @see #resolveType(ContentResolver)
6281 */
6282 public String resolveType(Context context) {
6283 return resolveType(context.getContentResolver());
6284 }
6285
6286 /**
6287 * Return the MIME data type of this intent. If the type field is
6288 * explicitly set, that is simply returned. Otherwise, if the data is set,
6289 * the type of that data is returned. If neither fields are set, a null is
6290 * returned.
6291 *
6292 * @param resolver A ContentResolver that can be used to determine the MIME
6293 * type of the intent's data.
6294 *
6295 * @return The MIME type of this intent.
6296 *
6297 * @see #getType
6298 * @see #resolveType(Context)
6299 */
6300 public String resolveType(ContentResolver resolver) {
6301 if (mType != null) {
6302 return mType;
6303 }
6304 if (mData != null) {
6305 if ("content".equals(mData.getScheme())) {
6306 return resolver.getType(mData);
6307 }
6308 }
6309 return null;
6310 }
6311
6312 /**
6313 * Return the MIME data type of this intent, only if it will be needed for
6314 * intent resolution. This is not generally useful for application code;
6315 * it is used by the frameworks for communicating with back-end system
6316 * services.
6317 *
6318 * @param resolver A ContentResolver that can be used to determine the MIME
6319 * type of the intent's data.
6320 *
6321 * @return The MIME type of this intent, or null if it is unknown or not
6322 * needed.
6323 */
6324 public String resolveTypeIfNeeded(ContentResolver resolver) {
6325 if (mComponent != null) {
6326 return mType;
6327 }
6328 return resolveType(resolver);
6329 }
6330
6331 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09006332 * Check if a category exists in the intent.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006333 *
6334 * @param category The category to check.
6335 *
6336 * @return boolean True if the intent contains the category, else false.
6337 *
6338 * @see #getCategories
6339 * @see #addCategory
6340 */
6341 public boolean hasCategory(String category) {
6342 return mCategories != null && mCategories.contains(category);
6343 }
6344
6345 /**
6346 * Return the set of all categories in the intent. If there are no categories,
6347 * returns NULL.
6348 *
Dianne Hackbornf5b86712011-12-05 17:42:41 -08006349 * @return The set of categories you can examine. Do not modify!
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006350 *
6351 * @see #hasCategory
6352 * @see #addCategory
6353 */
6354 public Set<String> getCategories() {
6355 return mCategories;
6356 }
6357
6358 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08006359 * Return the specific selector associated with this Intent. If there is
6360 * none, returns null. See {@link #setSelector} for more information.
6361 *
6362 * @see #setSelector
6363 */
6364 public Intent getSelector() {
6365 return mSelector;
6366 }
6367
6368 /**
Dianne Hackborn21c241e2012-03-08 13:57:23 -08006369 * Return the {@link ClipData} associated with this Intent. If there is
6370 * none, returns null. See {@link #setClipData} for more information.
6371 *
John Spurlock125d1332013-11-25 11:58:37 -05006372 * @see #setClipData
Dianne Hackborn21c241e2012-03-08 13:57:23 -08006373 */
6374 public ClipData getClipData() {
6375 return mClipData;
6376 }
6377
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01006378 /** @hide */
6379 public int getContentUserHint() {
6380 return mContentUserHint;
6381 }
6382
Dianne Hackborn21c241e2012-03-08 13:57:23 -08006383 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006384 * Sets the ClassLoader that will be used when unmarshalling
6385 * any Parcelable values from the extras of this Intent.
6386 *
6387 * @param loader a ClassLoader, or null to use the default loader
6388 * at the time of unmarshalling.
6389 */
6390 public void setExtrasClassLoader(ClassLoader loader) {
6391 if (mExtras != null) {
6392 mExtras.setClassLoader(loader);
6393 }
6394 }
6395
6396 /**
6397 * Returns true if an extra value is associated with the given name.
6398 * @param name the extra's name
6399 * @return true if the given extra is present.
6400 */
6401 public boolean hasExtra(String name) {
6402 return mExtras != null && mExtras.containsKey(name);
6403 }
6404
6405 /**
6406 * Returns true if the Intent's extras contain a parcelled file descriptor.
6407 * @return true if the Intent contains a parcelled file descriptor.
6408 */
6409 public boolean hasFileDescriptors() {
6410 return mExtras != null && mExtras.hasFileDescriptors();
6411 }
The Android Open Source Project10592532009-03-18 17:39:46 -07006412
Jeff Sharkeyd136e512016-03-09 22:30:56 -07006413 /** {@hide} */
Dianne Hackborn9ecebbf2011-09-28 23:19:47 -04006414 public void setAllowFds(boolean allowFds) {
6415 if (mExtras != null) {
6416 mExtras.setAllowFds(allowFds);
6417 }
6418 }
6419
Jeff Sharkeyd136e512016-03-09 22:30:56 -07006420 /** {@hide} */
6421 public void setDefusable(boolean defusable) {
6422 if (mExtras != null) {
6423 mExtras.setDefusable(defusable);
6424 }
6425 }
6426
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006427 /**
6428 * Retrieve extended data from the intent.
6429 *
6430 * @param name The name of the desired item.
6431 *
6432 * @return the value of an item that previously added with putExtra()
6433 * or null if none was found.
6434 *
6435 * @deprecated
6436 * @hide
6437 */
6438 @Deprecated
6439 public Object getExtra(String name) {
6440 return getExtra(name, null);
6441 }
6442
6443 /**
6444 * Retrieve extended data from the intent.
6445 *
6446 * @param name The name of the desired item.
6447 * @param defaultValue the value to be returned if no value of the desired
6448 * type is stored with the given name.
6449 *
6450 * @return the value of an item that previously added with putExtra()
6451 * or the default value if none was found.
6452 *
6453 * @see #putExtra(String, boolean)
6454 */
6455 public boolean getBooleanExtra(String name, boolean defaultValue) {
6456 return mExtras == null ? defaultValue :
6457 mExtras.getBoolean(name, defaultValue);
6458 }
6459
6460 /**
6461 * Retrieve extended data from the intent.
6462 *
6463 * @param name The name of the desired item.
6464 * @param defaultValue the value to be returned if no value of the desired
6465 * type is stored with the given name.
6466 *
6467 * @return the value of an item that previously added with putExtra()
6468 * or the default value if none was found.
6469 *
6470 * @see #putExtra(String, byte)
6471 */
6472 public byte getByteExtra(String name, byte defaultValue) {
6473 return mExtras == null ? defaultValue :
6474 mExtras.getByte(name, defaultValue);
6475 }
6476
6477 /**
6478 * Retrieve extended data from the intent.
6479 *
6480 * @param name The name of the desired item.
6481 * @param defaultValue the value to be returned if no value of the desired
6482 * type is stored with the given name.
6483 *
6484 * @return the value of an item that previously added with putExtra()
6485 * or the default value if none was found.
6486 *
6487 * @see #putExtra(String, short)
6488 */
6489 public short getShortExtra(String name, short defaultValue) {
6490 return mExtras == null ? defaultValue :
6491 mExtras.getShort(name, defaultValue);
6492 }
6493
6494 /**
6495 * Retrieve extended data from the intent.
6496 *
6497 * @param name The name of the desired item.
6498 * @param defaultValue the value to be returned if no value of the desired
6499 * type is stored with the given name.
6500 *
6501 * @return the value of an item that previously added with putExtra()
6502 * or the default value if none was found.
6503 *
6504 * @see #putExtra(String, char)
6505 */
6506 public char getCharExtra(String name, char defaultValue) {
6507 return mExtras == null ? defaultValue :
6508 mExtras.getChar(name, defaultValue);
6509 }
6510
6511 /**
6512 * Retrieve extended data from the intent.
6513 *
6514 * @param name The name of the desired item.
6515 * @param defaultValue the value to be returned if no value of the desired
6516 * type is stored with the given name.
6517 *
6518 * @return the value of an item that previously added with putExtra()
6519 * or the default value if none was found.
6520 *
6521 * @see #putExtra(String, int)
6522 */
6523 public int getIntExtra(String name, int defaultValue) {
6524 return mExtras == null ? defaultValue :
6525 mExtras.getInt(name, defaultValue);
6526 }
6527
6528 /**
6529 * Retrieve extended data from the intent.
6530 *
6531 * @param name The name of the desired item.
6532 * @param defaultValue the value to be returned if no value of the desired
6533 * type is stored with the given name.
6534 *
6535 * @return the value of an item that previously added with putExtra()
6536 * or the default value if none was found.
6537 *
6538 * @see #putExtra(String, long)
6539 */
6540 public long getLongExtra(String name, long defaultValue) {
6541 return mExtras == null ? defaultValue :
6542 mExtras.getLong(name, defaultValue);
6543 }
6544
6545 /**
6546 * Retrieve extended data from the intent.
6547 *
6548 * @param name The name of the desired item.
6549 * @param defaultValue the value to be returned if no value of the desired
6550 * type is stored with the given name.
6551 *
6552 * @return the value of an item that previously added with putExtra(),
6553 * or the default value if no such item is present
6554 *
6555 * @see #putExtra(String, float)
6556 */
6557 public float getFloatExtra(String name, float defaultValue) {
6558 return mExtras == null ? defaultValue :
6559 mExtras.getFloat(name, defaultValue);
6560 }
6561
6562 /**
6563 * Retrieve extended data from the intent.
6564 *
6565 * @param name The name of the desired item.
6566 * @param defaultValue the value to be returned if no value of the desired
6567 * type is stored with the given name.
6568 *
6569 * @return the value of an item that previously added with putExtra()
6570 * or the default value if none was found.
6571 *
6572 * @see #putExtra(String, double)
6573 */
6574 public double getDoubleExtra(String name, double defaultValue) {
6575 return mExtras == null ? defaultValue :
6576 mExtras.getDouble(name, defaultValue);
6577 }
6578
6579 /**
6580 * Retrieve extended data from the intent.
6581 *
6582 * @param name The name of the desired item.
6583 *
6584 * @return the value of an item that previously added with putExtra()
6585 * or null if no String value was found.
6586 *
6587 * @see #putExtra(String, String)
6588 */
6589 public String getStringExtra(String name) {
6590 return mExtras == null ? null : mExtras.getString(name);
6591 }
6592
6593 /**
6594 * Retrieve extended data from the intent.
6595 *
6596 * @param name The name of the desired item.
6597 *
6598 * @return the value of an item that previously added with putExtra()
6599 * or null if no CharSequence value was found.
6600 *
6601 * @see #putExtra(String, CharSequence)
6602 */
6603 public CharSequence getCharSequenceExtra(String name) {
6604 return mExtras == null ? null : mExtras.getCharSequence(name);
6605 }
6606
6607 /**
6608 * Retrieve extended data from the intent.
6609 *
6610 * @param name The name of the desired item.
6611 *
6612 * @return the value of an item that previously added with putExtra()
6613 * or null if no Parcelable value was found.
6614 *
6615 * @see #putExtra(String, Parcelable)
6616 */
6617 public <T extends Parcelable> T getParcelableExtra(String name) {
6618 return mExtras == null ? null : mExtras.<T>getParcelable(name);
6619 }
6620
6621 /**
6622 * Retrieve extended data from the intent.
6623 *
6624 * @param name The name of the desired item.
6625 *
6626 * @return the value of an item that previously added with putExtra()
6627 * or null if no Parcelable[] value was found.
6628 *
6629 * @see #putExtra(String, Parcelable[])
6630 */
6631 public Parcelable[] getParcelableArrayExtra(String name) {
6632 return mExtras == null ? null : mExtras.getParcelableArray(name);
6633 }
6634
6635 /**
6636 * Retrieve extended data from the intent.
6637 *
6638 * @param name The name of the desired item.
6639 *
6640 * @return the value of an item that previously added with putExtra()
6641 * or null if no ArrayList<Parcelable> value was found.
6642 *
6643 * @see #putParcelableArrayListExtra(String, ArrayList)
6644 */
6645 public <T extends Parcelable> ArrayList<T> getParcelableArrayListExtra(String name) {
6646 return mExtras == null ? null : mExtras.<T>getParcelableArrayList(name);
6647 }
6648
6649 /**
6650 * Retrieve extended data from the intent.
6651 *
6652 * @param name The name of the desired item.
6653 *
6654 * @return the value of an item that previously added with putExtra()
6655 * or null if no Serializable value was found.
6656 *
6657 * @see #putExtra(String, Serializable)
6658 */
6659 public Serializable getSerializableExtra(String name) {
6660 return mExtras == null ? null : mExtras.getSerializable(name);
6661 }
6662
6663 /**
6664 * Retrieve extended data from the intent.
6665 *
6666 * @param name The name of the desired item.
6667 *
6668 * @return the value of an item that previously added with putExtra()
6669 * or null if no ArrayList<Integer> value was found.
6670 *
6671 * @see #putIntegerArrayListExtra(String, ArrayList)
6672 */
6673 public ArrayList<Integer> getIntegerArrayListExtra(String name) {
6674 return mExtras == null ? null : mExtras.getIntegerArrayList(name);
6675 }
6676
6677 /**
6678 * Retrieve extended data from the intent.
6679 *
6680 * @param name The name of the desired item.
6681 *
6682 * @return the value of an item that previously added with putExtra()
6683 * or null if no ArrayList<String> value was found.
6684 *
6685 * @see #putStringArrayListExtra(String, ArrayList)
6686 */
6687 public ArrayList<String> getStringArrayListExtra(String name) {
6688 return mExtras == null ? null : mExtras.getStringArrayList(name);
6689 }
6690
6691 /**
6692 * Retrieve extended data from the intent.
6693 *
6694 * @param name The name of the desired item.
6695 *
6696 * @return the value of an item that previously added with putExtra()
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00006697 * or null if no ArrayList<CharSequence> value was found.
6698 *
6699 * @see #putCharSequenceArrayListExtra(String, ArrayList)
6700 */
6701 public ArrayList<CharSequence> getCharSequenceArrayListExtra(String name) {
6702 return mExtras == null ? null : mExtras.getCharSequenceArrayList(name);
6703 }
6704
6705 /**
6706 * Retrieve extended data from the intent.
6707 *
6708 * @param name The name of the desired item.
6709 *
6710 * @return the value of an item that previously added with putExtra()
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006711 * or null if no boolean array value was found.
6712 *
6713 * @see #putExtra(String, boolean[])
6714 */
6715 public boolean[] getBooleanArrayExtra(String name) {
6716 return mExtras == null ? null : mExtras.getBooleanArray(name);
6717 }
6718
6719 /**
6720 * Retrieve extended data from the intent.
6721 *
6722 * @param name The name of the desired item.
6723 *
6724 * @return the value of an item that previously added with putExtra()
6725 * or null if no byte array value was found.
6726 *
6727 * @see #putExtra(String, byte[])
6728 */
6729 public byte[] getByteArrayExtra(String name) {
6730 return mExtras == null ? null : mExtras.getByteArray(name);
6731 }
6732
6733 /**
6734 * Retrieve extended data from the intent.
6735 *
6736 * @param name The name of the desired item.
6737 *
6738 * @return the value of an item that previously added with putExtra()
6739 * or null if no short array value was found.
6740 *
6741 * @see #putExtra(String, short[])
6742 */
6743 public short[] getShortArrayExtra(String name) {
6744 return mExtras == null ? null : mExtras.getShortArray(name);
6745 }
6746
6747 /**
6748 * Retrieve extended data from the intent.
6749 *
6750 * @param name The name of the desired item.
6751 *
6752 * @return the value of an item that previously added with putExtra()
6753 * or null if no char array value was found.
6754 *
6755 * @see #putExtra(String, char[])
6756 */
6757 public char[] getCharArrayExtra(String name) {
6758 return mExtras == null ? null : mExtras.getCharArray(name);
6759 }
6760
6761 /**
6762 * Retrieve extended data from the intent.
6763 *
6764 * @param name The name of the desired item.
6765 *
6766 * @return the value of an item that previously added with putExtra()
6767 * or null if no int array value was found.
6768 *
6769 * @see #putExtra(String, int[])
6770 */
6771 public int[] getIntArrayExtra(String name) {
6772 return mExtras == null ? null : mExtras.getIntArray(name);
6773 }
6774
6775 /**
6776 * Retrieve extended data from the intent.
6777 *
6778 * @param name The name of the desired item.
6779 *
6780 * @return the value of an item that previously added with putExtra()
6781 * or null if no long array value was found.
6782 *
6783 * @see #putExtra(String, long[])
6784 */
6785 public long[] getLongArrayExtra(String name) {
6786 return mExtras == null ? null : mExtras.getLongArray(name);
6787 }
6788
6789 /**
6790 * Retrieve extended data from the intent.
6791 *
6792 * @param name The name of the desired item.
6793 *
6794 * @return the value of an item that previously added with putExtra()
6795 * or null if no float array value was found.
6796 *
6797 * @see #putExtra(String, float[])
6798 */
6799 public float[] getFloatArrayExtra(String name) {
6800 return mExtras == null ? null : mExtras.getFloatArray(name);
6801 }
6802
6803 /**
6804 * Retrieve extended data from the intent.
6805 *
6806 * @param name The name of the desired item.
6807 *
6808 * @return the value of an item that previously added with putExtra()
6809 * or null if no double array value was found.
6810 *
6811 * @see #putExtra(String, double[])
6812 */
6813 public double[] getDoubleArrayExtra(String name) {
6814 return mExtras == null ? null : mExtras.getDoubleArray(name);
6815 }
6816
6817 /**
6818 * Retrieve extended data from the intent.
6819 *
6820 * @param name The name of the desired item.
6821 *
6822 * @return the value of an item that previously added with putExtra()
6823 * or null if no String array value was found.
6824 *
6825 * @see #putExtra(String, String[])
6826 */
6827 public String[] getStringArrayExtra(String name) {
6828 return mExtras == null ? null : mExtras.getStringArray(name);
6829 }
6830
6831 /**
6832 * Retrieve extended data from the intent.
6833 *
6834 * @param name The name of the desired item.
6835 *
6836 * @return the value of an item that previously added with putExtra()
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00006837 * or null if no CharSequence array value was found.
6838 *
6839 * @see #putExtra(String, CharSequence[])
6840 */
6841 public CharSequence[] getCharSequenceArrayExtra(String name) {
6842 return mExtras == null ? null : mExtras.getCharSequenceArray(name);
6843 }
6844
6845 /**
6846 * Retrieve extended data from the intent.
6847 *
6848 * @param name The name of the desired item.
6849 *
6850 * @return the value of an item that previously added with putExtra()
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006851 * or null if no Bundle value was found.
6852 *
6853 * @see #putExtra(String, Bundle)
6854 */
6855 public Bundle getBundleExtra(String name) {
6856 return mExtras == null ? null : mExtras.getBundle(name);
6857 }
6858
6859 /**
6860 * Retrieve extended data from the intent.
6861 *
6862 * @param name The name of the desired item.
6863 *
6864 * @return the value of an item that previously added with putExtra()
6865 * or null if no IBinder value was found.
6866 *
6867 * @see #putExtra(String, IBinder)
6868 *
6869 * @deprecated
6870 * @hide
6871 */
6872 @Deprecated
6873 public IBinder getIBinderExtra(String name) {
6874 return mExtras == null ? null : mExtras.getIBinder(name);
6875 }
6876
6877 /**
6878 * Retrieve extended data from the intent.
6879 *
6880 * @param name The name of the desired item.
6881 * @param defaultValue The default value to return in case no item is
6882 * associated with the key 'name'
6883 *
6884 * @return the value of an item that previously added with putExtra()
6885 * or defaultValue if none was found.
6886 *
6887 * @see #putExtra
6888 *
6889 * @deprecated
6890 * @hide
6891 */
6892 @Deprecated
6893 public Object getExtra(String name, Object defaultValue) {
6894 Object result = defaultValue;
6895 if (mExtras != null) {
6896 Object result2 = mExtras.get(name);
6897 if (result2 != null) {
6898 result = result2;
6899 }
6900 }
6901
6902 return result;
6903 }
6904
6905 /**
6906 * Retrieves a map of extended data from the intent.
6907 *
6908 * @return the map of all extras previously added with putExtra(),
6909 * or null if none have been added.
6910 */
6911 public Bundle getExtras() {
6912 return (mExtras != null)
6913 ? new Bundle(mExtras)
6914 : null;
6915 }
6916
6917 /**
Dianne Hackborna83ce1d2015-03-11 15:16:13 -07006918 * Filter extras to only basic types.
6919 * @hide
6920 */
6921 public void removeUnsafeExtras() {
6922 if (mExtras != null) {
Dianne Hackborn851ec492016-10-12 17:20:07 -07006923 mExtras = mExtras.filterValues();
Dianne Hackborna83ce1d2015-03-11 15:16:13 -07006924 }
6925 }
6926
6927 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006928 * Retrieve any special flags associated with this intent. You will
6929 * normally just set them with {@link #setFlags} and let the system
6930 * take the appropriate action with them.
6931 *
6932 * @return int The currently set flags.
6933 *
6934 * @see #setFlags
6935 */
6936 public int getFlags() {
6937 return mFlags;
6938 }
6939
Dianne Hackborne7f97212011-02-24 14:40:20 -08006940 /** @hide */
6941 public boolean isExcludingStopped() {
6942 return (mFlags&(FLAG_EXCLUDE_STOPPED_PACKAGES|FLAG_INCLUDE_STOPPED_PACKAGES))
6943 == FLAG_EXCLUDE_STOPPED_PACKAGES;
6944 }
6945
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006946 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006947 * Retrieve the application package name this Intent is limited to. When
6948 * resolving an Intent, if non-null this limits the resolution to only
6949 * components in the given application package.
6950 *
6951 * @return The name of the application package for the Intent.
6952 *
6953 * @see #resolveActivity
6954 * @see #setPackage
6955 */
6956 public String getPackage() {
6957 return mPackage;
6958 }
6959
6960 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006961 * Retrieve the concrete component associated with the intent. When receiving
6962 * an intent, this is the component that was found to best handle it (that is,
6963 * yourself) and will always be non-null; in all other cases it will be
6964 * null unless explicitly set.
6965 *
6966 * @return The name of the application component to handle the intent.
6967 *
6968 * @see #resolveActivity
6969 * @see #setComponent
6970 */
6971 public ComponentName getComponent() {
6972 return mComponent;
6973 }
6974
6975 /**
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08006976 * Get the bounds of the sender of this intent, in screen coordinates. This can be
6977 * used as a hint to the receiver for animations and the like. Null means that there
6978 * is no source bounds.
6979 */
6980 public Rect getSourceBounds() {
6981 return mSourceBounds;
6982 }
6983
6984 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006985 * Return the Activity component that should be used to handle this intent.
6986 * The appropriate component is determined based on the information in the
6987 * intent, evaluated as follows:
6988 *
6989 * <p>If {@link #getComponent} returns an explicit class, that is returned
6990 * without any further consideration.
6991 *
6992 * <p>The activity must handle the {@link Intent#CATEGORY_DEFAULT} Intent
6993 * category to be considered.
6994 *
6995 * <p>If {@link #getAction} is non-NULL, the activity must handle this
6996 * action.
6997 *
6998 * <p>If {@link #resolveType} returns non-NULL, the activity must handle
6999 * this type.
7000 *
7001 * <p>If {@link #addCategory} has added any categories, the activity must
7002 * handle ALL of the categories specified.
7003 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007004 * <p>If {@link #getPackage} is non-NULL, only activity components in
7005 * that application package will be considered.
7006 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007007 * <p>If there are no activities that satisfy all of these conditions, a
7008 * null string is returned.
7009 *
7010 * <p>If multiple activities are found to satisfy the intent, the one with
7011 * the highest priority will be used. If there are multiple activities
7012 * with the same priority, the system will either pick the best activity
7013 * based on user preference, or resolve to a system class that will allow
7014 * the user to pick an activity and forward from there.
7015 *
7016 * <p>This method is implemented simply by calling
7017 * {@link PackageManager#resolveActivity} with the "defaultOnly" parameter
7018 * true.</p>
7019 * <p> This API is called for you as part of starting an activity from an
7020 * intent. You do not normally need to call it yourself.</p>
7021 *
7022 * @param pm The package manager with which to resolve the Intent.
7023 *
7024 * @return Name of the component implementing an activity that can
7025 * display the intent.
7026 *
7027 * @see #setComponent
7028 * @see #getComponent
7029 * @see #resolveActivityInfo
7030 */
7031 public ComponentName resolveActivity(PackageManager pm) {
7032 if (mComponent != null) {
7033 return mComponent;
7034 }
7035
7036 ResolveInfo info = pm.resolveActivity(
7037 this, PackageManager.MATCH_DEFAULT_ONLY);
7038 if (info != null) {
7039 return new ComponentName(
7040 info.activityInfo.applicationInfo.packageName,
7041 info.activityInfo.name);
7042 }
7043
7044 return null;
7045 }
7046
7047 /**
7048 * Resolve the Intent into an {@link ActivityInfo}
7049 * describing the activity that should execute the intent. Resolution
7050 * follows the same rules as described for {@link #resolveActivity}, but
7051 * you get back the completely information about the resolved activity
7052 * instead of just its class name.
7053 *
7054 * @param pm The package manager with which to resolve the Intent.
7055 * @param flags Addition information to retrieve as per
7056 * {@link PackageManager#getActivityInfo(ComponentName, int)
7057 * PackageManager.getActivityInfo()}.
7058 *
7059 * @return PackageManager.ActivityInfo
7060 *
7061 * @see #resolveActivity
7062 */
7063 public ActivityInfo resolveActivityInfo(PackageManager pm, int flags) {
7064 ActivityInfo ai = null;
7065 if (mComponent != null) {
7066 try {
7067 ai = pm.getActivityInfo(mComponent, flags);
7068 } catch (PackageManager.NameNotFoundException e) {
7069 // ignore
7070 }
7071 } else {
7072 ResolveInfo info = pm.resolveActivity(
Dianne Hackborn9bfb7072009-09-22 11:37:40 -07007073 this, PackageManager.MATCH_DEFAULT_ONLY | flags);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007074 if (info != null) {
7075 ai = info.activityInfo;
7076 }
7077 }
7078
7079 return ai;
7080 }
7081
7082 /**
Dianne Hackborn221ea892013-08-04 16:50:16 -07007083 * Special function for use by the system to resolve service
7084 * intents to system apps. Throws an exception if there are
7085 * multiple potential matches to the Intent. Returns null if
7086 * there are no matches.
7087 * @hide
7088 */
7089 public ComponentName resolveSystemService(PackageManager pm, int flags) {
7090 if (mComponent != null) {
7091 return mComponent;
7092 }
7093
7094 List<ResolveInfo> results = pm.queryIntentServices(this, flags);
7095 if (results == null) {
7096 return null;
7097 }
7098 ComponentName comp = null;
7099 for (int i=0; i<results.size(); i++) {
7100 ResolveInfo ri = results.get(i);
7101 if ((ri.serviceInfo.applicationInfo.flags&ApplicationInfo.FLAG_SYSTEM) == 0) {
7102 continue;
7103 }
7104 ComponentName foundComp = new ComponentName(ri.serviceInfo.applicationInfo.packageName,
7105 ri.serviceInfo.name);
7106 if (comp != null) {
7107 throw new IllegalStateException("Multiple system services handle " + this
7108 + ": " + comp + ", " + foundComp);
7109 }
7110 comp = foundComp;
7111 }
7112 return comp;
7113 }
7114
7115 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007116 * Set the general action to be performed.
7117 *
7118 * @param action An action name, such as ACTION_VIEW. Application-specific
7119 * actions should be prefixed with the vendor's package name.
7120 *
7121 * @return Returns the same Intent object, for chaining multiple calls
7122 * into a single statement.
7123 *
7124 * @see #getAction
7125 */
7126 public Intent setAction(String action) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08007127 mAction = action != null ? action.intern() : null;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007128 return this;
7129 }
7130
7131 /**
7132 * Set the data this intent is operating on. This method automatically
Nick Pellyccae4122012-01-09 14:12:58 -08007133 * clears any type that was previously set by {@link #setType} or
7134 * {@link #setTypeAndNormalize}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007135 *
Nick Pellyccae4122012-01-09 14:12:58 -08007136 * <p><em>Note: scheme matching in the Android framework is
7137 * case-sensitive, unlike the formal RFC. As a result,
7138 * you should always write your Uri with a lower case scheme,
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04007139 * or use {@link Uri#normalizeScheme} or
Nick Pellyccae4122012-01-09 14:12:58 -08007140 * {@link #setDataAndNormalize}
7141 * to ensure that the scheme is converted to lower case.</em>
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07007142 *
Nick Pellyccae4122012-01-09 14:12:58 -08007143 * @param data The Uri of the data this intent is now targeting.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007144 *
7145 * @return Returns the same Intent object, for chaining multiple calls
7146 * into a single statement.
7147 *
7148 * @see #getData
Nick Pellyccae4122012-01-09 14:12:58 -08007149 * @see #setDataAndNormalize
Dianne Hackborn221ea892013-08-04 16:50:16 -07007150 * @see android.net.Uri#normalizeScheme()
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007151 */
7152 public Intent setData(Uri data) {
7153 mData = data;
7154 mType = null;
7155 return this;
7156 }
7157
7158 /**
Nick Pellyccae4122012-01-09 14:12:58 -08007159 * Normalize and set the data this intent is operating on.
7160 *
7161 * <p>This method automatically clears any type that was
7162 * previously set (for example, by {@link #setType}).
7163 *
7164 * <p>The data Uri is normalized using
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04007165 * {@link android.net.Uri#normalizeScheme} before it is set,
Nick Pellyccae4122012-01-09 14:12:58 -08007166 * so really this is just a convenience method for
7167 * <pre>
7168 * setData(data.normalize())
7169 * </pre>
7170 *
7171 * @param data The Uri of the data this intent is now targeting.
7172 *
7173 * @return Returns the same Intent object, for chaining multiple calls
7174 * into a single statement.
7175 *
7176 * @see #getData
7177 * @see #setType
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04007178 * @see android.net.Uri#normalizeScheme
Nick Pellyccae4122012-01-09 14:12:58 -08007179 */
7180 public Intent setDataAndNormalize(Uri data) {
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04007181 return setData(data.normalizeScheme());
Nick Pellyccae4122012-01-09 14:12:58 -08007182 }
7183
7184 /**
7185 * Set an explicit MIME data type.
7186 *
7187 * <p>This is used to create intents that only specify a type and not data,
7188 * for example to indicate the type of data to return.
7189 *
7190 * <p>This method automatically clears any data that was
7191 * previously set (for example by {@link #setData}).
Romain Guy4969af72009-06-17 10:53:19 -07007192 *
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07007193 * <p><em>Note: MIME type matching in the Android framework is
7194 * case-sensitive, unlike formal RFC MIME types. As a result,
7195 * you should always write your MIME types with lower case letters,
Nick Pellyccae4122012-01-09 14:12:58 -08007196 * or use {@link #normalizeMimeType} or {@link #setTypeAndNormalize}
7197 * to ensure that it is converted to lower case.</em>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007198 *
7199 * @param type The MIME type of the data being handled by this intent.
7200 *
7201 * @return Returns the same Intent object, for chaining multiple calls
7202 * into a single statement.
7203 *
7204 * @see #getType
Nick Pellyccae4122012-01-09 14:12:58 -08007205 * @see #setTypeAndNormalize
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007206 * @see #setDataAndType
Nick Pellyccae4122012-01-09 14:12:58 -08007207 * @see #normalizeMimeType
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007208 */
7209 public Intent setType(String type) {
7210 mData = null;
7211 mType = type;
7212 return this;
7213 }
7214
7215 /**
Nick Pellyccae4122012-01-09 14:12:58 -08007216 * Normalize and set an explicit MIME data type.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007217 *
Nick Pellyccae4122012-01-09 14:12:58 -08007218 * <p>This is used to create intents that only specify a type and not data,
7219 * for example to indicate the type of data to return.
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07007220 *
Nick Pellyccae4122012-01-09 14:12:58 -08007221 * <p>This method automatically clears any data that was
7222 * previously set (for example by {@link #setData}).
7223 *
7224 * <p>The MIME type is normalized using
7225 * {@link #normalizeMimeType} before it is set,
7226 * so really this is just a convenience method for
7227 * <pre>
7228 * setType(Intent.normalizeMimeType(type))
7229 * </pre>
7230 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007231 * @param type The MIME type of the data being handled by this intent.
7232 *
7233 * @return Returns the same Intent object, for chaining multiple calls
7234 * into a single statement.
7235 *
Nick Pellyccae4122012-01-09 14:12:58 -08007236 * @see #getType
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007237 * @see #setData
Nick Pellyccae4122012-01-09 14:12:58 -08007238 * @see #normalizeMimeType
7239 */
7240 public Intent setTypeAndNormalize(String type) {
7241 return setType(normalizeMimeType(type));
7242 }
7243
7244 /**
7245 * (Usually optional) Set the data for the intent along with an explicit
7246 * MIME data type. This method should very rarely be used -- it allows you
7247 * to override the MIME type that would ordinarily be inferred from the
7248 * data with your own type given here.
7249 *
7250 * <p><em>Note: MIME type and Uri scheme matching in the
7251 * Android framework is case-sensitive, unlike the formal RFC definitions.
7252 * As a result, you should always write these elements with lower case letters,
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04007253 * or use {@link #normalizeMimeType} or {@link android.net.Uri#normalizeScheme} or
Nick Pellyccae4122012-01-09 14:12:58 -08007254 * {@link #setDataAndTypeAndNormalize}
7255 * to ensure that they are converted to lower case.</em>
7256 *
7257 * @param data The Uri of the data this intent is now targeting.
7258 * @param type The MIME type of the data being handled by this intent.
7259 *
7260 * @return Returns the same Intent object, for chaining multiple calls
7261 * into a single statement.
7262 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007263 * @see #setType
Nick Pellyccae4122012-01-09 14:12:58 -08007264 * @see #setData
7265 * @see #normalizeMimeType
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04007266 * @see android.net.Uri#normalizeScheme
Nick Pellyccae4122012-01-09 14:12:58 -08007267 * @see #setDataAndTypeAndNormalize
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007268 */
7269 public Intent setDataAndType(Uri data, String type) {
7270 mData = data;
7271 mType = type;
7272 return this;
7273 }
7274
7275 /**
Nick Pellyccae4122012-01-09 14:12:58 -08007276 * (Usually optional) Normalize and set both the data Uri and an explicit
7277 * MIME data type. This method should very rarely be used -- it allows you
7278 * to override the MIME type that would ordinarily be inferred from the
7279 * data with your own type given here.
7280 *
7281 * <p>The data Uri and the MIME type are normalize using
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04007282 * {@link android.net.Uri#normalizeScheme} and {@link #normalizeMimeType}
Nick Pellyccae4122012-01-09 14:12:58 -08007283 * before they are set, so really this is just a convenience method for
7284 * <pre>
7285 * setDataAndType(data.normalize(), Intent.normalizeMimeType(type))
7286 * </pre>
7287 *
7288 * @param data The Uri of the data this intent is now targeting.
7289 * @param type The MIME type of the data being handled by this intent.
7290 *
7291 * @return Returns the same Intent object, for chaining multiple calls
7292 * into a single statement.
7293 *
7294 * @see #setType
7295 * @see #setData
7296 * @see #setDataAndType
7297 * @see #normalizeMimeType
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04007298 * @see android.net.Uri#normalizeScheme
Nick Pellyccae4122012-01-09 14:12:58 -08007299 */
7300 public Intent setDataAndTypeAndNormalize(Uri data, String type) {
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04007301 return setDataAndType(data.normalizeScheme(), normalizeMimeType(type));
Nick Pellyccae4122012-01-09 14:12:58 -08007302 }
7303
7304 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007305 * Add a new category to the intent. Categories provide additional detail
Ken Wakasaf76a50c2012-03-09 19:56:35 +09007306 * about the action the intent performs. When resolving an intent, only
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007307 * activities that provide <em>all</em> of the requested categories will be
7308 * used.
7309 *
7310 * @param category The desired category. This can be either one of the
7311 * predefined Intent categories, or a custom category in your own
7312 * namespace.
7313 *
7314 * @return Returns the same Intent object, for chaining multiple calls
7315 * into a single statement.
7316 *
7317 * @see #hasCategory
7318 * @see #removeCategory
7319 */
7320 public Intent addCategory(String category) {
7321 if (mCategories == null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07007322 mCategories = new ArraySet<String>();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007323 }
Jeff Brown2c376fc2011-01-28 17:34:01 -08007324 mCategories.add(category.intern());
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007325 return this;
7326 }
7327
7328 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09007329 * Remove a category from an intent.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007330 *
7331 * @param category The category to remove.
7332 *
7333 * @see #addCategory
7334 */
7335 public void removeCategory(String category) {
7336 if (mCategories != null) {
7337 mCategories.remove(category);
7338 if (mCategories.size() == 0) {
7339 mCategories = null;
7340 }
7341 }
7342 }
7343
7344 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08007345 * Set a selector for this Intent. This is a modification to the kinds of
7346 * things the Intent will match. If the selector is set, it will be used
7347 * when trying to find entities that can handle the Intent, instead of the
7348 * main contents of the Intent. This allows you build an Intent containing
7349 * a generic protocol while targeting it more specifically.
7350 *
7351 * <p>An example of where this may be used is with things like
7352 * {@link #CATEGORY_APP_BROWSER}. This category allows you to build an
7353 * Intent that will launch the Browser application. However, the correct
7354 * main entry point of an application is actually {@link #ACTION_MAIN}
7355 * {@link #CATEGORY_LAUNCHER} with {@link #setComponent(ComponentName)}
7356 * used to specify the actual Activity to launch. If you launch the browser
7357 * with something different, undesired behavior may happen if the user has
7358 * previously or later launches it the normal way, since they do not match.
7359 * Instead, you can build an Intent with the MAIN action (but no ComponentName
7360 * yet specified) and set a selector with {@link #ACTION_MAIN} and
7361 * {@link #CATEGORY_APP_BROWSER} to point it specifically to the browser activity.
7362 *
7363 * <p>Setting a selector does not impact the behavior of
7364 * {@link #filterEquals(Intent)} and {@link #filterHashCode()}. This is part of the
7365 * desired behavior of a selector -- it does not impact the base meaning
7366 * of the Intent, just what kinds of things will be matched against it
7367 * when determining who can handle it.</p>
7368 *
7369 * <p>You can not use both a selector and {@link #setPackage(String)} on
7370 * the same base Intent.</p>
7371 *
7372 * @param selector The desired selector Intent; set to null to not use
7373 * a special selector.
7374 */
7375 public void setSelector(Intent selector) {
7376 if (selector == this) {
7377 throw new IllegalArgumentException(
7378 "Intent being set as a selector of itself");
7379 }
7380 if (selector != null && mPackage != null) {
7381 throw new IllegalArgumentException(
7382 "Can't set selector when package name is already set");
7383 }
7384 mSelector = selector;
7385 }
7386
7387 /**
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007388 * Set a {@link ClipData} associated with this Intent. This replaces any
7389 * previously set ClipData.
7390 *
7391 * <p>The ClipData in an intent is not used for Intent matching or other
7392 * such operations. Semantically it is like extras, used to transmit
7393 * additional data with the Intent. The main feature of using this over
7394 * the extras for data is that {@link #FLAG_GRANT_READ_URI_PERMISSION}
7395 * and {@link #FLAG_GRANT_WRITE_URI_PERMISSION} will operate on any URI
7396 * items included in the clip data. This is useful, in particular, if
7397 * you want to transmit an Intent containing multiple <code>content:</code>
7398 * URIs for which the recipient may not have global permission to access the
7399 * content provider.
7400 *
7401 * <p>If the ClipData contains items that are themselves Intents, any
7402 * grant flags in those Intents will be ignored. Only the top-level flags
7403 * of the main Intent are respected, and will be applied to all Uri or
7404 * Intent items in the clip (or sub-items of the clip).
7405 *
7406 * <p>The MIME type, label, and icon in the ClipData object are not
7407 * directly used by Intent. Applications should generally rely on the
7408 * MIME type of the Intent itself, not what it may find in the ClipData.
7409 * A common practice is to construct a ClipData for use with an Intent
John Spurlock33900182014-01-02 11:04:18 -05007410 * with a MIME type of "*&#47;*".
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007411 *
7412 * @param clip The new clip to set. May be null to clear the current clip.
7413 */
7414 public void setClipData(ClipData clip) {
7415 mClipData = clip;
7416 }
7417
7418 /**
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01007419 * This is NOT a secure mechanism to identify the user who sent the intent.
7420 * When the intent is sent to a different user, it is used to fix uris by adding the userId
7421 * who sent the intent.
7422 * @hide
7423 */
Nicolas Prevot107f7b72015-07-01 16:31:48 +01007424 public void prepareToLeaveUser(int userId) {
7425 // If mContentUserHint is not UserHandle.USER_CURRENT, the intent has already left a user.
7426 // We want mContentUserHint to refer to the original user, so don't do anything.
7427 if (mContentUserHint == UserHandle.USER_CURRENT) {
7428 mContentUserHint = userId;
7429 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01007430 }
7431
7432 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007433 * Add extended data to the intent. The name must include a package
7434 * prefix, for example the app com.android.contacts would use names
7435 * like "com.android.contacts.ShowAll".
7436 *
7437 * @param name The name of the extra data, with package prefix.
7438 * @param value The boolean data value.
7439 *
7440 * @return Returns the same Intent object, for chaining multiple calls
7441 * into a single statement.
7442 *
7443 * @see #putExtras
7444 * @see #removeExtra
7445 * @see #getBooleanExtra(String, boolean)
7446 */
7447 public Intent putExtra(String name, boolean value) {
7448 if (mExtras == null) {
7449 mExtras = new Bundle();
7450 }
7451 mExtras.putBoolean(name, value);
7452 return this;
7453 }
7454
7455 /**
7456 * Add extended data to the intent. The name must include a package
7457 * prefix, for example the app com.android.contacts would use names
7458 * like "com.android.contacts.ShowAll".
7459 *
7460 * @param name The name of the extra data, with package prefix.
7461 * @param value The byte data value.
7462 *
7463 * @return Returns the same Intent object, for chaining multiple calls
7464 * into a single statement.
7465 *
7466 * @see #putExtras
7467 * @see #removeExtra
7468 * @see #getByteExtra(String, byte)
7469 */
7470 public Intent putExtra(String name, byte value) {
7471 if (mExtras == null) {
7472 mExtras = new Bundle();
7473 }
7474 mExtras.putByte(name, value);
7475 return this;
7476 }
7477
7478 /**
7479 * Add extended data to the intent. The name must include a package
7480 * prefix, for example the app com.android.contacts would use names
7481 * like "com.android.contacts.ShowAll".
7482 *
7483 * @param name The name of the extra data, with package prefix.
7484 * @param value The char data value.
7485 *
7486 * @return Returns the same Intent object, for chaining multiple calls
7487 * into a single statement.
7488 *
7489 * @see #putExtras
7490 * @see #removeExtra
7491 * @see #getCharExtra(String, char)
7492 */
7493 public Intent putExtra(String name, char value) {
7494 if (mExtras == null) {
7495 mExtras = new Bundle();
7496 }
7497 mExtras.putChar(name, value);
7498 return this;
7499 }
7500
7501 /**
7502 * Add extended data to the intent. The name must include a package
7503 * prefix, for example the app com.android.contacts would use names
7504 * like "com.android.contacts.ShowAll".
7505 *
7506 * @param name The name of the extra data, with package prefix.
7507 * @param value The short data value.
7508 *
7509 * @return Returns the same Intent object, for chaining multiple calls
7510 * into a single statement.
7511 *
7512 * @see #putExtras
7513 * @see #removeExtra
7514 * @see #getShortExtra(String, short)
7515 */
7516 public Intent putExtra(String name, short value) {
7517 if (mExtras == null) {
7518 mExtras = new Bundle();
7519 }
7520 mExtras.putShort(name, value);
7521 return this;
7522 }
7523
7524 /**
7525 * Add extended data to the intent. The name must include a package
7526 * prefix, for example the app com.android.contacts would use names
7527 * like "com.android.contacts.ShowAll".
7528 *
7529 * @param name The name of the extra data, with package prefix.
7530 * @param value The integer data value.
7531 *
7532 * @return Returns the same Intent object, for chaining multiple calls
7533 * into a single statement.
7534 *
7535 * @see #putExtras
7536 * @see #removeExtra
7537 * @see #getIntExtra(String, int)
7538 */
7539 public Intent putExtra(String name, int value) {
7540 if (mExtras == null) {
7541 mExtras = new Bundle();
7542 }
7543 mExtras.putInt(name, value);
7544 return this;
7545 }
7546
7547 /**
7548 * Add extended data to the intent. The name must include a package
7549 * prefix, for example the app com.android.contacts would use names
7550 * like "com.android.contacts.ShowAll".
7551 *
7552 * @param name The name of the extra data, with package prefix.
7553 * @param value The long data value.
7554 *
7555 * @return Returns the same Intent object, for chaining multiple calls
7556 * into a single statement.
7557 *
7558 * @see #putExtras
7559 * @see #removeExtra
7560 * @see #getLongExtra(String, long)
7561 */
7562 public Intent putExtra(String name, long value) {
7563 if (mExtras == null) {
7564 mExtras = new Bundle();
7565 }
7566 mExtras.putLong(name, value);
7567 return this;
7568 }
7569
7570 /**
7571 * Add extended data to the intent. The name must include a package
7572 * prefix, for example the app com.android.contacts would use names
7573 * like "com.android.contacts.ShowAll".
7574 *
7575 * @param name The name of the extra data, with package prefix.
7576 * @param value The float data value.
7577 *
7578 * @return Returns the same Intent object, for chaining multiple calls
7579 * into a single statement.
7580 *
7581 * @see #putExtras
7582 * @see #removeExtra
7583 * @see #getFloatExtra(String, float)
7584 */
7585 public Intent putExtra(String name, float value) {
7586 if (mExtras == null) {
7587 mExtras = new Bundle();
7588 }
7589 mExtras.putFloat(name, value);
7590 return this;
7591 }
7592
7593 /**
7594 * Add extended data to the intent. The name must include a package
7595 * prefix, for example the app com.android.contacts would use names
7596 * like "com.android.contacts.ShowAll".
7597 *
7598 * @param name The name of the extra data, with package prefix.
7599 * @param value The double data value.
7600 *
7601 * @return Returns the same Intent object, for chaining multiple calls
7602 * into a single statement.
7603 *
7604 * @see #putExtras
7605 * @see #removeExtra
7606 * @see #getDoubleExtra(String, double)
7607 */
7608 public Intent putExtra(String name, double value) {
7609 if (mExtras == null) {
7610 mExtras = new Bundle();
7611 }
7612 mExtras.putDouble(name, value);
7613 return this;
7614 }
7615
7616 /**
7617 * Add extended data to the intent. The name must include a package
7618 * prefix, for example the app com.android.contacts would use names
7619 * like "com.android.contacts.ShowAll".
7620 *
7621 * @param name The name of the extra data, with package prefix.
7622 * @param value The String data value.
7623 *
7624 * @return Returns the same Intent object, for chaining multiple calls
7625 * into a single statement.
7626 *
7627 * @see #putExtras
7628 * @see #removeExtra
7629 * @see #getStringExtra(String)
7630 */
7631 public Intent putExtra(String name, String value) {
7632 if (mExtras == null) {
7633 mExtras = new Bundle();
7634 }
7635 mExtras.putString(name, value);
7636 return this;
7637 }
7638
7639 /**
7640 * Add extended data to the intent. The name must include a package
7641 * prefix, for example the app com.android.contacts would use names
7642 * like "com.android.contacts.ShowAll".
7643 *
7644 * @param name The name of the extra data, with package prefix.
7645 * @param value The CharSequence data value.
7646 *
7647 * @return Returns the same Intent object, for chaining multiple calls
7648 * into a single statement.
7649 *
7650 * @see #putExtras
7651 * @see #removeExtra
7652 * @see #getCharSequenceExtra(String)
7653 */
7654 public Intent putExtra(String name, CharSequence value) {
7655 if (mExtras == null) {
7656 mExtras = new Bundle();
7657 }
7658 mExtras.putCharSequence(name, value);
7659 return this;
7660 }
7661
7662 /**
7663 * Add extended data to the intent. The name must include a package
7664 * prefix, for example the app com.android.contacts would use names
7665 * like "com.android.contacts.ShowAll".
7666 *
7667 * @param name The name of the extra data, with package prefix.
7668 * @param value The Parcelable data value.
7669 *
7670 * @return Returns the same Intent object, for chaining multiple calls
7671 * into a single statement.
7672 *
7673 * @see #putExtras
7674 * @see #removeExtra
7675 * @see #getParcelableExtra(String)
7676 */
7677 public Intent putExtra(String name, Parcelable value) {
7678 if (mExtras == null) {
7679 mExtras = new Bundle();
7680 }
7681 mExtras.putParcelable(name, value);
7682 return this;
7683 }
7684
7685 /**
7686 * Add extended data to the intent. The name must include a package
7687 * prefix, for example the app com.android.contacts would use names
7688 * like "com.android.contacts.ShowAll".
7689 *
7690 * @param name The name of the extra data, with package prefix.
7691 * @param value The Parcelable[] data value.
7692 *
7693 * @return Returns the same Intent object, for chaining multiple calls
7694 * into a single statement.
7695 *
7696 * @see #putExtras
7697 * @see #removeExtra
7698 * @see #getParcelableArrayExtra(String)
7699 */
7700 public Intent putExtra(String name, Parcelable[] value) {
7701 if (mExtras == null) {
7702 mExtras = new Bundle();
7703 }
7704 mExtras.putParcelableArray(name, value);
7705 return this;
7706 }
7707
7708 /**
7709 * Add extended data to the intent. The name must include a package
7710 * prefix, for example the app com.android.contacts would use names
7711 * like "com.android.contacts.ShowAll".
7712 *
7713 * @param name The name of the extra data, with package prefix.
7714 * @param value The ArrayList<Parcelable> data value.
7715 *
7716 * @return Returns the same Intent object, for chaining multiple calls
7717 * into a single statement.
7718 *
7719 * @see #putExtras
7720 * @see #removeExtra
7721 * @see #getParcelableArrayListExtra(String)
7722 */
7723 public Intent putParcelableArrayListExtra(String name, ArrayList<? extends Parcelable> value) {
7724 if (mExtras == null) {
7725 mExtras = new Bundle();
7726 }
7727 mExtras.putParcelableArrayList(name, value);
7728 return this;
7729 }
7730
7731 /**
7732 * Add extended data to the intent. The name must include a package
7733 * prefix, for example the app com.android.contacts would use names
7734 * like "com.android.contacts.ShowAll".
7735 *
7736 * @param name The name of the extra data, with package prefix.
7737 * @param value The ArrayList<Integer> data value.
7738 *
7739 * @return Returns the same Intent object, for chaining multiple calls
7740 * into a single statement.
7741 *
7742 * @see #putExtras
7743 * @see #removeExtra
7744 * @see #getIntegerArrayListExtra(String)
7745 */
7746 public Intent putIntegerArrayListExtra(String name, ArrayList<Integer> value) {
7747 if (mExtras == null) {
7748 mExtras = new Bundle();
7749 }
7750 mExtras.putIntegerArrayList(name, value);
7751 return this;
7752 }
7753
7754 /**
7755 * Add extended data to the intent. The name must include a package
7756 * prefix, for example the app com.android.contacts would use names
7757 * like "com.android.contacts.ShowAll".
7758 *
7759 * @param name The name of the extra data, with package prefix.
7760 * @param value The ArrayList<String> data value.
7761 *
7762 * @return Returns the same Intent object, for chaining multiple calls
7763 * into a single statement.
7764 *
7765 * @see #putExtras
7766 * @see #removeExtra
7767 * @see #getStringArrayListExtra(String)
7768 */
7769 public Intent putStringArrayListExtra(String name, ArrayList<String> value) {
7770 if (mExtras == null) {
7771 mExtras = new Bundle();
7772 }
7773 mExtras.putStringArrayList(name, value);
7774 return this;
7775 }
7776
7777 /**
7778 * Add extended data to the intent. The name must include a package
7779 * prefix, for example the app com.android.contacts would use names
7780 * like "com.android.contacts.ShowAll".
7781 *
7782 * @param name The name of the extra data, with package prefix.
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00007783 * @param value The ArrayList<CharSequence> data value.
7784 *
7785 * @return Returns the same Intent object, for chaining multiple calls
7786 * into a single statement.
7787 *
7788 * @see #putExtras
7789 * @see #removeExtra
7790 * @see #getCharSequenceArrayListExtra(String)
7791 */
7792 public Intent putCharSequenceArrayListExtra(String name, ArrayList<CharSequence> value) {
7793 if (mExtras == null) {
7794 mExtras = new Bundle();
7795 }
7796 mExtras.putCharSequenceArrayList(name, value);
7797 return this;
7798 }
7799
7800 /**
7801 * Add extended data to the intent. The name must include a package
7802 * prefix, for example the app com.android.contacts would use names
7803 * like "com.android.contacts.ShowAll".
7804 *
7805 * @param name The name of the extra data, with package prefix.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007806 * @param value The Serializable data value.
7807 *
7808 * @return Returns the same Intent object, for chaining multiple calls
7809 * into a single statement.
7810 *
7811 * @see #putExtras
7812 * @see #removeExtra
7813 * @see #getSerializableExtra(String)
7814 */
7815 public Intent putExtra(String name, Serializable value) {
7816 if (mExtras == null) {
7817 mExtras = new Bundle();
7818 }
7819 mExtras.putSerializable(name, value);
7820 return this;
7821 }
7822
7823 /**
7824 * Add extended data to the intent. The name must include a package
7825 * prefix, for example the app com.android.contacts would use names
7826 * like "com.android.contacts.ShowAll".
7827 *
7828 * @param name The name of the extra data, with package prefix.
7829 * @param value The boolean array data value.
7830 *
7831 * @return Returns the same Intent object, for chaining multiple calls
7832 * into a single statement.
7833 *
7834 * @see #putExtras
7835 * @see #removeExtra
7836 * @see #getBooleanArrayExtra(String)
7837 */
7838 public Intent putExtra(String name, boolean[] value) {
7839 if (mExtras == null) {
7840 mExtras = new Bundle();
7841 }
7842 mExtras.putBooleanArray(name, value);
7843 return this;
7844 }
7845
7846 /**
7847 * Add extended data to the intent. The name must include a package
7848 * prefix, for example the app com.android.contacts would use names
7849 * like "com.android.contacts.ShowAll".
7850 *
7851 * @param name The name of the extra data, with package prefix.
7852 * @param value The byte array data value.
7853 *
7854 * @return Returns the same Intent object, for chaining multiple calls
7855 * into a single statement.
7856 *
7857 * @see #putExtras
7858 * @see #removeExtra
7859 * @see #getByteArrayExtra(String)
7860 */
7861 public Intent putExtra(String name, byte[] value) {
7862 if (mExtras == null) {
7863 mExtras = new Bundle();
7864 }
7865 mExtras.putByteArray(name, value);
7866 return this;
7867 }
7868
7869 /**
7870 * Add extended data to the intent. The name must include a package
7871 * prefix, for example the app com.android.contacts would use names
7872 * like "com.android.contacts.ShowAll".
7873 *
7874 * @param name The name of the extra data, with package prefix.
7875 * @param value The short array data value.
7876 *
7877 * @return Returns the same Intent object, for chaining multiple calls
7878 * into a single statement.
7879 *
7880 * @see #putExtras
7881 * @see #removeExtra
7882 * @see #getShortArrayExtra(String)
7883 */
7884 public Intent putExtra(String name, short[] value) {
7885 if (mExtras == null) {
7886 mExtras = new Bundle();
7887 }
7888 mExtras.putShortArray(name, value);
7889 return this;
7890 }
7891
7892 /**
7893 * Add extended data to the intent. The name must include a package
7894 * prefix, for example the app com.android.contacts would use names
7895 * like "com.android.contacts.ShowAll".
7896 *
7897 * @param name The name of the extra data, with package prefix.
7898 * @param value The char array data value.
7899 *
7900 * @return Returns the same Intent object, for chaining multiple calls
7901 * into a single statement.
7902 *
7903 * @see #putExtras
7904 * @see #removeExtra
7905 * @see #getCharArrayExtra(String)
7906 */
7907 public Intent putExtra(String name, char[] value) {
7908 if (mExtras == null) {
7909 mExtras = new Bundle();
7910 }
7911 mExtras.putCharArray(name, value);
7912 return this;
7913 }
7914
7915 /**
7916 * Add extended data to the intent. The name must include a package
7917 * prefix, for example the app com.android.contacts would use names
7918 * like "com.android.contacts.ShowAll".
7919 *
7920 * @param name The name of the extra data, with package prefix.
7921 * @param value The int array data value.
7922 *
7923 * @return Returns the same Intent object, for chaining multiple calls
7924 * into a single statement.
7925 *
7926 * @see #putExtras
7927 * @see #removeExtra
7928 * @see #getIntArrayExtra(String)
7929 */
7930 public Intent putExtra(String name, int[] value) {
7931 if (mExtras == null) {
7932 mExtras = new Bundle();
7933 }
7934 mExtras.putIntArray(name, value);
7935 return this;
7936 }
7937
7938 /**
7939 * Add extended data to the intent. The name must include a package
7940 * prefix, for example the app com.android.contacts would use names
7941 * like "com.android.contacts.ShowAll".
7942 *
7943 * @param name The name of the extra data, with package prefix.
7944 * @param value The byte array data value.
7945 *
7946 * @return Returns the same Intent object, for chaining multiple calls
7947 * into a single statement.
7948 *
7949 * @see #putExtras
7950 * @see #removeExtra
7951 * @see #getLongArrayExtra(String)
7952 */
7953 public Intent putExtra(String name, long[] value) {
7954 if (mExtras == null) {
7955 mExtras = new Bundle();
7956 }
7957 mExtras.putLongArray(name, value);
7958 return this;
7959 }
7960
7961 /**
7962 * Add extended data to the intent. The name must include a package
7963 * prefix, for example the app com.android.contacts would use names
7964 * like "com.android.contacts.ShowAll".
7965 *
7966 * @param name The name of the extra data, with package prefix.
7967 * @param value The float array data value.
7968 *
7969 * @return Returns the same Intent object, for chaining multiple calls
7970 * into a single statement.
7971 *
7972 * @see #putExtras
7973 * @see #removeExtra
7974 * @see #getFloatArrayExtra(String)
7975 */
7976 public Intent putExtra(String name, float[] value) {
7977 if (mExtras == null) {
7978 mExtras = new Bundle();
7979 }
7980 mExtras.putFloatArray(name, value);
7981 return this;
7982 }
7983
7984 /**
7985 * Add extended data to the intent. The name must include a package
7986 * prefix, for example the app com.android.contacts would use names
7987 * like "com.android.contacts.ShowAll".
7988 *
7989 * @param name The name of the extra data, with package prefix.
7990 * @param value The double array data value.
7991 *
7992 * @return Returns the same Intent object, for chaining multiple calls
7993 * into a single statement.
7994 *
7995 * @see #putExtras
7996 * @see #removeExtra
7997 * @see #getDoubleArrayExtra(String)
7998 */
7999 public Intent putExtra(String name, double[] value) {
8000 if (mExtras == null) {
8001 mExtras = new Bundle();
8002 }
8003 mExtras.putDoubleArray(name, value);
8004 return this;
8005 }
8006
8007 /**
8008 * Add extended data to the intent. The name must include a package
8009 * prefix, for example the app com.android.contacts would use names
8010 * like "com.android.contacts.ShowAll".
8011 *
8012 * @param name The name of the extra data, with package prefix.
8013 * @param value The String array data value.
8014 *
8015 * @return Returns the same Intent object, for chaining multiple calls
8016 * into a single statement.
8017 *
8018 * @see #putExtras
8019 * @see #removeExtra
8020 * @see #getStringArrayExtra(String)
8021 */
8022 public Intent putExtra(String name, String[] value) {
8023 if (mExtras == null) {
8024 mExtras = new Bundle();
8025 }
8026 mExtras.putStringArray(name, value);
8027 return this;
8028 }
8029
8030 /**
8031 * Add extended data to the intent. The name must include a package
8032 * prefix, for example the app com.android.contacts would use names
8033 * like "com.android.contacts.ShowAll".
8034 *
8035 * @param name The name of the extra data, with package prefix.
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00008036 * @param value The CharSequence array data value.
8037 *
8038 * @return Returns the same Intent object, for chaining multiple calls
8039 * into a single statement.
8040 *
8041 * @see #putExtras
8042 * @see #removeExtra
8043 * @see #getCharSequenceArrayExtra(String)
8044 */
8045 public Intent putExtra(String name, CharSequence[] value) {
8046 if (mExtras == null) {
8047 mExtras = new Bundle();
8048 }
8049 mExtras.putCharSequenceArray(name, value);
8050 return this;
8051 }
8052
8053 /**
8054 * Add extended data to the intent. The name must include a package
8055 * prefix, for example the app com.android.contacts would use names
8056 * like "com.android.contacts.ShowAll".
8057 *
8058 * @param name The name of the extra data, with package prefix.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008059 * @param value The Bundle data value.
8060 *
8061 * @return Returns the same Intent object, for chaining multiple calls
8062 * into a single statement.
8063 *
8064 * @see #putExtras
8065 * @see #removeExtra
8066 * @see #getBundleExtra(String)
8067 */
8068 public Intent putExtra(String name, Bundle value) {
8069 if (mExtras == null) {
8070 mExtras = new Bundle();
8071 }
8072 mExtras.putBundle(name, value);
8073 return this;
8074 }
8075
8076 /**
8077 * Add extended data to the intent. The name must include a package
8078 * prefix, for example the app com.android.contacts would use names
8079 * like "com.android.contacts.ShowAll".
8080 *
8081 * @param name The name of the extra data, with package prefix.
8082 * @param value The IBinder data value.
8083 *
8084 * @return Returns the same Intent object, for chaining multiple calls
8085 * into a single statement.
8086 *
8087 * @see #putExtras
8088 * @see #removeExtra
8089 * @see #getIBinderExtra(String)
8090 *
8091 * @deprecated
8092 * @hide
8093 */
8094 @Deprecated
8095 public Intent putExtra(String name, IBinder value) {
8096 if (mExtras == null) {
8097 mExtras = new Bundle();
8098 }
8099 mExtras.putIBinder(name, value);
8100 return this;
8101 }
8102
8103 /**
8104 * Copy all extras in 'src' in to this intent.
8105 *
8106 * @param src Contains the extras to copy.
8107 *
8108 * @see #putExtra
8109 */
8110 public Intent putExtras(Intent src) {
8111 if (src.mExtras != null) {
8112 if (mExtras == null) {
8113 mExtras = new Bundle(src.mExtras);
8114 } else {
8115 mExtras.putAll(src.mExtras);
8116 }
8117 }
8118 return this;
8119 }
8120
8121 /**
8122 * Add a set of extended data to the intent. The keys must include a package
8123 * prefix, for example the app com.android.contacts would use names
8124 * like "com.android.contacts.ShowAll".
8125 *
8126 * @param extras The Bundle of extras to add to this intent.
8127 *
8128 * @see #putExtra
8129 * @see #removeExtra
8130 */
8131 public Intent putExtras(Bundle extras) {
8132 if (mExtras == null) {
8133 mExtras = new Bundle();
8134 }
8135 mExtras.putAll(extras);
8136 return this;
8137 }
8138
8139 /**
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08008140 * Completely replace the extras in the Intent with the extras in the
8141 * given Intent.
The Android Open Source Project10592532009-03-18 17:39:46 -07008142 *
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08008143 * @param src The exact extras contained in this Intent are copied
8144 * into the target intent, replacing any that were previously there.
8145 */
8146 public Intent replaceExtras(Intent src) {
8147 mExtras = src.mExtras != null ? new Bundle(src.mExtras) : null;
8148 return this;
8149 }
The Android Open Source Project10592532009-03-18 17:39:46 -07008150
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08008151 /**
8152 * Completely replace the extras in the Intent with the given Bundle of
8153 * extras.
The Android Open Source Project10592532009-03-18 17:39:46 -07008154 *
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08008155 * @param extras The new set of extras in the Intent, or null to erase
8156 * all extras.
8157 */
8158 public Intent replaceExtras(Bundle extras) {
8159 mExtras = extras != null ? new Bundle(extras) : null;
8160 return this;
8161 }
The Android Open Source Project10592532009-03-18 17:39:46 -07008162
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08008163 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008164 * Remove extended data from the intent.
8165 *
8166 * @see #putExtra
8167 */
8168 public void removeExtra(String name) {
8169 if (mExtras != null) {
8170 mExtras.remove(name);
8171 if (mExtras.size() == 0) {
8172 mExtras = null;
8173 }
8174 }
8175 }
8176
8177 /**
8178 * Set special flags controlling how this intent is handled. Most values
8179 * here depend on the type of component being executed by the Intent,
8180 * specifically the FLAG_ACTIVITY_* flags are all for use with
8181 * {@link Context#startActivity Context.startActivity()} and the
8182 * FLAG_RECEIVER_* flags are all for use with
8183 * {@link Context#sendBroadcast(Intent) Context.sendBroadcast()}.
8184 *
Scott Main7aee61f2011-02-08 11:25:01 -08008185 * <p>See the
8186 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
8187 * Stack</a> documentation for important information on how some of these options impact
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008188 * the behavior of your application.
8189 *
8190 * @param flags The desired flags.
8191 *
8192 * @return Returns the same Intent object, for chaining multiple calls
8193 * into a single statement.
8194 *
8195 * @see #getFlags
8196 * @see #addFlags
Jeff Sharkey6a34e562016-12-21 09:56:00 -07008197 * @see #removeFlags
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008198 *
8199 * @see #FLAG_GRANT_READ_URI_PERMISSION
8200 * @see #FLAG_GRANT_WRITE_URI_PERMISSION
Jeff Sharkey846318a2014-04-04 12:12:41 -07008201 * @see #FLAG_GRANT_PERSISTABLE_URI_PERMISSION
8202 * @see #FLAG_GRANT_PREFIX_URI_PERMISSION
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008203 * @see #FLAG_DEBUG_LOG_RESOLUTION
8204 * @see #FLAG_FROM_BACKGROUND
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008205 * @see #FLAG_ACTIVITY_BROUGHT_TO_FRONT
Dianne Hackborn621e17d2010-11-22 15:59:56 -08008206 * @see #FLAG_ACTIVITY_CLEAR_TASK
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008207 * @see #FLAG_ACTIVITY_CLEAR_TOP
Dianne Hackborn621e17d2010-11-22 15:59:56 -08008208 * @see #FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008209 * @see #FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS
8210 * @see #FLAG_ACTIVITY_FORWARD_RESULT
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08008211 * @see #FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008212 * @see #FLAG_ACTIVITY_MULTIPLE_TASK
Craig Mautnerd00f4742014-03-12 14:17:26 -07008213 * @see #FLAG_ACTIVITY_NEW_DOCUMENT
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008214 * @see #FLAG_ACTIVITY_NEW_TASK
Dianne Hackborn621e17d2010-11-22 15:59:56 -08008215 * @see #FLAG_ACTIVITY_NO_ANIMATION
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008216 * @see #FLAG_ACTIVITY_NO_HISTORY
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08008217 * @see #FLAG_ACTIVITY_NO_USER_ACTION
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08008218 * @see #FLAG_ACTIVITY_PREVIOUS_IS_TOP
8219 * @see #FLAG_ACTIVITY_RESET_TASK_IF_NEEDED
Dianne Hackborn621e17d2010-11-22 15:59:56 -08008220 * @see #FLAG_ACTIVITY_REORDER_TO_FRONT
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008221 * @see #FLAG_ACTIVITY_SINGLE_TOP
Dianne Hackborn621e17d2010-11-22 15:59:56 -08008222 * @see #FLAG_ACTIVITY_TASK_ON_HOME
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008223 * @see #FLAG_RECEIVER_REGISTERED_ONLY
8224 */
8225 public Intent setFlags(int flags) {
8226 mFlags = flags;
8227 return this;
8228 }
8229
8230 /**
Jeff Sharkey6a34e562016-12-21 09:56:00 -07008231 * Add additional flags to the intent (or with existing flags value).
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008232 *
8233 * @param flags The new flags to set.
Jeff Sharkey6a34e562016-12-21 09:56:00 -07008234 * @return Returns the same Intent object, for chaining multiple calls into
8235 * a single statement.
8236 * @see #setFlags(int)
8237 * @see #removeFlags(int)
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008238 */
8239 public Intent addFlags(int flags) {
8240 mFlags |= flags;
8241 return this;
8242 }
8243
8244 /**
Jeff Sharkey6a34e562016-12-21 09:56:00 -07008245 * Remove these flags from the intent.
8246 *
8247 * @param flags The flags to remove.
8248 * @see #setFlags(int)
8249 * @see #addFlags(int)
8250 */
8251 public void removeFlags(int flags) {
8252 mFlags &= ~flags;
8253 }
8254
8255 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008256 * (Usually optional) Set an explicit application package name that limits
8257 * the components this Intent will resolve to. If left to the default
8258 * value of null, all components in all applications will considered.
8259 * If non-null, the Intent can only match the components in the given
8260 * application package.
8261 *
8262 * @param packageName The name of the application package to handle the
8263 * intent, or null to allow any application package.
8264 *
8265 * @return Returns the same Intent object, for chaining multiple calls
8266 * into a single statement.
8267 *
8268 * @see #getPackage
8269 * @see #resolveActivity
8270 */
8271 public Intent setPackage(String packageName) {
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008272 if (packageName != null && mSelector != null) {
8273 throw new IllegalArgumentException(
8274 "Can't set package name when selector is already set");
8275 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008276 mPackage = packageName;
8277 return this;
8278 }
8279
8280 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008281 * (Usually optional) Explicitly set the component to handle the intent.
8282 * If left with the default value of null, the system will determine the
8283 * appropriate class to use based on the other fields (action, data,
8284 * type, categories) in the Intent. If this class is defined, the
8285 * specified class will always be used regardless of the other fields. You
8286 * should only set this value when you know you absolutely want a specific
8287 * class to be used; otherwise it is better to let the system find the
8288 * appropriate class so that you will respect the installed applications
8289 * and user preferences.
8290 *
8291 * @param component The name of the application component to handle the
8292 * intent, or null to let the system find one for you.
8293 *
8294 * @return Returns the same Intent object, for chaining multiple calls
8295 * into a single statement.
8296 *
8297 * @see #setClass
8298 * @see #setClassName(Context, String)
8299 * @see #setClassName(String, String)
8300 * @see #getComponent
8301 * @see #resolveActivity
8302 */
8303 public Intent setComponent(ComponentName component) {
8304 mComponent = component;
8305 return this;
8306 }
8307
8308 /**
8309 * Convenience for calling {@link #setComponent} with an
8310 * explicit class name.
8311 *
8312 * @param packageContext A Context of the application package implementing
8313 * this class.
8314 * @param className The name of a class inside of the application package
8315 * that will be used as the component for this Intent.
8316 *
8317 * @return Returns the same Intent object, for chaining multiple calls
8318 * into a single statement.
8319 *
8320 * @see #setComponent
8321 * @see #setClass
8322 */
8323 public Intent setClassName(Context packageContext, String className) {
8324 mComponent = new ComponentName(packageContext, className);
8325 return this;
8326 }
8327
8328 /**
8329 * Convenience for calling {@link #setComponent} with an
8330 * explicit application package name and class name.
8331 *
8332 * @param packageName The name of the package implementing the desired
8333 * component.
8334 * @param className The name of a class inside of the application package
8335 * that will be used as the component for this Intent.
8336 *
8337 * @return Returns the same Intent object, for chaining multiple calls
8338 * into a single statement.
8339 *
8340 * @see #setComponent
8341 * @see #setClass
8342 */
8343 public Intent setClassName(String packageName, String className) {
8344 mComponent = new ComponentName(packageName, className);
8345 return this;
8346 }
8347
8348 /**
8349 * Convenience for calling {@link #setComponent(ComponentName)} with the
8350 * name returned by a {@link Class} object.
8351 *
8352 * @param packageContext A Context of the application package implementing
8353 * this class.
8354 * @param cls The class name to set, equivalent to
8355 * <code>setClassName(context, cls.getName())</code>.
8356 *
8357 * @return Returns the same Intent object, for chaining multiple calls
8358 * into a single statement.
8359 *
8360 * @see #setComponent
8361 */
8362 public Intent setClass(Context packageContext, Class<?> cls) {
8363 mComponent = new ComponentName(packageContext, cls);
8364 return this;
8365 }
8366
8367 /**
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08008368 * Set the bounds of the sender of this intent, in screen coordinates. This can be
8369 * used as a hint to the receiver for animations and the like. Null means that there
8370 * is no source bounds.
8371 */
8372 public void setSourceBounds(Rect r) {
8373 if (r != null) {
8374 mSourceBounds = new Rect(r);
8375 } else {
Daniel Lehmanna5b58df2011-10-12 16:24:22 -07008376 mSourceBounds = null;
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08008377 }
8378 }
8379
Tor Norbyed9273d62013-05-30 15:59:53 -07008380 /** @hide */
8381 @IntDef(flag = true,
8382 value = {
8383 FILL_IN_ACTION,
8384 FILL_IN_DATA,
8385 FILL_IN_CATEGORIES,
8386 FILL_IN_COMPONENT,
8387 FILL_IN_PACKAGE,
8388 FILL_IN_SOURCE_BOUNDS,
8389 FILL_IN_SELECTOR,
8390 FILL_IN_CLIP_DATA
8391 })
8392 @Retention(RetentionPolicy.SOURCE)
8393 public @interface FillInFlags {}
8394
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08008395 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008396 * Use with {@link #fillIn} to allow the current action value to be
8397 * overwritten, even if it is already set.
8398 */
8399 public static final int FILL_IN_ACTION = 1<<0;
8400
8401 /**
8402 * Use with {@link #fillIn} to allow the current data or type value
8403 * overwritten, even if it is already set.
8404 */
8405 public static final int FILL_IN_DATA = 1<<1;
8406
8407 /**
8408 * Use with {@link #fillIn} to allow the current categories to be
8409 * overwritten, even if they are already set.
8410 */
8411 public static final int FILL_IN_CATEGORIES = 1<<2;
8412
8413 /**
8414 * Use with {@link #fillIn} to allow the current component value to be
8415 * overwritten, even if it is already set.
8416 */
8417 public static final int FILL_IN_COMPONENT = 1<<3;
8418
8419 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008420 * Use with {@link #fillIn} to allow the current package value to be
8421 * overwritten, even if it is already set.
8422 */
8423 public static final int FILL_IN_PACKAGE = 1<<4;
8424
8425 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008426 * Use with {@link #fillIn} to allow the current bounds rectangle to be
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08008427 * overwritten, even if it is already set.
8428 */
8429 public static final int FILL_IN_SOURCE_BOUNDS = 1<<5;
8430
8431 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008432 * Use with {@link #fillIn} to allow the current selector to be
8433 * overwritten, even if it is already set.
8434 */
8435 public static final int FILL_IN_SELECTOR = 1<<6;
8436
8437 /**
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008438 * Use with {@link #fillIn} to allow the current ClipData to be
8439 * overwritten, even if it is already set.
8440 */
8441 public static final int FILL_IN_CLIP_DATA = 1<<7;
8442
8443 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008444 * Copy the contents of <var>other</var> in to this object, but only
8445 * where fields are not defined by this object. For purposes of a field
8446 * being defined, the following pieces of data in the Intent are
8447 * considered to be separate fields:
8448 *
8449 * <ul>
8450 * <li> action, as set by {@link #setAction}.
Nick Pellyccae4122012-01-09 14:12:58 -08008451 * <li> data Uri and MIME type, as set by {@link #setData(Uri)},
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008452 * {@link #setType(String)}, or {@link #setDataAndType(Uri, String)}.
8453 * <li> categories, as set by {@link #addCategory}.
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008454 * <li> package, as set by {@link #setPackage}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008455 * <li> component, as set by {@link #setComponent(ComponentName)} or
8456 * related methods.
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008457 * <li> source bounds, as set by {@link #setSourceBounds}.
8458 * <li> selector, as set by {@link #setSelector(Intent)}.
8459 * <li> clip data, as set by {@link #setClipData(ClipData)}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008460 * <li> each top-level name in the associated extras.
8461 * </ul>
8462 *
8463 * <p>In addition, you can use the {@link #FILL_IN_ACTION},
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008464 * {@link #FILL_IN_DATA}, {@link #FILL_IN_CATEGORIES}, {@link #FILL_IN_PACKAGE},
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008465 * {@link #FILL_IN_COMPONENT}, {@link #FILL_IN_SOURCE_BOUNDS},
8466 * {@link #FILL_IN_SELECTOR}, and {@link #FILL_IN_CLIP_DATA} to override
8467 * the restriction where the corresponding field will not be replaced if
8468 * it is already set.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008469 *
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008470 * <p>Note: The component field will only be copied if {@link #FILL_IN_COMPONENT}
8471 * is explicitly specified. The selector will only be copied if
8472 * {@link #FILL_IN_SELECTOR} is explicitly specified.
Brett Chabot3e391752009-07-21 16:07:23 -07008473 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008474 * <p>For example, consider Intent A with {data="foo", categories="bar"}
8475 * and Intent B with {action="gotit", data-type="some/thing",
8476 * categories="one","two"}.
8477 *
8478 * <p>Calling A.fillIn(B, Intent.FILL_IN_DATA) will result in A now
8479 * containing: {action="gotit", data-type="some/thing",
8480 * categories="bar"}.
8481 *
8482 * @param other Another Intent whose values are to be used to fill in
8483 * the current one.
8484 * @param flags Options to control which fields can be filled in.
8485 *
8486 * @return Returns a bit mask of {@link #FILL_IN_ACTION},
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008487 * {@link #FILL_IN_DATA}, {@link #FILL_IN_CATEGORIES}, {@link #FILL_IN_PACKAGE},
Tor Norbyed9273d62013-05-30 15:59:53 -07008488 * {@link #FILL_IN_COMPONENT}, {@link #FILL_IN_SOURCE_BOUNDS},
Elliot Waite54de7742017-01-11 15:30:35 -08008489 * {@link #FILL_IN_SELECTOR} and {@link #FILL_IN_CLIP_DATA} indicating which fields were
Tor Norbyed9273d62013-05-30 15:59:53 -07008490 * changed.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008491 */
Tor Norbyed9273d62013-05-30 15:59:53 -07008492 @FillInFlags
8493 public int fillIn(Intent other, @FillInFlags int flags) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008494 int changes = 0;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008495 boolean mayHaveCopiedUris = false;
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008496 if (other.mAction != null
8497 && (mAction == null || (flags&FILL_IN_ACTION) != 0)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008498 mAction = other.mAction;
8499 changes |= FILL_IN_ACTION;
8500 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008501 if ((other.mData != null || other.mType != null)
8502 && ((mData == null && mType == null)
8503 || (flags&FILL_IN_DATA) != 0)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008504 mData = other.mData;
8505 mType = other.mType;
8506 changes |= FILL_IN_DATA;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008507 mayHaveCopiedUris = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008508 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008509 if (other.mCategories != null
8510 && (mCategories == null || (flags&FILL_IN_CATEGORIES) != 0)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008511 if (other.mCategories != null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07008512 mCategories = new ArraySet<String>(other.mCategories);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008513 }
8514 changes |= FILL_IN_CATEGORIES;
8515 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008516 if (other.mPackage != null
8517 && (mPackage == null || (flags&FILL_IN_PACKAGE) != 0)) {
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008518 // Only do this if mSelector is not set.
8519 if (mSelector == null) {
8520 mPackage = other.mPackage;
8521 changes |= FILL_IN_PACKAGE;
8522 }
8523 }
8524 // Selector is special: it can only be set if explicitly allowed,
8525 // for the same reason as the component name.
8526 if (other.mSelector != null && (flags&FILL_IN_SELECTOR) != 0) {
8527 if (mPackage == null) {
8528 mSelector = new Intent(other.mSelector);
8529 mPackage = null;
8530 changes |= FILL_IN_SELECTOR;
8531 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008532 }
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008533 if (other.mClipData != null
8534 && (mClipData == null || (flags&FILL_IN_CLIP_DATA) != 0)) {
8535 mClipData = other.mClipData;
8536 changes |= FILL_IN_CLIP_DATA;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008537 mayHaveCopiedUris = true;
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008538 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008539 // Component is special: it can -only- be set if explicitly allowed,
8540 // since otherwise the sender could force the intent somewhere the
8541 // originator didn't intend.
8542 if (other.mComponent != null && (flags&FILL_IN_COMPONENT) != 0) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008543 mComponent = other.mComponent;
8544 changes |= FILL_IN_COMPONENT;
8545 }
8546 mFlags |= other.mFlags;
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08008547 if (other.mSourceBounds != null
8548 && (mSourceBounds == null || (flags&FILL_IN_SOURCE_BOUNDS) != 0)) {
8549 mSourceBounds = new Rect(other.mSourceBounds);
8550 changes |= FILL_IN_SOURCE_BOUNDS;
8551 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008552 if (mExtras == null) {
8553 if (other.mExtras != null) {
8554 mExtras = new Bundle(other.mExtras);
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008555 mayHaveCopiedUris = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008556 }
8557 } else if (other.mExtras != null) {
8558 try {
8559 Bundle newb = new Bundle(other.mExtras);
8560 newb.putAll(mExtras);
8561 mExtras = newb;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008562 mayHaveCopiedUris = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008563 } catch (RuntimeException e) {
8564 // Modifying the extras can cause us to unparcel the contents
8565 // of the bundle, and if we do this in the system process that
8566 // may fail. We really should handle this (i.e., the Bundle
8567 // impl shouldn't be on top of a plain map), but for now just
8568 // ignore it and keep the original contents. :(
8569 Log.w("Intent", "Failure filling in extras", e);
8570 }
8571 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008572 if (mayHaveCopiedUris && mContentUserHint == UserHandle.USER_CURRENT
8573 && other.mContentUserHint != UserHandle.USER_CURRENT) {
8574 mContentUserHint = other.mContentUserHint;
8575 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008576 return changes;
8577 }
8578
8579 /**
8580 * Wrapper class holding an Intent and implementing comparisons on it for
8581 * the purpose of filtering. The class implements its
8582 * {@link #equals equals()} and {@link #hashCode hashCode()} methods as
8583 * simple calls to {@link Intent#filterEquals(Intent)} filterEquals()} and
8584 * {@link android.content.Intent#filterHashCode()} filterHashCode()}
8585 * on the wrapped Intent.
8586 */
8587 public static final class FilterComparison {
8588 private final Intent mIntent;
8589 private final int mHashCode;
8590
8591 public FilterComparison(Intent intent) {
8592 mIntent = intent;
8593 mHashCode = intent.filterHashCode();
8594 }
8595
8596 /**
8597 * Return the Intent that this FilterComparison represents.
8598 * @return Returns the Intent held by the FilterComparison. Do
8599 * not modify!
8600 */
8601 public Intent getIntent() {
8602 return mIntent;
8603 }
8604
8605 @Override
8606 public boolean equals(Object obj) {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08008607 if (obj instanceof FilterComparison) {
8608 Intent other = ((FilterComparison)obj).mIntent;
8609 return mIntent.filterEquals(other);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008610 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08008611 return false;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008612 }
8613
8614 @Override
8615 public int hashCode() {
8616 return mHashCode;
8617 }
8618 }
8619
8620 /**
8621 * Determine if two intents are the same for the purposes of intent
8622 * resolution (filtering). That is, if their action, data, type,
8623 * class, and categories are the same. This does <em>not</em> compare
8624 * any extra data included in the intents.
8625 *
8626 * @param other The other Intent to compare against.
8627 *
8628 * @return Returns true if action, data, type, class, and categories
8629 * are the same.
8630 */
8631 public boolean filterEquals(Intent other) {
8632 if (other == null) {
8633 return false;
8634 }
Christopher Tate63d9ae12014-06-19 19:07:26 -07008635 if (!Objects.equals(this.mAction, other.mAction)) return false;
8636 if (!Objects.equals(this.mData, other.mData)) return false;
8637 if (!Objects.equals(this.mType, other.mType)) return false;
8638 if (!Objects.equals(this.mPackage, other.mPackage)) return false;
8639 if (!Objects.equals(this.mComponent, other.mComponent)) return false;
8640 if (!Objects.equals(this.mCategories, other.mCategories)) return false;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008641
8642 return true;
8643 }
8644
8645 /**
8646 * Generate hash code that matches semantics of filterEquals().
8647 *
8648 * @return Returns the hash value of the action, data, type, class, and
8649 * categories.
8650 *
8651 * @see #filterEquals
8652 */
8653 public int filterHashCode() {
8654 int code = 0;
8655 if (mAction != null) {
8656 code += mAction.hashCode();
8657 }
8658 if (mData != null) {
8659 code += mData.hashCode();
8660 }
8661 if (mType != null) {
8662 code += mType.hashCode();
8663 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008664 if (mPackage != null) {
8665 code += mPackage.hashCode();
8666 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008667 if (mComponent != null) {
8668 code += mComponent.hashCode();
8669 }
8670 if (mCategories != null) {
8671 code += mCategories.hashCode();
8672 }
8673 return code;
8674 }
8675
8676 @Override
8677 public String toString() {
Dianne Hackborn90c52de2011-09-23 12:57:44 -07008678 StringBuilder b = new StringBuilder(128);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008679
Dianne Hackborn1d442e02009-04-20 18:14:05 -07008680 b.append("Intent { ");
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008681 toShortString(b, true, true, true, false);
Dianne Hackborn1d442e02009-04-20 18:14:05 -07008682 b.append(" }");
8683
8684 return b.toString();
8685 }
8686
8687 /** @hide */
Dianne Hackborn90c52de2011-09-23 12:57:44 -07008688 public String toInsecureString() {
8689 StringBuilder b = new StringBuilder(128);
8690
8691 b.append("Intent { ");
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008692 toShortString(b, false, true, true, false);
Dianne Hackborn90c52de2011-09-23 12:57:44 -07008693 b.append(" }");
8694
Dianne Hackborn1d442e02009-04-20 18:14:05 -07008695 return b.toString();
8696 }
Romain Guy4969af72009-06-17 10:53:19 -07008697
Dianne Hackborn1d442e02009-04-20 18:14:05 -07008698 /** @hide */
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008699 public String toInsecureStringWithClip() {
Dianne Hackborn90c52de2011-09-23 12:57:44 -07008700 StringBuilder b = new StringBuilder(128);
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008701
8702 b.append("Intent { ");
8703 toShortString(b, false, true, true, true);
8704 b.append(" }");
8705
Dianne Hackborn90c52de2011-09-23 12:57:44 -07008706 return b.toString();
8707 }
8708
8709 /** @hide */
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008710 public String toShortString(boolean secure, boolean comp, boolean extras, boolean clip) {
8711 StringBuilder b = new StringBuilder(128);
8712 toShortString(b, secure, comp, extras, clip);
8713 return b.toString();
8714 }
8715
8716 /** @hide */
8717 public void toShortString(StringBuilder b, boolean secure, boolean comp, boolean extras,
8718 boolean clip) {
Dianne Hackborn1d442e02009-04-20 18:14:05 -07008719 boolean first = true;
8720 if (mAction != null) {
8721 b.append("act=").append(mAction);
8722 first = false;
8723 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008724 if (mCategories != null) {
Dianne Hackborn1d442e02009-04-20 18:14:05 -07008725 if (!first) {
8726 b.append(' ');
8727 }
8728 first = false;
8729 b.append("cat=[");
Dianne Hackbornadd005c2013-07-17 18:43:12 -07008730 for (int i=0; i<mCategories.size(); i++) {
8731 if (i > 0) b.append(',');
8732 b.append(mCategories.valueAt(i));
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008733 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07008734 b.append("]");
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008735 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07008736 if (mData != null) {
8737 if (!first) {
8738 b.append(' ');
8739 }
8740 first = false;
Wink Savillea4288072010-10-12 12:36:38 -07008741 b.append("dat=");
Dianne Hackborn90c52de2011-09-23 12:57:44 -07008742 if (secure) {
8743 b.append(mData.toSafeString());
Wink Savillea4288072010-10-12 12:36:38 -07008744 } else {
8745 b.append(mData);
8746 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07008747 }
8748 if (mType != null) {
8749 if (!first) {
8750 b.append(' ');
8751 }
8752 first = false;
8753 b.append("typ=").append(mType);
8754 }
8755 if (mFlags != 0) {
8756 if (!first) {
8757 b.append(' ');
8758 }
8759 first = false;
8760 b.append("flg=0x").append(Integer.toHexString(mFlags));
8761 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008762 if (mPackage != null) {
8763 if (!first) {
8764 b.append(' ');
8765 }
8766 first = false;
8767 b.append("pkg=").append(mPackage);
8768 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07008769 if (comp && mComponent != null) {
8770 if (!first) {
8771 b.append(' ');
8772 }
8773 first = false;
8774 b.append("cmp=").append(mComponent.flattenToShortString());
8775 }
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08008776 if (mSourceBounds != null) {
8777 if (!first) {
8778 b.append(' ');
8779 }
8780 first = false;
8781 b.append("bnds=").append(mSourceBounds.toShortString());
8782 }
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008783 if (mClipData != null) {
8784 if (!first) {
8785 b.append(' ');
8786 }
Dianne Hackbornae498722015-08-14 13:29:47 -07008787 b.append("clip={");
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008788 if (clip) {
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008789 mClipData.toShortString(b);
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008790 } else {
Dianne Hackbornae498722015-08-14 13:29:47 -07008791 if (mClipData.getDescription() != null) {
8792 first = !mClipData.getDescription().toShortStringTypesOnly(b);
8793 } else {
8794 first = true;
8795 }
8796 mClipData.toShortStringShortItems(b, first);
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008797 }
Dianne Hackbornae498722015-08-14 13:29:47 -07008798 first = false;
8799 b.append('}');
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008800 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07008801 if (extras && mExtras != null) {
8802 if (!first) {
8803 b.append(' ');
8804 }
8805 first = false;
8806 b.append("(has extras)");
8807 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008808 if (mContentUserHint != UserHandle.USER_CURRENT) {
8809 if (!first) {
8810 b.append(' ');
8811 }
8812 first = false;
8813 b.append("u=").append(mContentUserHint);
8814 }
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008815 if (mSelector != null) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008816 b.append(" sel=");
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008817 mSelector.toShortString(b, secure, comp, extras, clip);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008818 b.append("}");
8819 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008820 }
8821
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008822 /**
8823 * Call {@link #toUri} with 0 flags.
8824 * @deprecated Use {@link #toUri} instead.
8825 */
8826 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008827 public String toURI() {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008828 return toUri(0);
8829 }
8830
8831 /**
8832 * Convert this Intent into a String holding a URI representation of it.
8833 * The returned URI string has been properly URI encoded, so it can be
8834 * used with {@link Uri#parse Uri.parse(String)}. The URI contains the
8835 * Intent's data as the base URI, with an additional fragment describing
8836 * the action, categories, type, flags, package, component, and extras.
Tom Taylord4a47292009-12-21 13:59:18 -08008837 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008838 * <p>You can convert the returned string back to an Intent with
8839 * {@link #getIntent}.
Tom Taylord4a47292009-12-21 13:59:18 -08008840 *
Dianne Hackborn85d558c2014-11-04 10:31:54 -08008841 * @param flags Additional operating flags. Either 0,
8842 * {@link #URI_INTENT_SCHEME}, or {@link #URI_ANDROID_APP_SCHEME}.
Tom Taylord4a47292009-12-21 13:59:18 -08008843 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008844 * @return Returns a URI encoding URI string describing the entire contents
8845 * of the Intent.
8846 */
8847 public String toUri(int flags) {
Dianne Hackborn1d442e02009-04-20 18:14:05 -07008848 StringBuilder uri = new StringBuilder(128);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08008849 if ((flags&URI_ANDROID_APP_SCHEME) != 0) {
8850 if (mPackage == null) {
8851 throw new IllegalArgumentException(
8852 "Intent must include an explicit package name to build an android-app: "
8853 + this);
8854 }
8855 uri.append("android-app://");
8856 uri.append(mPackage);
8857 String scheme = null;
8858 if (mData != null) {
8859 scheme = mData.getScheme();
8860 if (scheme != null) {
8861 uri.append('/');
8862 uri.append(scheme);
8863 String authority = mData.getEncodedAuthority();
8864 if (authority != null) {
8865 uri.append('/');
8866 uri.append(authority);
8867 String path = mData.getEncodedPath();
8868 if (path != null) {
8869 uri.append(path);
8870 }
8871 String queryParams = mData.getEncodedQuery();
8872 if (queryParams != null) {
8873 uri.append('?');
8874 uri.append(queryParams);
8875 }
8876 String fragment = mData.getEncodedFragment();
8877 if (fragment != null) {
8878 uri.append('#');
8879 uri.append(fragment);
8880 }
8881 }
8882 }
8883 }
8884 toUriFragment(uri, null, scheme == null ? Intent.ACTION_MAIN : Intent.ACTION_VIEW,
8885 mPackage, flags);
8886 return uri.toString();
8887 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008888 String scheme = null;
8889 if (mData != null) {
8890 String data = mData.toString();
8891 if ((flags&URI_INTENT_SCHEME) != 0) {
8892 final int N = data.length();
8893 for (int i=0; i<N; i++) {
8894 char c = data.charAt(i);
8895 if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')
8896 || c == '.' || c == '-') {
8897 continue;
8898 }
8899 if (c == ':' && i > 0) {
8900 // Valid scheme.
8901 scheme = data.substring(0, i);
8902 uri.append("intent:");
8903 data = data.substring(i+1);
8904 break;
8905 }
Tom Taylord4a47292009-12-21 13:59:18 -08008906
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008907 // No scheme.
8908 break;
8909 }
8910 }
8911 uri.append(data);
Tom Taylord4a47292009-12-21 13:59:18 -08008912
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008913 } else if ((flags&URI_INTENT_SCHEME) != 0) {
8914 uri.append("intent:");
8915 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008916
Dianne Hackborn85d558c2014-11-04 10:31:54 -08008917 toUriFragment(uri, scheme, Intent.ACTION_VIEW, null, flags);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008918
Dianne Hackborn85d558c2014-11-04 10:31:54 -08008919 return uri.toString();
8920 }
8921
8922 private void toUriFragment(StringBuilder uri, String scheme, String defAction,
8923 String defPackage, int flags) {
8924 StringBuilder frag = new StringBuilder(128);
8925
8926 toUriInner(frag, scheme, defAction, defPackage, flags);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008927 if (mSelector != null) {
Dianne Hackborn80b1c562014-12-09 20:22:08 -08008928 frag.append("SEL;");
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008929 // Note that for now we are not going to try to handle the
8930 // data part; not clear how to represent this as a URI, and
8931 // not much utility in it.
Dianne Hackborn85d558c2014-11-04 10:31:54 -08008932 mSelector.toUriInner(frag, mSelector.mData != null ? mSelector.mData.getScheme() : null,
8933 null, null, flags);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008934 }
8935
Dianne Hackborn85d558c2014-11-04 10:31:54 -08008936 if (frag.length() > 0) {
8937 uri.append("#Intent;");
8938 uri.append(frag);
8939 uri.append("end");
8940 }
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008941 }
8942
Dianne Hackborn85d558c2014-11-04 10:31:54 -08008943 private void toUriInner(StringBuilder uri, String scheme, String defAction,
8944 String defPackage, int flags) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008945 if (scheme != null) {
8946 uri.append("scheme=").append(scheme).append(';');
8947 }
Dianne Hackborn85d558c2014-11-04 10:31:54 -08008948 if (mAction != null && !mAction.equals(defAction)) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008949 uri.append("action=").append(Uri.encode(mAction)).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008950 }
8951 if (mCategories != null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07008952 for (int i=0; i<mCategories.size(); i++) {
8953 uri.append("category=").append(Uri.encode(mCategories.valueAt(i))).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008954 }
8955 }
8956 if (mType != null) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008957 uri.append("type=").append(Uri.encode(mType, "/")).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008958 }
8959 if (mFlags != 0) {
8960 uri.append("launchFlags=0x").append(Integer.toHexString(mFlags)).append(';');
8961 }
Dianne Hackborn85d558c2014-11-04 10:31:54 -08008962 if (mPackage != null && !mPackage.equals(defPackage)) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008963 uri.append("package=").append(Uri.encode(mPackage)).append(';');
8964 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008965 if (mComponent != null) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008966 uri.append("component=").append(Uri.encode(
8967 mComponent.flattenToShortString(), "/")).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008968 }
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08008969 if (mSourceBounds != null) {
8970 uri.append("sourceBounds=")
8971 .append(Uri.encode(mSourceBounds.flattenToString()))
8972 .append(';');
8973 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008974 if (mExtras != null) {
8975 for (String key : mExtras.keySet()) {
8976 final Object value = mExtras.get(key);
8977 char entryType =
8978 value instanceof String ? 'S' :
8979 value instanceof Boolean ? 'B' :
8980 value instanceof Byte ? 'b' :
8981 value instanceof Character ? 'c' :
8982 value instanceof Double ? 'd' :
8983 value instanceof Float ? 'f' :
8984 value instanceof Integer ? 'i' :
8985 value instanceof Long ? 'l' :
8986 value instanceof Short ? 's' :
8987 '\0';
8988
8989 if (entryType != '\0') {
8990 uri.append(entryType);
8991 uri.append('.');
8992 uri.append(Uri.encode(key));
8993 uri.append('=');
8994 uri.append(Uri.encode(value.toString()));
8995 uri.append(';');
8996 }
8997 }
8998 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008999 }
The Android Open Source Project10592532009-03-18 17:39:46 -07009000
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009001 public int describeContents() {
9002 return (mExtras != null) ? mExtras.describeContents() : 0;
9003 }
9004
9005 public void writeToParcel(Parcel out, int flags) {
9006 out.writeString(mAction);
9007 Uri.writeToParcel(out, mData);
9008 out.writeString(mType);
9009 out.writeInt(mFlags);
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009010 out.writeString(mPackage);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009011 ComponentName.writeToParcel(mComponent, out);
9012
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08009013 if (mSourceBounds != null) {
9014 out.writeInt(1);
9015 mSourceBounds.writeToParcel(out, flags);
9016 } else {
9017 out.writeInt(0);
9018 }
9019
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009020 if (mCategories != null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07009021 final int N = mCategories.size();
9022 out.writeInt(N);
9023 for (int i=0; i<N; i++) {
9024 out.writeString(mCategories.valueAt(i));
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009025 }
9026 } else {
9027 out.writeInt(0);
9028 }
9029
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009030 if (mSelector != null) {
9031 out.writeInt(1);
9032 mSelector.writeToParcel(out, flags);
9033 } else {
9034 out.writeInt(0);
9035 }
9036
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009037 if (mClipData != null) {
9038 out.writeInt(1);
9039 mClipData.writeToParcel(out, flags);
9040 } else {
9041 out.writeInt(0);
9042 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009043 out.writeInt(mContentUserHint);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009044 out.writeBundle(mExtras);
9045 }
9046
9047 public static final Parcelable.Creator<Intent> CREATOR
9048 = new Parcelable.Creator<Intent>() {
9049 public Intent createFromParcel(Parcel in) {
9050 return new Intent(in);
9051 }
9052 public Intent[] newArray(int size) {
9053 return new Intent[size];
9054 }
9055 };
9056
Dianne Hackborneb034652009-09-07 00:49:58 -07009057 /** @hide */
9058 protected Intent(Parcel in) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009059 readFromParcel(in);
9060 }
9061
9062 public void readFromParcel(Parcel in) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08009063 setAction(in.readString());
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009064 mData = Uri.CREATOR.createFromParcel(in);
9065 mType = in.readString();
9066 mFlags = in.readInt();
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009067 mPackage = in.readString();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009068 mComponent = ComponentName.readFromParcel(in);
9069
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08009070 if (in.readInt() != 0) {
9071 mSourceBounds = Rect.CREATOR.createFromParcel(in);
9072 }
9073
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009074 int N = in.readInt();
9075 if (N > 0) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07009076 mCategories = new ArraySet<String>();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009077 int i;
9078 for (i=0; i<N; i++) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08009079 mCategories.add(in.readString().intern());
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009080 }
9081 } else {
9082 mCategories = null;
9083 }
9084
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009085 if (in.readInt() != 0) {
9086 mSelector = new Intent(in);
9087 }
9088
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009089 if (in.readInt() != 0) {
9090 mClipData = new ClipData(in);
9091 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009092 mContentUserHint = in.readInt();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009093 mExtras = in.readBundle();
9094 }
9095
9096 /**
9097 * Parses the "intent" element (and its children) from XML and instantiates
9098 * an Intent object. The given XML parser should be located at the tag
9099 * where parsing should start (often named "intent"), from which the
9100 * basic action, data, type, and package and class name will be
9101 * retrieved. The function will then parse in to any child elements,
9102 * looking for <category android:name="xxx"> tags to add categories and
9103 * <extra android:name="xxx" android:value="yyy"> to attach extra data
9104 * to the intent.
9105 *
9106 * @param resources The Resources to use when inflating resources.
9107 * @param parser The XML parser pointing at an "intent" tag.
9108 * @param attrs The AttributeSet interface for retrieving extended
9109 * attribute data at the current <var>parser</var> location.
9110 * @return An Intent object matching the XML data.
9111 * @throws XmlPullParserException If there was an XML parsing error.
9112 * @throws IOException If there was an I/O error.
9113 */
9114 public static Intent parseIntent(Resources resources, XmlPullParser parser, AttributeSet attrs)
9115 throws XmlPullParserException, IOException {
9116 Intent intent = new Intent();
9117
9118 TypedArray sa = resources.obtainAttributes(attrs,
9119 com.android.internal.R.styleable.Intent);
9120
9121 intent.setAction(sa.getString(com.android.internal.R.styleable.Intent_action));
9122
9123 String data = sa.getString(com.android.internal.R.styleable.Intent_data);
9124 String mimeType = sa.getString(com.android.internal.R.styleable.Intent_mimeType);
9125 intent.setDataAndType(data != null ? Uri.parse(data) : null, mimeType);
9126
9127 String packageName = sa.getString(com.android.internal.R.styleable.Intent_targetPackage);
9128 String className = sa.getString(com.android.internal.R.styleable.Intent_targetClass);
9129 if (packageName != null && className != null) {
9130 intent.setComponent(new ComponentName(packageName, className));
9131 }
9132
9133 sa.recycle();
9134
9135 int outerDepth = parser.getDepth();
9136 int type;
9137 while ((type=parser.next()) != XmlPullParser.END_DOCUMENT
9138 && (type != XmlPullParser.END_TAG || parser.getDepth() > outerDepth)) {
9139 if (type == XmlPullParser.END_TAG || type == XmlPullParser.TEXT) {
9140 continue;
9141 }
9142
9143 String nodeName = parser.getName();
Craig Mautner21d24a22014-04-23 11:45:37 -07009144 if (nodeName.equals(TAG_CATEGORIES)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009145 sa = resources.obtainAttributes(attrs,
9146 com.android.internal.R.styleable.IntentCategory);
9147 String cat = sa.getString(com.android.internal.R.styleable.IntentCategory_name);
9148 sa.recycle();
9149
9150 if (cat != null) {
9151 intent.addCategory(cat);
9152 }
9153 XmlUtils.skipCurrentTag(parser);
9154
Craig Mautner21d24a22014-04-23 11:45:37 -07009155 } else if (nodeName.equals(TAG_EXTRA)) {
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08009156 if (intent.mExtras == null) {
9157 intent.mExtras = new Bundle();
9158 }
Craig Mautner21d24a22014-04-23 11:45:37 -07009159 resources.parseBundleExtra(TAG_EXTRA, attrs, intent.mExtras);
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08009160 XmlUtils.skipCurrentTag(parser);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009161
9162 } else {
9163 XmlUtils.skipCurrentTag(parser);
9164 }
9165 }
9166
9167 return intent;
9168 }
Nick Pellyccae4122012-01-09 14:12:58 -08009169
Craig Mautner21d24a22014-04-23 11:45:37 -07009170 /** @hide */
9171 public void saveToXml(XmlSerializer out) throws IOException {
9172 if (mAction != null) {
9173 out.attribute(null, ATTR_ACTION, mAction);
9174 }
9175 if (mData != null) {
9176 out.attribute(null, ATTR_DATA, mData.toString());
9177 }
9178 if (mType != null) {
9179 out.attribute(null, ATTR_TYPE, mType);
9180 }
9181 if (mComponent != null) {
9182 out.attribute(null, ATTR_COMPONENT, mComponent.flattenToShortString());
9183 }
9184 out.attribute(null, ATTR_FLAGS, Integer.toHexString(getFlags()));
9185
9186 if (mCategories != null) {
9187 out.startTag(null, TAG_CATEGORIES);
9188 for (int categoryNdx = mCategories.size() - 1; categoryNdx >= 0; --categoryNdx) {
9189 out.attribute(null, ATTR_CATEGORY, mCategories.valueAt(categoryNdx));
9190 }
Craig Mautner43e52ed2014-06-16 17:18:52 -07009191 out.endTag(null, TAG_CATEGORIES);
Craig Mautner21d24a22014-04-23 11:45:37 -07009192 }
9193 }
9194
9195 /** @hide */
9196 public static Intent restoreFromXml(XmlPullParser in) throws IOException,
9197 XmlPullParserException {
9198 Intent intent = new Intent();
9199 final int outerDepth = in.getDepth();
9200
9201 int attrCount = in.getAttributeCount();
9202 for (int attrNdx = attrCount - 1; attrNdx >= 0; --attrNdx) {
9203 final String attrName = in.getAttributeName(attrNdx);
9204 final String attrValue = in.getAttributeValue(attrNdx);
9205 if (ATTR_ACTION.equals(attrName)) {
9206 intent.setAction(attrValue);
9207 } else if (ATTR_DATA.equals(attrName)) {
9208 intent.setData(Uri.parse(attrValue));
9209 } else if (ATTR_TYPE.equals(attrName)) {
9210 intent.setType(attrValue);
9211 } else if (ATTR_COMPONENT.equals(attrName)) {
9212 intent.setComponent(ComponentName.unflattenFromString(attrValue));
9213 } else if (ATTR_FLAGS.equals(attrName)) {
Narayan Kamatha09b4d22016-04-15 18:32:45 +01009214 intent.setFlags(Integer.parseInt(attrValue, 16));
Craig Mautner21d24a22014-04-23 11:45:37 -07009215 } else {
9216 Log.e("Intent", "restoreFromXml: unknown attribute=" + attrName);
9217 }
9218 }
9219
9220 int event;
9221 String name;
9222 while (((event = in.next()) != XmlPullParser.END_DOCUMENT) &&
9223 (event != XmlPullParser.END_TAG || in.getDepth() < outerDepth)) {
9224 if (event == XmlPullParser.START_TAG) {
9225 name = in.getName();
9226 if (TAG_CATEGORIES.equals(name)) {
9227 attrCount = in.getAttributeCount();
9228 for (int attrNdx = attrCount - 1; attrNdx >= 0; --attrNdx) {
9229 intent.addCategory(in.getAttributeValue(attrNdx));
9230 }
9231 } else {
9232 Log.w("Intent", "restoreFromXml: unknown name=" + name);
9233 XmlUtils.skipCurrentTag(in);
9234 }
9235 }
9236 }
9237
9238 return intent;
9239 }
9240
Nick Pellyccae4122012-01-09 14:12:58 -08009241 /**
9242 * Normalize a MIME data type.
9243 *
9244 * <p>A normalized MIME type has white-space trimmed,
9245 * content-type parameters removed, and is lower-case.
9246 * This aligns the type with Android best practices for
9247 * intent filtering.
9248 *
9249 * <p>For example, "text/plain; charset=utf-8" becomes "text/plain".
9250 * "text/x-vCard" becomes "text/x-vcard".
9251 *
9252 * <p>All MIME types received from outside Android (such as user input,
9253 * or external sources like Bluetooth, NFC, or the Internet) should
9254 * be normalized before they are used to create an Intent.
9255 *
9256 * @param type MIME data type to normalize
9257 * @return normalized MIME data type, or null if the input was null
John Spurlock125d1332013-11-25 11:58:37 -05009258 * @see #setType
9259 * @see #setTypeAndNormalize
Nick Pellyccae4122012-01-09 14:12:58 -08009260 */
9261 public static String normalizeMimeType(String type) {
9262 if (type == null) {
9263 return null;
9264 }
9265
Elliott Hughescb64d432013-08-02 10:00:44 -07009266 type = type.trim().toLowerCase(Locale.ROOT);
Nick Pellyccae4122012-01-09 14:12:58 -08009267
9268 final int semicolonIndex = type.indexOf(';');
9269 if (semicolonIndex != -1) {
9270 type = type.substring(0, semicolonIndex);
9271 }
9272 return type;
9273 }
Jeff Sharkey678d04f2012-03-23 15:41:58 -07009274
9275 /**
Jeff Sharkeya14acd22013-04-02 18:27:45 -07009276 * Prepare this {@link Intent} to leave an app process.
9277 *
9278 * @hide
9279 */
Jeff Sharkey344744b2016-01-28 19:03:30 -07009280 public void prepareToLeaveProcess(Context context) {
9281 final boolean leavingPackage = (mComponent == null)
9282 || !Objects.equals(mComponent.getPackageName(), context.getPackageName());
9283 prepareToLeaveProcess(leavingPackage);
9284 }
9285
9286 /**
9287 * Prepare this {@link Intent} to leave an app process.
9288 *
9289 * @hide
9290 */
9291 public void prepareToLeaveProcess(boolean leavingPackage) {
Jeff Sharkeya14acd22013-04-02 18:27:45 -07009292 setAllowFds(false);
9293
9294 if (mSelector != null) {
Jeff Sharkey344744b2016-01-28 19:03:30 -07009295 mSelector.prepareToLeaveProcess(leavingPackage);
Jeff Sharkeya14acd22013-04-02 18:27:45 -07009296 }
9297 if (mClipData != null) {
Jeff Sharkeyfb833f32016-12-01 14:59:59 -07009298 mClipData.prepareToLeaveProcess(leavingPackage, getFlags());
Jeff Sharkeya14acd22013-04-02 18:27:45 -07009299 }
9300
Jeff Sharkeyc6fe23d2017-02-24 09:39:58 -07009301 if (mExtras != null && !mExtras.isParcelled()) {
9302 final Object intent = mExtras.get(Intent.EXTRA_INTENT);
9303 if (intent instanceof Intent) {
9304 ((Intent) intent).prepareToLeaveProcess(leavingPackage);
9305 }
9306 }
9307
Jeff Sharkeya8b42782016-01-30 17:58:09 -07009308 if (mAction != null && mData != null && StrictMode.vmFileUriExposureEnabled()
9309 && leavingPackage) {
Jeff Sharkey344744b2016-01-28 19:03:30 -07009310 switch (mAction) {
9311 case ACTION_MEDIA_REMOVED:
9312 case ACTION_MEDIA_UNMOUNTED:
9313 case ACTION_MEDIA_CHECKING:
9314 case ACTION_MEDIA_NOFS:
9315 case ACTION_MEDIA_MOUNTED:
9316 case ACTION_MEDIA_SHARED:
9317 case ACTION_MEDIA_UNSHARED:
9318 case ACTION_MEDIA_BAD_REMOVAL:
9319 case ACTION_MEDIA_UNMOUNTABLE:
9320 case ACTION_MEDIA_EJECT:
9321 case ACTION_MEDIA_SCANNER_STARTED:
9322 case ACTION_MEDIA_SCANNER_FINISHED:
9323 case ACTION_MEDIA_SCANNER_SCAN_FILE:
Jeff Sharkey37355a92016-02-05 16:19:10 -07009324 case ACTION_PACKAGE_NEEDS_VERIFICATION:
9325 case ACTION_PACKAGE_VERIFIED:
Jeff Sharkey344744b2016-01-28 19:03:30 -07009326 // Ignore legacy actions
9327 break;
9328 default:
9329 mData.checkFileUriExposed("Intent.getData()");
Jeff Sharkeya14acd22013-04-02 18:27:45 -07009330 }
9331 }
Jeff Sharkeyfb833f32016-12-01 14:59:59 -07009332
9333 if (mAction != null && mData != null && StrictMode.vmContentUriWithoutPermissionEnabled()
9334 && leavingPackage) {
9335 switch (mAction) {
9336 case ACTION_PROVIDER_CHANGED:
9337 // Ignore actions that don't need to grant
9338 break;
9339 default:
9340 mData.checkContentUriWithoutPermission("Intent.getData()", getFlags());
9341 }
9342 }
Jeff Sharkeya14acd22013-04-02 18:27:45 -07009343 }
9344
9345 /**
Nicolas Prevotd85fc722014-04-16 19:52:08 +01009346 * @hide
9347 */
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009348 public void prepareToEnterProcess() {
Jeff Sharkeyd136e512016-03-09 22:30:56 -07009349 // We just entered destination process, so we should be able to read all
9350 // parcelables inside.
9351 setDefusable(true);
9352
9353 if (mSelector != null) {
9354 mSelector.prepareToEnterProcess();
9355 }
9356 if (mClipData != null) {
9357 mClipData.prepareToEnterProcess();
9358 }
9359
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009360 if (mContentUserHint != UserHandle.USER_CURRENT) {
Nicolas Prevotc4fc00a2014-10-31 12:01:32 +00009361 if (UserHandle.getAppId(Process.myUid()) != Process.SYSTEM_UID) {
9362 fixUris(mContentUserHint);
9363 mContentUserHint = UserHandle.USER_CURRENT;
9364 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009365 }
9366 }
9367
9368 /**
9369 * @hide
9370 */
9371 public void fixUris(int contentUserHint) {
Nicolas Prevotd85fc722014-04-16 19:52:08 +01009372 Uri data = getData();
9373 if (data != null) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009374 mData = maybeAddUserId(data, contentUserHint);
Nicolas Prevotd85fc722014-04-16 19:52:08 +01009375 }
9376 if (mClipData != null) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009377 mClipData.fixUris(contentUserHint);
Nicolas Prevotd85fc722014-04-16 19:52:08 +01009378 }
9379 String action = getAction();
9380 if (ACTION_SEND.equals(action)) {
9381 final Uri stream = getParcelableExtra(EXTRA_STREAM);
9382 if (stream != null) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009383 putExtra(EXTRA_STREAM, maybeAddUserId(stream, contentUserHint));
Nicolas Prevotd85fc722014-04-16 19:52:08 +01009384 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009385 } else if (ACTION_SEND_MULTIPLE.equals(action)) {
Nicolas Prevotd85fc722014-04-16 19:52:08 +01009386 final ArrayList<Uri> streams = getParcelableArrayListExtra(EXTRA_STREAM);
9387 if (streams != null) {
9388 ArrayList<Uri> newStreams = new ArrayList<Uri>();
9389 for (int i = 0; i < streams.size(); i++) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009390 newStreams.add(maybeAddUserId(streams.get(i), contentUserHint));
Nicolas Prevotd85fc722014-04-16 19:52:08 +01009391 }
9392 putParcelableArrayListExtra(EXTRA_STREAM, newStreams);
9393 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009394 } else if (MediaStore.ACTION_IMAGE_CAPTURE.equals(action)
9395 || MediaStore.ACTION_IMAGE_CAPTURE_SECURE.equals(action)
9396 || MediaStore.ACTION_VIDEO_CAPTURE.equals(action)) {
9397 final Uri output = getParcelableExtra(MediaStore.EXTRA_OUTPUT);
9398 if (output != null) {
9399 putExtra(MediaStore.EXTRA_OUTPUT, maybeAddUserId(output, contentUserHint));
9400 }
Nicolas Prevotd85fc722014-04-16 19:52:08 +01009401 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009402 }
Nicolas Prevotd85fc722014-04-16 19:52:08 +01009403
9404 /**
Jeff Sharkey678d04f2012-03-23 15:41:58 -07009405 * Migrate any {@link #EXTRA_STREAM} in {@link #ACTION_SEND} and
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009406 * {@link #ACTION_SEND_MULTIPLE} to {@link ClipData}. Also inspects nested
9407 * intents in {@link #ACTION_CHOOSER}.
Jeff Sharkey678d04f2012-03-23 15:41:58 -07009408 *
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009409 * @return Whether any contents were migrated.
Jeff Sharkey678d04f2012-03-23 15:41:58 -07009410 * @hide
9411 */
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009412 public boolean migrateExtraStreamToClipData() {
Jeff Sharkey678d04f2012-03-23 15:41:58 -07009413 // Refuse to touch if extras already parcelled
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009414 if (mExtras != null && mExtras.isParcelled()) return false;
Jeff Sharkey678d04f2012-03-23 15:41:58 -07009415
9416 // Bail when someone already gave us ClipData
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009417 if (getClipData() != null) return false;
Jeff Sharkey678d04f2012-03-23 15:41:58 -07009418
9419 final String action = getAction();
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009420 if (ACTION_CHOOSER.equals(action)) {
Jeff Sharkeyc004eef2014-09-23 16:40:50 -07009421 // Inspect contained intents to see if we need to migrate extras. We
9422 // don't promote ClipData to the parent, since ChooserActivity will
9423 // already start the picked item as the caller, and we can't combine
9424 // the flags in a safe way.
9425
9426 boolean migrated = false;
Jeff Sharkey1c297002012-05-18 13:55:47 -07009427 try {
Jeff Sharkeyc004eef2014-09-23 16:40:50 -07009428 final Intent intent = getParcelableExtra(EXTRA_INTENT);
9429 if (intent != null) {
9430 migrated |= intent.migrateExtraStreamToClipData();
Jeff Sharkey1c297002012-05-18 13:55:47 -07009431 }
9432 } catch (ClassCastException e) {
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009433 }
Jeff Sharkeyc004eef2014-09-23 16:40:50 -07009434 try {
9435 final Parcelable[] intents = getParcelableArrayExtra(EXTRA_INITIAL_INTENTS);
9436 if (intents != null) {
9437 for (int i = 0; i < intents.length; i++) {
9438 final Intent intent = (Intent) intents[i];
9439 if (intent != null) {
9440 migrated |= intent.migrateExtraStreamToClipData();
9441 }
9442 }
9443 }
9444 } catch (ClassCastException e) {
9445 }
9446 return migrated;
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009447
9448 } else if (ACTION_SEND.equals(action)) {
Jeff Sharkeyf27ea662012-03-27 10:34:24 -07009449 try {
Jeff Sharkeydd471e62012-05-01 13:07:01 -07009450 final Uri stream = getParcelableExtra(EXTRA_STREAM);
9451 final CharSequence text = getCharSequenceExtra(EXTRA_TEXT);
9452 final String htmlText = getStringExtra(EXTRA_HTML_TEXT);
9453 if (stream != null || text != null || htmlText != null) {
9454 final ClipData clipData = new ClipData(
9455 null, new String[] { getType() },
9456 new ClipData.Item(text, htmlText, null, stream));
9457 setClipData(clipData);
9458 addFlags(FLAG_GRANT_READ_URI_PERMISSION);
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009459 return true;
Jeff Sharkeydd471e62012-05-01 13:07:01 -07009460 }
Jeff Sharkeyf27ea662012-03-27 10:34:24 -07009461 } catch (ClassCastException e) {
Jeff Sharkeyf27ea662012-03-27 10:34:24 -07009462 }
Jeff Sharkey678d04f2012-03-23 15:41:58 -07009463
9464 } else if (ACTION_SEND_MULTIPLE.equals(action)) {
Jeff Sharkeyf27ea662012-03-27 10:34:24 -07009465 try {
Jeff Sharkeydd471e62012-05-01 13:07:01 -07009466 final ArrayList<Uri> streams = getParcelableArrayListExtra(EXTRA_STREAM);
9467 final ArrayList<CharSequence> texts = getCharSequenceArrayListExtra(EXTRA_TEXT);
9468 final ArrayList<String> htmlTexts = getStringArrayListExtra(EXTRA_HTML_TEXT);
9469 int num = -1;
9470 if (streams != null) {
9471 num = streams.size();
9472 }
9473 if (texts != null) {
9474 if (num >= 0 && num != texts.size()) {
9475 // Wha...! F- you.
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009476 return false;
Jeff Sharkeydd471e62012-05-01 13:07:01 -07009477 }
9478 num = texts.size();
9479 }
9480 if (htmlTexts != null) {
9481 if (num >= 0 && num != htmlTexts.size()) {
9482 // Wha...! F- you.
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009483 return false;
Jeff Sharkeydd471e62012-05-01 13:07:01 -07009484 }
9485 num = htmlTexts.size();
9486 }
9487 if (num > 0) {
9488 final ClipData clipData = new ClipData(
9489 null, new String[] { getType() },
9490 makeClipItem(streams, texts, htmlTexts, 0));
9491
9492 for (int i = 1; i < num; i++) {
9493 clipData.addItem(makeClipItem(streams, texts, htmlTexts, i));
9494 }
9495
9496 setClipData(clipData);
9497 addFlags(FLAG_GRANT_READ_URI_PERMISSION);
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009498 return true;
Jeff Sharkeydd471e62012-05-01 13:07:01 -07009499 }
Jeff Sharkeyf27ea662012-03-27 10:34:24 -07009500 } catch (ClassCastException e) {
Jeff Sharkeyf27ea662012-03-27 10:34:24 -07009501 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009502 } else if (MediaStore.ACTION_IMAGE_CAPTURE.equals(action)
9503 || MediaStore.ACTION_IMAGE_CAPTURE_SECURE.equals(action)
9504 || MediaStore.ACTION_VIDEO_CAPTURE.equals(action)) {
9505 final Uri output;
9506 try {
9507 output = getParcelableExtra(MediaStore.EXTRA_OUTPUT);
9508 } catch (ClassCastException e) {
9509 return false;
9510 }
9511 if (output != null) {
9512 setClipData(ClipData.newRawUri("", output));
9513 addFlags(FLAG_GRANT_WRITE_URI_PERMISSION|FLAG_GRANT_READ_URI_PERMISSION);
9514 return true;
9515 }
Jeff Sharkey678d04f2012-03-23 15:41:58 -07009516 }
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009517
9518 return false;
Jeff Sharkey678d04f2012-03-23 15:41:58 -07009519 }
Dianne Hackbornac4243f2012-04-13 17:32:18 -07009520
9521 private static ClipData.Item makeClipItem(ArrayList<Uri> streams, ArrayList<CharSequence> texts,
9522 ArrayList<String> htmlTexts, int which) {
9523 Uri uri = streams != null ? streams.get(which) : null;
9524 CharSequence text = texts != null ? texts.get(which) : null;
9525 String htmlText = htmlTexts != null ? htmlTexts.get(which) : null;
9526 return new ClipData.Item(text, htmlText, null, uri);
9527 }
Craig Mautnerd00f4742014-03-12 14:17:26 -07009528
9529 /** @hide */
9530 public boolean isDocument() {
9531 return (mFlags & FLAG_ACTIVITY_NEW_DOCUMENT) == FLAG_ACTIVITY_NEW_DOCUMENT;
9532 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009533}