blob: b559ebfcdd7592811a51210b8e31e006fe9bb108 [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;
Jeff Sharkey32ee8ee2017-03-08 20:17:51 -070020import android.annotation.BroadcastBehavior;
Tor Norbyed9273d62013-05-30 15:59:53 -070021import android.annotation.IntDef;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070022import android.annotation.SdkConstant;
23import android.annotation.SdkConstant.SdkConstantType;
Jason Monk2f68e8a2016-02-23 17:57:28 -050024import android.annotation.SystemApi;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070025import android.content.pm.ActivityInfo;
Jason Monk2f68e8a2016-02-23 17:57:28 -050026import android.content.pm.ApplicationInfo;
Jeff Sharkeycf3f0a12016-03-17 19:57:58 -060027import android.content.pm.ComponentInfo;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070028import android.content.pm.PackageManager;
29import android.content.pm.ResolveInfo;
30import android.content.res.Resources;
31import android.content.res.TypedArray;
Joe Onoratoc7a63ee2009-12-02 21:13:17 -080032import android.graphics.Rect;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070033import android.net.Uri;
Jeff Sharkeycf3f0a12016-03-17 19:57:58 -060034import android.os.Build;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070035import android.os.Bundle;
36import android.os.IBinder;
37import android.os.Parcel;
38import android.os.Parcelable;
Nicolas Prevotc4fc00a2014-10-31 12:01:32 +000039import android.os.Process;
Jason Monk2f68e8a2016-02-23 17:57:28 -050040import android.os.ResultReceiver;
41import android.os.ShellCommand;
Jeff Sharkeya14acd22013-04-02 18:27:45 -070042import android.os.StrictMode;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +010043import android.os.UserHandle;
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)
Jeff Sharkey32ee8ee2017-03-08 20:17:51 -07001995 @BroadcastBehavior(includeBackground = true)
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001996 public static final String ACTION_BOOT_COMPLETED = "android.intent.action.BOOT_COMPLETED";
Jeff Sharkeybedbaa92015-12-02 16:42:25 -07001997
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001998 /**
1999 * Broadcast Action: This is broadcast when a user action should request a
2000 * temporary system dialog to dismiss. Some examples of temporary system
2001 * dialogs are the notification window-shade and the recent tasks dialog.
2002 */
2003 public static final String ACTION_CLOSE_SYSTEM_DIALOGS = "android.intent.action.CLOSE_SYSTEM_DIALOGS";
2004 /**
2005 * Broadcast Action: Trigger the download and eventual installation
2006 * of a package.
2007 * <p>Input: {@link #getData} is the URI of the package file to download.
Tom Taylord4a47292009-12-21 13:59:18 -08002008 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002009 * <p class="note">This is a protected intent that can only be sent
2010 * by the system.
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07002011 *
2012 * @deprecated This constant has never been used.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002013 */
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07002014 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002015 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2016 public static final String ACTION_PACKAGE_INSTALL = "android.intent.action.PACKAGE_INSTALL";
2017 /**
2018 * Broadcast Action: A new application package has been installed on the
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07002019 * device. The data contains the name of the package. Note that the
2020 * newly installed package does <em>not</em> receive this broadcast.
Jeff Sharkeyd0c6ccb2012-09-14 16:26:37 -07002021 * <p>May include the following extras:
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002022 * <ul>
2023 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the new package.
2024 * <li> {@link #EXTRA_REPLACING} is set to true if this is following
2025 * an {@link #ACTION_PACKAGE_REMOVED} broadcast for the same package.
2026 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002027 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002028 * <p class="note">This is a protected intent that can only be sent
2029 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002030 */
2031 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2032 public static final String ACTION_PACKAGE_ADDED = "android.intent.action.PACKAGE_ADDED";
2033 /**
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07002034 * Broadcast Action: A new version of an application package has been
2035 * installed, replacing an existing version that was previously installed.
2036 * The data contains the name of the package.
Jeff Sharkeyd0c6ccb2012-09-14 16:26:37 -07002037 * <p>May include the following extras:
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07002038 * <ul>
2039 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the new package.
2040 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002041 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002042 * <p class="note">This is a protected intent that can only be sent
2043 * by the system.
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07002044 */
2045 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2046 public static final String ACTION_PACKAGE_REPLACED = "android.intent.action.PACKAGE_REPLACED";
2047 /**
Dianne Hackborne7f97212011-02-24 14:40:20 -08002048 * Broadcast Action: A new version of your application has been installed
2049 * over an existing one. This is only sent to the application that was
2050 * replaced. It does not contain any additional data; to receive it, just
2051 * use an intent filter for this action.
2052 *
2053 * <p class="note">This is a protected intent that can only be sent
2054 * by the system.
2055 */
2056 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2057 public static final String ACTION_MY_PACKAGE_REPLACED = "android.intent.action.MY_PACKAGE_REPLACED";
2058 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002059 * Broadcast Action: An existing application package has been removed from
2060 * the device. The data contains the name of the package. The package
Trevor Johns682c24e2016-04-12 10:13:47 -07002061 * that is being removed does <em>not</em> receive this Intent.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002062 * <ul>
2063 * <li> {@link #EXTRA_UID} containing the integer uid previously assigned
2064 * to the package.
2065 * <li> {@link #EXTRA_DATA_REMOVED} is set to true if the entire
2066 * application -- data and code -- is being removed.
2067 * <li> {@link #EXTRA_REPLACING} is set to true if this will be followed
2068 * by an {@link #ACTION_PACKAGE_ADDED} broadcast for the same package.
2069 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002070 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002071 * <p class="note">This is a protected intent that can only be sent
2072 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002073 */
2074 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2075 public static final String ACTION_PACKAGE_REMOVED = "android.intent.action.PACKAGE_REMOVED";
2076 /**
Dianne Hackbornf9abb402011-08-10 15:00:59 -07002077 * Broadcast Action: An existing application package has been completely
2078 * removed from the device. The data contains the name of the package.
2079 * This is like {@link #ACTION_PACKAGE_REMOVED}, but only set when
2080 * {@link #EXTRA_DATA_REMOVED} is true and
2081 * {@link #EXTRA_REPLACING} is false of that broadcast.
2082 *
2083 * <ul>
2084 * <li> {@link #EXTRA_UID} containing the integer uid previously assigned
2085 * to the package.
2086 * </ul>
2087 *
2088 * <p class="note">This is a protected intent that can only be sent
2089 * by the system.
2090 */
2091 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2092 public static final String ACTION_PACKAGE_FULLY_REMOVED
2093 = "android.intent.action.PACKAGE_FULLY_REMOVED";
2094 /**
Trevor Johns682c24e2016-04-12 10:13:47 -07002095 * Broadcast Action: An existing application package has been changed (for
2096 * example, a component has been enabled or disabled). The data contains
2097 * the name of the package.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002098 * <ul>
2099 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
Dianne Hackborn86a72da2009-11-11 20:12:41 -08002100 * <li> {@link #EXTRA_CHANGED_COMPONENT_NAME_LIST} containing the class name
Dianne Hackbornfd7aded2013-01-22 17:10:23 -08002101 * of the changed components (or the package name itself).
Dianne Hackborn86a72da2009-11-11 20:12:41 -08002102 * <li> {@link #EXTRA_DONT_KILL_APP} containing boolean field to override the
2103 * default action of restarting the application.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002104 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002105 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002106 * <p class="note">This is a protected intent that can only be sent
2107 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002108 */
2109 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2110 public static final String ACTION_PACKAGE_CHANGED = "android.intent.action.PACKAGE_CHANGED";
2111 /**
Dianne Hackborn21f1bd12010-02-19 17:02:21 -08002112 * @hide
2113 * Broadcast Action: Ask system services if there is any reason to
2114 * restart the given package. The data contains the name of the
2115 * package.
2116 * <ul>
2117 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
2118 * <li> {@link #EXTRA_PACKAGES} String array of all packages to check.
2119 * </ul>
2120 *
2121 * <p class="note">This is a protected intent that can only be sent
2122 * by the system.
2123 */
Soonil Nagarkar0e8fd092015-02-10 10:37:36 -08002124 @SystemApi
Dianne Hackborn21f1bd12010-02-19 17:02:21 -08002125 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2126 public static final String ACTION_QUERY_PACKAGE_RESTART = "android.intent.action.QUERY_PACKAGE_RESTART";
2127 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002128 * Broadcast Action: The user has restarted a package, and all of its
2129 * processes have been killed. All runtime state
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002130 * associated with it (processes, alarms, notifications, etc) should
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07002131 * be removed. Note that the restarted package does <em>not</em>
2132 * receive this broadcast.
2133 * The data contains the name of the package.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002134 * <ul>
2135 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
2136 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002137 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002138 * <p class="note">This is a protected intent that can only be sent
2139 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002140 */
2141 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2142 public static final String ACTION_PACKAGE_RESTARTED = "android.intent.action.PACKAGE_RESTARTED";
2143 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002144 * Broadcast Action: The user has cleared the data of a package. This should
2145 * be preceded by {@link #ACTION_PACKAGE_RESTARTED}, after which all of
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07002146 * its persistent data is erased and this broadcast sent.
2147 * Note that the cleared package does <em>not</em>
2148 * receive this broadcast. The data contains the name of the package.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002149 * <ul>
2150 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
2151 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002152 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002153 * <p class="note">This is a protected intent that can only be sent
2154 * by the system.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002155 */
2156 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2157 public static final String ACTION_PACKAGE_DATA_CLEARED = "android.intent.action.PACKAGE_DATA_CLEARED";
2158 /**
Andrei Stingaceanu69d5ebc2016-01-14 12:59:03 +00002159 * Broadcast Action: Packages have been suspended.
2160 * <p>Includes the following extras:
2161 * <ul>
2162 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages which have been suspended
2163 * </ul>
2164 *
2165 * <p class="note">This is a protected intent that can only be sent
2166 * by the system. It is only sent to registered receivers.
2167 */
2168 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2169 public static final String ACTION_PACKAGES_SUSPENDED = "android.intent.action.PACKAGES_SUSPENDED";
2170 /**
2171 * Broadcast Action: Packages have been unsuspended.
2172 * <p>Includes the following extras:
2173 * <ul>
2174 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages which have been unsuspended
2175 * </ul>
2176 *
2177 * <p class="note">This is a protected intent that can only be sent
2178 * by the system. It is only sent to registered receivers.
2179 */
2180 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2181 public static final String ACTION_PACKAGES_UNSUSPENDED = "android.intent.action.PACKAGES_UNSUSPENDED";
2182 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002183 * Broadcast Action: A user ID has been removed from the system. The user
2184 * ID number is stored in the extra data under {@link #EXTRA_UID}.
Tom Taylord4a47292009-12-21 13:59:18 -08002185 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002186 * <p class="note">This is a protected intent that can only be sent
2187 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002188 */
2189 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2190 public static final String ACTION_UID_REMOVED = "android.intent.action.UID_REMOVED";
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002191
2192 /**
Trevor Johns682c24e2016-04-12 10:13:47 -07002193 * Broadcast Action: Sent to the installer package of an application when
2194 * that application is first launched (that is the first time it is moved
2195 * out of the stopped state). The data contains the name of the package.
Dianne Hackborne7f97212011-02-24 14:40:20 -08002196 *
2197 * <p class="note">This is a protected intent that can only be sent
2198 * by the system.
2199 */
2200 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2201 public static final String ACTION_PACKAGE_FIRST_LAUNCH = "android.intent.action.PACKAGE_FIRST_LAUNCH";
2202
2203 /**
Kenny Root5ab21572011-07-27 11:11:19 -07002204 * Broadcast Action: Sent to the system package verifier when a package
2205 * needs to be verified. The data contains the package URI.
2206 * <p class="note">
2207 * This is a protected intent that can only be sent by the system.
2208 * </p>
Kenny Root5ab21572011-07-27 11:11:19 -07002209 */
2210 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2211 public static final String ACTION_PACKAGE_NEEDS_VERIFICATION = "android.intent.action.PACKAGE_NEEDS_VERIFICATION";
2212
2213 /**
rich canningsd1b5cfc2012-08-29 14:49:51 -07002214 * Broadcast Action: Sent to the system package verifier when a package is
2215 * verified. The data contains the package URI.
2216 * <p class="note">
2217 * This is a protected intent that can only be sent by the system.
2218 */
2219 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2220 public static final String ACTION_PACKAGE_VERIFIED = "android.intent.action.PACKAGE_VERIFIED";
2221
2222 /**
Trevor Johns682c24e2016-04-12 10:13:47 -07002223 * Broadcast Action: Sent to the system intent filter verifier when an
2224 * intent filter needs to be verified. The data contains the filter data
2225 * hosts to be verified against.
Fabrice Di Meglio1c1b4712014-11-19 17:12:32 -08002226 * <p class="note">
2227 * This is a protected intent that can only be sent by the system.
2228 * </p>
2229 *
2230 * @hide
2231 */
2232 @SystemApi
2233 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2234 public static final String ACTION_INTENT_FILTER_NEEDS_VERIFICATION = "android.intent.action.INTENT_FILTER_NEEDS_VERIFICATION";
2235
2236 /**
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002237 * Broadcast Action: Resources for a set of packages (which were
2238 * previously unavailable) are currently
2239 * available since the media on which they exist is available.
2240 * The extra data {@link #EXTRA_CHANGED_PACKAGE_LIST} contains a
2241 * list of packages whose availability changed.
2242 * The extra data {@link #EXTRA_CHANGED_UID_LIST} contains a
2243 * list of uids of packages whose availability changed.
2244 * Note that the
2245 * packages in this list do <em>not</em> receive this broadcast.
2246 * The specified set of packages are now available on the system.
2247 * <p>Includes the following extras:
2248 * <ul>
2249 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages
2250 * whose resources(were previously unavailable) are currently available.
2251 * {@link #EXTRA_CHANGED_UID_LIST} is the set of uids of the
2252 * packages whose resources(were previously unavailable)
2253 * are currently available.
2254 * </ul>
2255 *
2256 * <p class="note">This is a protected intent that can only be sent
2257 * by the system.
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002258 */
2259 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08002260 public static final String ACTION_EXTERNAL_APPLICATIONS_AVAILABLE =
2261 "android.intent.action.EXTERNAL_APPLICATIONS_AVAILABLE";
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002262
2263 /**
2264 * Broadcast Action: Resources for a set of packages are currently
2265 * unavailable since the media on which they exist is unavailable.
2266 * The extra data {@link #EXTRA_CHANGED_PACKAGE_LIST} contains a
2267 * list of packages whose availability changed.
2268 * The extra data {@link #EXTRA_CHANGED_UID_LIST} contains a
2269 * list of uids of packages whose availability changed.
2270 * The specified set of packages can no longer be
2271 * launched and are practically unavailable on the system.
2272 * <p>Inclues the following extras:
2273 * <ul>
2274 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages
2275 * whose resources are no longer available.
2276 * {@link #EXTRA_CHANGED_UID_LIST} is the set of packages
2277 * whose resources are no longer available.
2278 * </ul>
2279 *
2280 * <p class="note">This is a protected intent that can only be sent
2281 * by the system.
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002282 */
2283 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08002284 public static final String ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE =
Joe Onorato8a051a42010-03-04 15:54:50 -05002285 "android.intent.action.EXTERNAL_APPLICATIONS_UNAVAILABLE";
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002286
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002287 /**
Makoto Onuki10305202016-07-14 18:14:08 -07002288 * Broadcast Action: preferred activities have changed *explicitly*.
2289 *
2290 * <p>Note there are cases where a preferred activity is invalidated *implicitly*, e.g.
2291 * when an app is installed or uninstalled, but in such cases this broadcast will *not*
2292 * be sent.
2293 *
2294 * {@link #EXTRA_USER_HANDLE} contains the user ID in question.
2295 *
2296 * @hide
2297 */
2298 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2299 public static final String ACTION_PREFERRED_ACTIVITY_CHANGED =
2300 "android.intent.action.ACTION_PREFERRED_ACTIVITY_CHANGED";
2301
2302
2303 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002304 * Broadcast Action: The current system wallpaper has changed. See
Scott Main8b2e0002009-09-29 18:17:31 -07002305 * {@link android.app.WallpaperManager} for retrieving the new wallpaper.
Dianne Hackbornc5bf7582012-04-25 19:12:07 -07002306 * This should <em>only</em> be used to determine when the wallpaper
2307 * has changed to show the new wallpaper to the user. You should certainly
2308 * never, in response to this, change the wallpaper or other attributes of
2309 * it such as the suggested size. That would be crazy, right? You'd cause
2310 * all kinds of loops, especially if other apps are doing similar things,
2311 * right? Of course. So please don't do this.
2312 *
2313 * @deprecated Modern applications should use
2314 * {@link android.view.WindowManager.LayoutParams#FLAG_SHOW_WALLPAPER
2315 * WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER} to have the wallpaper
2316 * shown behind their UI, rather than watching for this broadcast and
2317 * rendering the wallpaper on their own.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002318 */
Dianne Hackbornc5bf7582012-04-25 19:12:07 -07002319 @Deprecated @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002320 public static final String ACTION_WALLPAPER_CHANGED = "android.intent.action.WALLPAPER_CHANGED";
2321 /**
2322 * Broadcast Action: The current device {@link android.content.res.Configuration}
2323 * (orientation, locale, etc) has changed. When such a change happens, the
2324 * UIs (view hierarchy) will need to be rebuilt based on this new
2325 * information; for the most part, applications don't need to worry about
2326 * this, because the system will take care of stopping and restarting the
2327 * application to make sure it sees the new changes. Some system code that
2328 * can not be restarted will need to watch for this action and handle it
2329 * appropriately.
Tom Taylord4a47292009-12-21 13:59:18 -08002330 *
Dianne Hackborn362d5b92009-11-11 18:04:39 -08002331 * <p class="note">
Casey Hodbf6785c2015-03-17 15:59:39 -07002332 * You <em>cannot</em> receive this through components declared
Dianne Hackborn362d5b92009-11-11 18:04:39 -08002333 * in manifests, only by explicitly registering for it with
2334 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
2335 * Context.registerReceiver()}.
Tom Taylord4a47292009-12-21 13:59:18 -08002336 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002337 * <p class="note">This is a protected intent that can only be sent
2338 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002339 *
2340 * @see android.content.res.Configuration
2341 */
2342 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2343 public static final String ACTION_CONFIGURATION_CHANGED = "android.intent.action.CONFIGURATION_CHANGED";
2344 /**
Dianne Hackborn362d5b92009-11-11 18:04:39 -08002345 * Broadcast Action: The current device's locale has changed.
Tom Taylord4a47292009-12-21 13:59:18 -08002346 *
Dianne Hackborn362d5b92009-11-11 18:04:39 -08002347 * <p class="note">This is a protected intent that can only be sent
2348 * by the system.
2349 */
2350 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2351 public static final String ACTION_LOCALE_CHANGED = "android.intent.action.LOCALE_CHANGED";
2352 /**
Dianne Hackbornedd93162009-09-19 14:03:05 -07002353 * Broadcast Action: This is a <em>sticky broadcast</em> containing the
2354 * charging state, level, and other information about the battery.
2355 * See {@link android.os.BatteryManager} for documentation on the
2356 * contents of the Intent.
The Android Open Source Project10592532009-03-18 17:39:46 -07002357 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002358 * <p class="note">
Casey Hodbf6785c2015-03-17 15:59:39 -07002359 * You <em>cannot</em> receive this through components declared
Dianne Hackborn854060af2009-07-09 18:14:31 -07002360 * in manifests, only by explicitly registering for it with
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002361 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
Dianne Hackbornedd93162009-09-19 14:03:05 -07002362 * Context.registerReceiver()}. See {@link #ACTION_BATTERY_LOW},
2363 * {@link #ACTION_BATTERY_OKAY}, {@link #ACTION_POWER_CONNECTED},
2364 * and {@link #ACTION_POWER_DISCONNECTED} for distinct battery-related
2365 * broadcasts that are sent and can be received through manifest
2366 * receivers.
Tom Taylord4a47292009-12-21 13:59:18 -08002367 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002368 * <p class="note">This is a protected intent that can only be sent
2369 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002370 */
2371 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2372 public static final String ACTION_BATTERY_CHANGED = "android.intent.action.BATTERY_CHANGED";
2373 /**
2374 * Broadcast Action: Indicates low battery condition on the device.
2375 * This broadcast corresponds to the "Low battery warning" system dialog.
Tom Taylord4a47292009-12-21 13:59:18 -08002376 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002377 * <p class="note">This is a protected intent that can only be sent
2378 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002379 */
2380 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2381 public static final String ACTION_BATTERY_LOW = "android.intent.action.BATTERY_LOW";
2382 /**
Dianne Hackborn1dac2772009-06-26 18:16:48 -07002383 * Broadcast Action: Indicates the battery is now okay after being low.
2384 * This will be sent after {@link #ACTION_BATTERY_LOW} once the battery has
2385 * gone back up to an okay state.
Tom Taylord4a47292009-12-21 13:59:18 -08002386 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002387 * <p class="note">This is a protected intent that can only be sent
2388 * by the system.
Dianne Hackborn1dac2772009-06-26 18:16:48 -07002389 */
2390 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2391 public static final String ACTION_BATTERY_OKAY = "android.intent.action.BATTERY_OKAY";
2392 /**
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002393 * Broadcast Action: External power has been connected to the device.
2394 * This is intended for applications that wish to register specifically to this notification.
2395 * Unlike ACTION_BATTERY_CHANGED, applications will be woken for this and so do not have to
2396 * stay active to receive this notification. This action can be used to implement actions
2397 * that wait until power is available to trigger.
Tom Taylord4a47292009-12-21 13:59:18 -08002398 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002399 * <p class="note">This is a protected intent that can only be sent
2400 * by the system.
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002401 */
2402 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Dianne Hackbornfe240ec2009-08-27 12:51:11 -07002403 public static final String ACTION_POWER_CONNECTED = "android.intent.action.ACTION_POWER_CONNECTED";
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002404 /**
2405 * Broadcast Action: External power has been removed from the device.
2406 * This is intended for applications that wish to register specifically to this notification.
2407 * Unlike ACTION_BATTERY_CHANGED, applications will be woken for this and so do not have to
2408 * stay active to receive this notification. This action can be used to implement actions
Romain Guy4969af72009-06-17 10:53:19 -07002409 * that wait until power is available to trigger.
Tom Taylord4a47292009-12-21 13:59:18 -08002410 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002411 * <p class="note">This is a protected intent that can only be sent
2412 * by the system.
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002413 */
2414 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jean-Baptiste Queru1ef45642008-10-24 11:49:25 -07002415 public static final String ACTION_POWER_DISCONNECTED =
Dianne Hackbornfe240ec2009-08-27 12:51:11 -07002416 "android.intent.action.ACTION_POWER_DISCONNECTED";
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002417 /**
Dianne Hackborn55280a92009-05-07 15:53:46 -07002418 * Broadcast Action: Device is shutting down.
2419 * This is broadcast when the device is being shut down (completely turned
2420 * off, not sleeping). Once the broadcast is complete, the final shutdown
2421 * will proceed and all unsaved data lost. Apps will not normally need
Dianne Hackbornfe240ec2009-08-27 12:51:11 -07002422 * to handle this, since the foreground activity will be paused as well.
Tom Taylord4a47292009-12-21 13:59:18 -08002423 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002424 * <p class="note">This is a protected intent that can only be sent
2425 * by the system.
Dianne Hackborn57a7f592013-07-22 18:21:32 -07002426 * <p>May include the following extras:
2427 * <ul>
2428 * <li> {@link #EXTRA_SHUTDOWN_USERSPACE_ONLY} a boolean that is set to true if this
2429 * shutdown is only for userspace processes. If not set, assumed to be false.
2430 * </ul>
Dianne Hackborn55280a92009-05-07 15:53:46 -07002431 */
2432 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Romain Guy4969af72009-06-17 10:53:19 -07002433 public static final String ACTION_SHUTDOWN = "android.intent.action.ACTION_SHUTDOWN";
Dianne Hackborn55280a92009-05-07 15:53:46 -07002434 /**
Mike Lockwoodbad80e02009-07-30 01:21:08 -07002435 * Activity Action: Start this activity to request system shutdown.
2436 * The optional boolean extra field {@link #EXTRA_KEY_CONFIRM} can be set to true
Yusuke Sato705ffd12015-07-21 15:52:11 -07002437 * to request confirmation from the user before shutting down. The optional boolean
2438 * extra field {@link #EXTRA_USER_REQUESTED_SHUTDOWN} can be set to true to
2439 * indicate that the shutdown is requested by the user.
Mike Lockwoodbad80e02009-07-30 01:21:08 -07002440 *
2441 * <p class="note">This is a protected intent that can only be sent
2442 * by the system.
2443 *
2444 * {@hide}
2445 */
2446 public static final String ACTION_REQUEST_SHUTDOWN = "android.intent.action.ACTION_REQUEST_SHUTDOWN";
2447 /**
Dianne Hackbornedd93162009-09-19 14:03:05 -07002448 * Broadcast Action: A sticky broadcast that indicates low memory
2449 * condition on the device
Tom Taylord4a47292009-12-21 13:59:18 -08002450 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002451 * <p class="note">This is a protected intent that can only be sent
2452 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002453 */
2454 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2455 public static final String ACTION_DEVICE_STORAGE_LOW = "android.intent.action.DEVICE_STORAGE_LOW";
2456 /**
2457 * Broadcast Action: Indicates low memory condition on the device no longer exists
Tom Taylord4a47292009-12-21 13:59:18 -08002458 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002459 * <p class="note">This is a protected intent that can only be sent
2460 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002461 */
2462 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2463 public static final String ACTION_DEVICE_STORAGE_OK = "android.intent.action.DEVICE_STORAGE_OK";
2464 /**
Jake Hambybb371632010-08-23 18:16:48 -07002465 * Broadcast Action: A sticky broadcast that indicates a memory full
2466 * condition on the device. This is intended for activities that want
2467 * to be able to fill the data partition completely, leaving only
2468 * enough free space to prevent system-wide SQLite failures.
2469 *
2470 * <p class="note">This is a protected intent that can only be sent
2471 * by the system.
2472 *
2473 * {@hide}
2474 */
2475 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2476 public static final String ACTION_DEVICE_STORAGE_FULL = "android.intent.action.DEVICE_STORAGE_FULL";
2477 /**
2478 * Broadcast Action: Indicates memory full condition on the device
2479 * no longer exists.
2480 *
2481 * <p class="note">This is a protected intent that can only be sent
2482 * by the system.
2483 *
2484 * {@hide}
2485 */
2486 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2487 public static final String ACTION_DEVICE_STORAGE_NOT_FULL = "android.intent.action.DEVICE_STORAGE_NOT_FULL";
2488 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002489 * Broadcast Action: Indicates low memory condition notification acknowledged by user
2490 * and package management should be started.
2491 * This is triggered by the user from the ACTION_DEVICE_STORAGE_LOW
2492 * notification.
2493 */
2494 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2495 public static final String ACTION_MANAGE_PACKAGE_STORAGE = "android.intent.action.MANAGE_PACKAGE_STORAGE";
2496 /**
2497 * Broadcast Action: The device has entered USB Mass Storage mode.
2498 * This is used mainly for the USB Settings panel.
2499 * Apps should listen for ACTION_MEDIA_MOUNTED and ACTION_MEDIA_UNMOUNTED broadcasts to be notified
2500 * when the SD card file system is mounted or unmounted
Mike Lockwood7e4db372011-06-07 11:23:44 -07002501 * @deprecated replaced by android.os.storage.StorageEventListener
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002502 */
Mike Lockwoodda85e522011-06-07 09:08:34 -07002503 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002504 public static final String ACTION_UMS_CONNECTED = "android.intent.action.UMS_CONNECTED";
2505
2506 /**
2507 * Broadcast Action: The device has exited USB Mass Storage mode.
2508 * This is used mainly for the USB Settings panel.
2509 * Apps should listen for ACTION_MEDIA_MOUNTED and ACTION_MEDIA_UNMOUNTED broadcasts to be notified
2510 * when the SD card file system is mounted or unmounted
Mike Lockwood7e4db372011-06-07 11:23:44 -07002511 * @deprecated replaced by android.os.storage.StorageEventListener
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002512 */
Mike Lockwoodda85e522011-06-07 09:08:34 -07002513 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002514 public static final String ACTION_UMS_DISCONNECTED = "android.intent.action.UMS_DISCONNECTED";
2515
2516 /**
2517 * Broadcast Action: External media has been removed.
2518 * The path to the mount point for the removed media is contained in the Intent.mData field.
2519 */
2520 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2521 public static final String ACTION_MEDIA_REMOVED = "android.intent.action.MEDIA_REMOVED";
2522
2523 /**
2524 * Broadcast Action: External media is present, but not mounted at its mount point.
suyi Yuanbe7af832013-01-04 21:21:59 +08002525 * 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 -07002526 */
2527 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2528 public static final String ACTION_MEDIA_UNMOUNTED = "android.intent.action.MEDIA_UNMOUNTED";
2529
2530 /**
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08002531 * Broadcast Action: External media is present, and being disk-checked
2532 * 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 -08002533 */
2534 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2535 public static final String ACTION_MEDIA_CHECKING = "android.intent.action.MEDIA_CHECKING";
2536
2537 /**
2538 * Broadcast Action: External media is present, but is using an incompatible fs (or is blank)
2539 * 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 -08002540 */
2541 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2542 public static final String ACTION_MEDIA_NOFS = "android.intent.action.MEDIA_NOFS";
2543
2544 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002545 * Broadcast Action: External media is present and mounted at its mount point.
suyi Yuanbe7af832013-01-04 21:21:59 +08002546 * 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 -07002547 * The Intent contains an extra with name "read-only" and Boolean value to indicate if the
2548 * media was mounted read only.
2549 */
2550 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2551 public static final String ACTION_MEDIA_MOUNTED = "android.intent.action.MEDIA_MOUNTED";
2552
2553 /**
2554 * Broadcast Action: External media is unmounted because it is being shared via USB mass storage.
Mike Lockwoodbf2dd442010-03-03 06:16:52 -05002555 * 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 -07002556 */
2557 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2558 public static final String ACTION_MEDIA_SHARED = "android.intent.action.MEDIA_SHARED";
2559
2560 /**
Mike Lockwoodbf2dd442010-03-03 06:16:52 -05002561 * Broadcast Action: External media is no longer being shared via USB mass storage.
2562 * The path to the mount point for the previously shared media is contained in the Intent.mData field.
2563 *
2564 * @hide
2565 */
2566 public static final String ACTION_MEDIA_UNSHARED = "android.intent.action.MEDIA_UNSHARED";
2567
2568 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002569 * Broadcast Action: External media was removed from SD card slot, but mount point was not unmounted.
2570 * The path to the mount point for the removed media is contained in the Intent.mData field.
2571 */
2572 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2573 public static final String ACTION_MEDIA_BAD_REMOVAL = "android.intent.action.MEDIA_BAD_REMOVAL";
2574
2575 /**
2576 * Broadcast Action: External media is present but cannot be mounted.
suyi Yuanbe7af832013-01-04 21:21:59 +08002577 * 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 -07002578 */
2579 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2580 public static final String ACTION_MEDIA_UNMOUNTABLE = "android.intent.action.MEDIA_UNMOUNTABLE";
2581
2582 /**
2583 * Broadcast Action: User has expressed the desire to remove the external storage media.
2584 * Applications should close all files they have open within the mount point when they receive this intent.
2585 * The path to the mount point for the media to be ejected is contained in the Intent.mData field.
2586 */
2587 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2588 public static final String ACTION_MEDIA_EJECT = "android.intent.action.MEDIA_EJECT";
2589
2590 /**
2591 * Broadcast Action: The media scanner has started scanning a directory.
2592 * The path to the directory being scanned is contained in the Intent.mData field.
2593 */
2594 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2595 public static final String ACTION_MEDIA_SCANNER_STARTED = "android.intent.action.MEDIA_SCANNER_STARTED";
2596
2597 /**
2598 * Broadcast Action: The media scanner has finished scanning a directory.
2599 * The path to the scanned directory is contained in the Intent.mData field.
2600 */
2601 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2602 public static final String ACTION_MEDIA_SCANNER_FINISHED = "android.intent.action.MEDIA_SCANNER_FINISHED";
2603
2604 /**
2605 * Broadcast Action: Request the media scanner to scan a file and add it to the media database.
2606 * The path to the file is contained in the Intent.mData field.
2607 */
2608 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2609 public static final String ACTION_MEDIA_SCANNER_SCAN_FILE = "android.intent.action.MEDIA_SCANNER_SCAN_FILE";
2610
2611 /**
2612 * Broadcast Action: The "Media Button" was pressed. Includes a single
2613 * extra field, {@link #EXTRA_KEY_EVENT}, containing the key event that
2614 * caused the broadcast.
2615 */
2616 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2617 public static final String ACTION_MEDIA_BUTTON = "android.intent.action.MEDIA_BUTTON";
2618
2619 /**
2620 * Broadcast Action: The "Camera Button" was pressed. Includes a single
2621 * extra field, {@link #EXTRA_KEY_EVENT}, containing the key event that
2622 * caused the broadcast.
2623 */
2624 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2625 public static final String ACTION_CAMERA_BUTTON = "android.intent.action.CAMERA_BUTTON";
2626
2627 // *** NOTE: @todo(*) The following really should go into a more domain-specific
2628 // location; they are not general-purpose actions.
2629
2630 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09002631 * Broadcast Action: A GTalk connection has been established.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002632 */
2633 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2634 public static final String ACTION_GTALK_SERVICE_CONNECTED =
2635 "android.intent.action.GTALK_CONNECTED";
2636
2637 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09002638 * Broadcast Action: A GTalk connection has been disconnected.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002639 */
2640 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2641 public static final String ACTION_GTALK_SERVICE_DISCONNECTED =
2642 "android.intent.action.GTALK_DISCONNECTED";
The Android Open Source Project10592532009-03-18 17:39:46 -07002643
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08002644 /**
2645 * Broadcast Action: An input method has been changed.
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08002646 */
2647 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2648 public static final String ACTION_INPUT_METHOD_CHANGED =
2649 "android.intent.action.INPUT_METHOD_CHANGED";
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002650
2651 /**
2652 * <p>Broadcast Action: The user has switched the phone into or out of Airplane Mode. One or
2653 * more radios have been turned off or on. The intent will have the following extra value:</p>
2654 * <ul>
2655 * <li><em>state</em> - A boolean value indicating whether Airplane Mode is on. If true,
2656 * then cell radio and possibly other radios such as bluetooth or WiFi may have also been
2657 * turned off</li>
2658 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002659 *
Peng Xua35b5532016-01-20 00:05:45 -08002660 * <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 -07002661 */
2662 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2663 public static final String ACTION_AIRPLANE_MODE_CHANGED = "android.intent.action.AIRPLANE_MODE";
2664
2665 /**
2666 * Broadcast Action: Some content providers have parts of their namespace
2667 * where they publish new events or items that the user may be especially
2668 * interested in. For these things, they may broadcast this action when the
2669 * set of interesting items change.
2670 *
2671 * For example, GmailProvider sends this notification when the set of unread
2672 * mail in the inbox changes.
2673 *
2674 * <p>The data of the intent identifies which part of which provider
2675 * changed. When queried through the content resolver, the data URI will
2676 * return the data set in question.
2677 *
2678 * <p>The intent will have the following extra values:
2679 * <ul>
2680 * <li><em>count</em> - The number of items in the data set. This is the
2681 * same as the number of items in the cursor returned by querying the
2682 * data URI. </li>
2683 * </ul>
2684 *
2685 * This intent will be sent at boot (if the count is non-zero) and when the
2686 * data set changes. It is possible for the data set to change without the
2687 * count changing (for example, if a new unread message arrives in the same
2688 * sync operation in which a message is archived). The phone should still
2689 * ring/vibrate/etc as normal in this case.
2690 */
2691 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2692 public static final String ACTION_PROVIDER_CHANGED =
2693 "android.intent.action.PROVIDER_CHANGED";
2694
2695 /**
2696 * Broadcast Action: Wired Headset plugged in or unplugged.
2697 *
Jean-Michel Trivic5258432014-08-27 15:46:54 -07002698 * Same as {@link android.media.AudioManager#ACTION_HEADSET_PLUG}, to be consulted for value
2699 * and documentation.
2700 * <p>If the minimum SDK version of your application is
Dianne Hackborn955d8d62014-10-07 20:17:19 -07002701 * {@link android.os.Build.VERSION_CODES#LOLLIPOP}, it is recommended to refer
Jean-Michel Trivic5258432014-08-27 15:46:54 -07002702 * to the <code>AudioManager</code> constant in your receiver registration code instead.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002703 */
2704 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jean-Michel Trivic5258432014-08-27 15:46:54 -07002705 public static final String ACTION_HEADSET_PLUG = android.media.AudioManager.ACTION_HEADSET_PLUG;
Eric Laurent59f48272012-04-05 19:42:21 -07002706
2707 /**
Joe Onorato9cdffa12011-04-06 18:27:27 -07002708 * <p>Broadcast Action: The user has switched on advanced settings in the settings app:</p>
2709 * <ul>
2710 * <li><em>state</em> - A boolean value indicating whether the settings is on or off.</li>
2711 * </ul>
2712 *
2713 * <p class="note">This is a protected intent that can only be sent
2714 * by the system.
2715 *
2716 * @hide
2717 */
2718 //@SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2719 public static final String ACTION_ADVANCED_SETTINGS_CHANGED
2720 = "android.intent.action.ADVANCED_SETTINGS";
2721
2722 /**
Robin Lee66e5d962014-04-09 16:44:21 +01002723 * Broadcast Action: Sent after application restrictions are changed.
2724 *
2725 * <p class="note">This is a protected intent that can only be sent
2726 * by the system.</p>
2727 */
2728 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2729 public static final String ACTION_APPLICATION_RESTRICTIONS_CHANGED =
2730 "android.intent.action.APPLICATION_RESTRICTIONS_CHANGED";
2731
2732 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002733 * Broadcast Action: An outgoing call is about to be placed.
2734 *
Dirk Dougherty367ce902013-05-28 17:37:12 -07002735 * <p>The Intent will have the following extra value:</p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002736 * <ul>
The Android Open Source Project10592532009-03-18 17:39:46 -07002737 * <li><em>{@link android.content.Intent#EXTRA_PHONE_NUMBER}</em> -
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002738 * the phone number originally intended to be dialed.</li>
2739 * </ul>
2740 * <p>Once the broadcast is finished, the resultData is used as the actual
2741 * number to call. If <code>null</code>, no call will be placed.</p>
The Android Open Source Project10592532009-03-18 17:39:46 -07002742 * <p>It is perfectly acceptable for multiple receivers to process the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002743 * outgoing call in turn: for example, a parental control application
2744 * might verify that the user is authorized to place the call at that
2745 * time, then a number-rewriting application might add an area code if
2746 * one was not specified.</p>
2747 * <p>For consistency, any receiver whose purpose is to prohibit phone
2748 * calls should have a priority of 0, to ensure it will see the final
2749 * phone number to be dialed.
The Android Open Source Project10592532009-03-18 17:39:46 -07002750 * Any receiver whose purpose is to rewrite phone numbers to be called
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002751 * should have a positive priority.
2752 * Negative priorities are reserved for the system for this broadcast;
2753 * using them may cause problems.</p>
Dirk Dougherty932fbcc2013-05-29 15:19:14 -07002754 * <p>Any BroadcastReceiver receiving this Intent <em>must not</em>
2755 * abort the broadcast.</p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002756 * <p>Emergency calls cannot be intercepted using this mechanism, and
2757 * other calls cannot be modified to call emergency numbers using this
2758 * mechanism.
Santos Cordonba701362013-05-17 14:48:54 -07002759 * <p>Some apps (such as VoIP apps) may want to redirect the outgoing
2760 * call to use their own service instead. Those apps should first prevent
2761 * the call from being placed by setting resultData to <code>null</code>
2762 * and then start their own app to make the call.
The Android Open Source Project10592532009-03-18 17:39:46 -07002763 * <p>You must hold the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002764 * {@link android.Manifest.permission#PROCESS_OUTGOING_CALLS}
2765 * permission to receive this Intent.</p>
Tom Taylord4a47292009-12-21 13:59:18 -08002766 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002767 * <p class="note">This is a protected intent that can only be sent
2768 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002769 */
2770 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2771 public static final String ACTION_NEW_OUTGOING_CALL =
2772 "android.intent.action.NEW_OUTGOING_CALL";
2773
2774 /**
2775 * Broadcast Action: Have the device reboot. This is only for use by
2776 * system code.
Tom Taylord4a47292009-12-21 13:59:18 -08002777 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002778 * <p class="note">This is a protected intent that can only be sent
2779 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002780 */
2781 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2782 public static final String ACTION_REBOOT =
2783 "android.intent.action.REBOOT";
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002784
Wei Huang97ecc9c2009-05-11 17:44:20 -07002785 /**
Dianne Hackborn7299c412010-03-04 18:41:49 -08002786 * Broadcast Action: A sticky broadcast for changes in the physical
2787 * docking state of the device.
Tobias Haamel154f7a12010-02-17 11:56:39 -08002788 *
2789 * <p>The intent will have the following extra values:
2790 * <ul>
2791 * <li><em>{@link #EXTRA_DOCK_STATE}</em> - the current dock
Dianne Hackborn7299c412010-03-04 18:41:49 -08002792 * state, indicating which dock the device is physically in.</li>
Tobias Haamel154f7a12010-02-17 11:56:39 -08002793 * </ul>
Dianne Hackborn7299c412010-03-04 18:41:49 -08002794 * <p>This is intended for monitoring the current physical dock state.
2795 * See {@link android.app.UiModeManager} for the normal API dealing with
2796 * dock mode changes.
Dianne Hackbornedd93162009-09-19 14:03:05 -07002797 */
2798 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2799 public static final String ACTION_DOCK_EVENT =
2800 "android.intent.action.DOCK_EVENT";
2801
2802 /**
Svetoslavb3038ec2013-02-13 14:39:30 -08002803 * Broadcast Action: A broadcast when idle maintenance can be started.
2804 * This means that the user is not interacting with the device and is
2805 * not expected to do so soon. Typical use of the idle maintenance is
2806 * to perform somehow expensive tasks that can be postponed at a moment
2807 * when they will not degrade user experience.
2808 * <p>
2809 * <p class="note">In order to keep the device responsive in case of an
2810 * unexpected user interaction, implementations of a maintenance task
2811 * should be interruptible. In such a scenario a broadcast with action
2812 * {@link #ACTION_IDLE_MAINTENANCE_END} will be sent. In other words, you
2813 * should not do the maintenance work in
2814 * {@link BroadcastReceiver#onReceive(Context, Intent)}, rather start a
2815 * maintenance service by {@link Context#startService(Intent)}. Also
2816 * you should hold a wake lock while your maintenance service is running
2817 * to prevent the device going to sleep.
2818 * </p>
2819 * <p>
2820 * <p class="note">This is a protected intent that can only be sent by
2821 * the system.
2822 * </p>
2823 *
2824 * @see #ACTION_IDLE_MAINTENANCE_END
Svetoslav6a08a122013-05-03 11:24:26 -07002825 *
2826 * @hide
Svetoslavb3038ec2013-02-13 14:39:30 -08002827 */
2828 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2829 public static final String ACTION_IDLE_MAINTENANCE_START =
2830 "android.intent.action.ACTION_IDLE_MAINTENANCE_START";
2831
2832 /**
2833 * Broadcast Action: A broadcast when idle maintenance should be stopped.
2834 * This means that the user was not interacting with the device as a result
2835 * of which a broadcast with action {@link #ACTION_IDLE_MAINTENANCE_START}
2836 * was sent and now the user started interacting with the device. Typical
2837 * use of the idle maintenance is to perform somehow expensive tasks that
2838 * can be postponed at a moment when they will not degrade user experience.
2839 * <p>
2840 * <p class="note">In order to keep the device responsive in case of an
2841 * unexpected user interaction, implementations of a maintenance task
2842 * should be interruptible. Hence, on receiving a broadcast with this
2843 * action, the maintenance task should be interrupted as soon as possible.
2844 * In other words, you should not do the maintenance work in
2845 * {@link BroadcastReceiver#onReceive(Context, Intent)}, rather stop the
2846 * maintenance service that was started on receiving of
2847 * {@link #ACTION_IDLE_MAINTENANCE_START}.Also you should release the wake
2848 * lock you acquired when your maintenance service started.
2849 * </p>
2850 * <p class="note">This is a protected intent that can only be sent
2851 * by the system.
2852 *
2853 * @see #ACTION_IDLE_MAINTENANCE_START
Svetoslav6a08a122013-05-03 11:24:26 -07002854 *
2855 * @hide
Svetoslavb3038ec2013-02-13 14:39:30 -08002856 */
2857 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2858 public static final String ACTION_IDLE_MAINTENANCE_END =
2859 "android.intent.action.ACTION_IDLE_MAINTENANCE_END";
2860
2861 /**
Wei Huang97ecc9c2009-05-11 17:44:20 -07002862 * Broadcast Action: a remote intent is to be broadcasted.
2863 *
2864 * A remote intent is used for remote RPC between devices. The remote intent
2865 * is serialized and sent from one device to another device. The receiving
2866 * device parses the remote intent and broadcasts it. Note that anyone can
2867 * broadcast a remote intent. However, if the intent receiver of the remote intent
2868 * does not trust intent broadcasts from arbitrary intent senders, it should require
2869 * the sender to hold certain permissions so only trusted sender's broadcast will be
2870 * let through.
Dianne Hackbornedd93162009-09-19 14:03:05 -07002871 * @hide
Wei Huang97ecc9c2009-05-11 17:44:20 -07002872 */
2873 public static final String ACTION_REMOTE_INTENT =
Costin Manolache8d83f9e2010-05-12 16:04:10 -07002874 "com.google.android.c2dm.intent.RECEIVE";
Wei Huang97ecc9c2009-05-11 17:44:20 -07002875
Dianne Hackborn9acc0302009-08-25 00:27:12 -07002876 /**
Jeff Sharkeybd91e2f2016-03-22 15:32:31 -06002877 * Broadcast Action: This is broadcast once when the user is booting after a
2878 * system update. It can be used to perform cleanup or upgrades after a
2879 * system update.
2880 * <p>
2881 * This broadcast is sent after the {@link #ACTION_LOCKED_BOOT_COMPLETED}
2882 * broadcast but before the {@link #ACTION_BOOT_COMPLETED} broadcast. It's
2883 * only sent when the {@link Build#FINGERPRINT} has changed, and it's only
2884 * sent to receivers in the system image.
Dianne Hackborn9acc0302009-08-25 00:27:12 -07002885 *
Dianne Hackborn9acc0302009-08-25 00:27:12 -07002886 * @hide
2887 */
Amith Yamasanicbabb8d2017-02-17 16:50:05 -08002888 @SystemApi
Dianne Hackborn9acc0302009-08-25 00:27:12 -07002889 public static final String ACTION_PRE_BOOT_COMPLETED =
2890 "android.intent.action.PRE_BOOT_COMPLETED";
2891
Amith Yamasani13593602012-03-22 16:16:17 -07002892 /**
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08002893 * Broadcast to a specific application to query any supported restrictions to impose
Amith Yamasani7e99bc02013-04-16 18:24:51 -07002894 * on restricted users. The broadcast intent contains an extra
2895 * {@link #EXTRA_RESTRICTIONS_BUNDLE} with the currently persisted
2896 * restrictions as a Bundle of key/value pairs. The value types can be Boolean, String or
2897 * String[] depending on the restriction type.<p/>
2898 * The response should contain an extra {@link #EXTRA_RESTRICTIONS_LIST},
Amith Yamasani86118ba2013-03-28 14:33:16 -07002899 * which is of type <code>ArrayList&lt;RestrictionEntry&gt;</code>. It can also
2900 * contain an extra {@link #EXTRA_RESTRICTIONS_INTENT}, which is of type <code>Intent</code>.
2901 * The activity specified by that intent will be launched for a result which must contain
Amith Yamasani3b458ad2013-04-18 18:40:07 -07002902 * one of the extras {@link #EXTRA_RESTRICTIONS_LIST} or {@link #EXTRA_RESTRICTIONS_BUNDLE}.
2903 * The keys and values of the returned restrictions will be persisted.
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08002904 * @see RestrictionEntry
2905 */
2906 public static final String ACTION_GET_RESTRICTION_ENTRIES =
2907 "android.intent.action.GET_RESTRICTION_ENTRIES";
2908
2909 /**
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002910 * Sent the first time a user is starting, to allow system apps to
2911 * perform one time initialization. (This will not be seen by third
2912 * party applications because a newly initialized user does not have any
2913 * third party applications installed for it.) This is sent early in
2914 * starting the user, around the time the home app is started, before
Dianne Hackborn36d337a2012-10-08 14:33:47 -07002915 * {@link #ACTION_BOOT_COMPLETED} is sent. This is sent as a foreground
2916 * broadcast, since it is part of a visible user interaction; be as quick
2917 * as possible when handling it.
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002918 */
2919 public static final String ACTION_USER_INITIALIZE =
2920 "android.intent.action.USER_INITIALIZE";
2921
2922 /**
2923 * Sent when a user switch is happening, causing the process's user to be
2924 * brought to the foreground. This is only sent to receivers registered
2925 * through {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
2926 * Context.registerReceiver}. It is sent to the user that is going to the
Dianne Hackborn36d337a2012-10-08 14:33:47 -07002927 * foreground. This is sent as a foreground
2928 * broadcast, since it is part of a visible user interaction; be as quick
2929 * as possible when handling it.
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002930 */
2931 public static final String ACTION_USER_FOREGROUND =
2932 "android.intent.action.USER_FOREGROUND";
2933
2934 /**
2935 * Sent when a user switch is happening, causing the process's user to be
2936 * sent to the background. This is only sent to receivers registered
2937 * through {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
2938 * Context.registerReceiver}. It is sent to the user that is going to the
Dianne Hackborn36d337a2012-10-08 14:33:47 -07002939 * background. This is sent as a foreground
2940 * broadcast, since it is part of a visible user interaction; be as quick
2941 * as possible when handling it.
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002942 */
2943 public static final String ACTION_USER_BACKGROUND =
2944 "android.intent.action.USER_BACKGROUND";
2945
2946 /**
Dianne Hackborn36d337a2012-10-08 14:33:47 -07002947 * Broadcast sent to the system when a user is added. Carries an extra
2948 * EXTRA_USER_HANDLE that has the userHandle of the new user. It is sent to
2949 * all running users. You must hold
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002950 * {@link android.Manifest.permission#MANAGE_USERS} to receive this broadcast.
Amith Yamasani13593602012-03-22 16:16:17 -07002951 * @hide
2952 */
2953 public static final String ACTION_USER_ADDED =
2954 "android.intent.action.USER_ADDED";
2955
2956 /**
Dianne Hackborn36d337a2012-10-08 14:33:47 -07002957 * Broadcast sent by the system when a user is started. Carries an extra
2958 * EXTRA_USER_HANDLE that has the userHandle of the user. This is only sent to
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002959 * registered receivers, not manifest receivers. It is sent to the user
Dianne Hackborn36d337a2012-10-08 14:33:47 -07002960 * that has been started. This is sent as a foreground
2961 * broadcast, since it is part of a visible user interaction; be as quick
2962 * as possible when handling it.
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002963 * @hide
2964 */
2965 public static final String ACTION_USER_STARTED =
2966 "android.intent.action.USER_STARTED";
2967
2968 /**
Dianne Hackborn36d337a2012-10-08 14:33:47 -07002969 * Broadcast sent when a user is in the process of starting. Carries an extra
2970 * EXTRA_USER_HANDLE that has the userHandle of the user. This is only
2971 * sent to registered receivers, not manifest receivers. It is sent to all
2972 * users (including the one that is being started). You must hold
2973 * {@link android.Manifest.permission#INTERACT_ACROSS_USERS} to receive
2974 * this broadcast. This is sent as a background broadcast, since
2975 * its result is not part of the primary UX flow; to safely keep track of
2976 * started/stopped state of a user you can use this in conjunction with
2977 * {@link #ACTION_USER_STOPPING}. It is <b>not</b> generally safe to use with
2978 * other user state broadcasts since those are foreground broadcasts so can
2979 * execute in a different order.
2980 * @hide
2981 */
2982 public static final String ACTION_USER_STARTING =
2983 "android.intent.action.USER_STARTING";
2984
2985 /**
2986 * Broadcast sent when a user is going to be stopped. Carries an extra
2987 * EXTRA_USER_HANDLE that has the userHandle of the user. This is only
2988 * sent to registered receivers, not manifest receivers. It is sent to all
2989 * users (including the one that is being stopped). You must hold
2990 * {@link android.Manifest.permission#INTERACT_ACROSS_USERS} to receive
2991 * this broadcast. The user will not stop until all receivers have
2992 * handled the broadcast. This is sent as a background broadcast, since
2993 * its result is not part of the primary UX flow; to safely keep track of
2994 * started/stopped state of a user you can use this in conjunction with
2995 * {@link #ACTION_USER_STARTING}. It is <b>not</b> generally safe to use with
2996 * other user state broadcasts since those are foreground broadcasts so can
2997 * execute in a different order.
2998 * @hide
2999 */
3000 public static final String ACTION_USER_STOPPING =
3001 "android.intent.action.USER_STOPPING";
3002
3003 /**
3004 * Broadcast sent to the system when a user is stopped. Carries an extra
3005 * EXTRA_USER_HANDLE that has the userHandle of the user. This is similar to
3006 * {@link #ACTION_PACKAGE_RESTARTED}, but for an entire user instead of a
3007 * specific package. This is only sent to registered receivers, not manifest
3008 * receivers. It is sent to all running users <em>except</em> the one that
3009 * has just been stopped (which is no longer running).
Dianne Hackborn80a4af22012-08-27 19:18:31 -07003010 * @hide
3011 */
3012 public static final String ACTION_USER_STOPPED =
3013 "android.intent.action.USER_STOPPED";
3014
3015 /**
Amith Yamasani2a003292012-08-14 18:25:45 -07003016 * 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 -07003017 * the userHandle of the user. It is sent to all running users except the
Amith Yamasanidb6a14c2012-10-17 21:16:52 -07003018 * one that has been removed. The user will not be completely removed until all receivers have
3019 * handled the broadcast. You must hold
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07003020 * {@link android.Manifest.permission#MANAGE_USERS} to receive this broadcast.
Amith Yamasani13593602012-03-22 16:16:17 -07003021 * @hide
3022 */
3023 public static final String ACTION_USER_REMOVED =
3024 "android.intent.action.USER_REMOVED";
3025
3026 /**
Amith Yamasani2a003292012-08-14 18:25:45 -07003027 * Broadcast sent to the system when the user switches. Carries an extra EXTRA_USER_HANDLE that has
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07003028 * the userHandle of the user to become the current one. This is only sent to
3029 * registered receivers, not manifest receivers. It is sent to all running users.
3030 * You must hold
3031 * {@link android.Manifest.permission#MANAGE_USERS} to receive this broadcast.
Amith Yamasani13593602012-03-22 16:16:17 -07003032 * @hide
3033 */
3034 public static final String ACTION_USER_SWITCHED =
3035 "android.intent.action.USER_SWITCHED";
3036
Amith Yamasanie928d7d2012-09-17 21:46:51 -07003037 /**
Jeff Sharkey8924e872015-11-30 12:52:10 -07003038 * Broadcast Action: Sent when the credential-encrypted private storage has
3039 * become unlocked for the target user. This is only sent to registered
3040 * receivers, not manifest receivers.
3041 */
3042 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3043 public static final String ACTION_USER_UNLOCKED = "android.intent.action.USER_UNLOCKED";
3044
3045 /**
Amith Yamasanie928d7d2012-09-17 21:46:51 -07003046 * Broadcast sent to the system when a user's information changes. Carries an extra
3047 * {@link #EXTRA_USER_HANDLE} to indicate which user's information changed.
Amith Yamasani6fc1d4e2013-05-08 16:43:58 -07003048 * This is only sent to registered receivers, not manifest receivers. It is sent to all users.
Amith Yamasanie928d7d2012-09-17 21:46:51 -07003049 * @hide
3050 */
3051 public static final String ACTION_USER_INFO_CHANGED =
3052 "android.intent.action.USER_INFO_CHANGED";
3053
Daniel Sandler2e7d25b2012-10-01 16:43:26 -04003054 /**
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01003055 * Broadcast sent to the primary user when an associated managed profile is added (the profile
3056 * was created and is ready to be used). Carries an extra {@link #EXTRA_USER} that specifies
Adam Connorsd4b584e2014-06-09 13:55:47 +01003057 * the UserHandle of the profile that was added. Only applications (for example Launchers)
3058 * that need to display merged content across both primary and managed profiles need to
3059 * worry about this broadcast. This is only sent to registered receivers,
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01003060 * not manifest receivers.
3061 */
3062 public static final String ACTION_MANAGED_PROFILE_ADDED =
3063 "android.intent.action.MANAGED_PROFILE_ADDED";
3064
3065 /**
3066 * Broadcast sent to the primary user when an associated managed profile is removed. Carries an
Adam Connorsd4b584e2014-06-09 13:55:47 +01003067 * extra {@link #EXTRA_USER} that specifies the UserHandle of the profile that was removed.
3068 * Only applications (for example Launchers) that need to display merged content across both
3069 * primary and managed profiles need to worry about this broadcast. This is only sent to
3070 * registered receivers, not manifest receivers.
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01003071 */
3072 public static final String ACTION_MANAGED_PROFILE_REMOVED =
3073 "android.intent.action.MANAGED_PROFILE_REMOVED";
3074
3075 /**
Kenny Guyb1b30262016-02-09 16:02:35 +00003076 * Broadcast sent to the primary user when the credential-encrypted private storage for
3077 * an associated managed profile is unlocked. Carries an extra {@link #EXTRA_USER} that
3078 * specifies the UserHandle of the profile that was unlocked. Only applications (for example
3079 * Launchers) that need to display merged content across both primary and managed profiles
3080 * need to worry about this broadcast. This is only sent to registered receivers,
3081 * not manifest receivers.
3082 */
3083 public static final String ACTION_MANAGED_PROFILE_UNLOCKED =
3084 "android.intent.action.MANAGED_PROFILE_UNLOCKED";
3085
3086 /**
Rubin Xue95057a2016-04-01 16:49:25 +01003087 * Broadcast sent to the primary user when an associated managed profile has become available.
3088 * Currently this includes when the user disables quiet mode for the profile. Carries an extra
Rubin Xuf13c9802016-01-21 18:06:00 +00003089 * {@link #EXTRA_USER} that specifies the UserHandle of the profile. When quiet mode is changed,
3090 * this broadcast will carry a boolean extra {@link #EXTRA_QUIET_MODE} indicating the new state
3091 * of quiet mode. This is only sent to registered receivers, not manifest receivers.
Rubin Xu0a29ecd2015-11-04 15:11:48 +00003092 */
Rubin Xue95057a2016-04-01 16:49:25 +01003093 public static final String ACTION_MANAGED_PROFILE_AVAILABLE =
3094 "android.intent.action.MANAGED_PROFILE_AVAILABLE";
3095
3096 /**
3097 * Broadcast sent to the primary user when an associated managed profile has become unavailable.
3098 * Currently this includes when the user enables quiet mode for the profile. Carries an extra
3099 * {@link #EXTRA_USER} that specifies the UserHandle of the profile. When quiet mode is changed,
3100 * this broadcast will carry a boolean extra {@link #EXTRA_QUIET_MODE} indicating the new state
3101 * of quiet mode. This is only sent to registered receivers, not manifest receivers.
3102 */
3103 public static final String ACTION_MANAGED_PROFILE_UNAVAILABLE =
3104 "android.intent.action.MANAGED_PROFILE_UNAVAILABLE";
Rubin Xu0a29ecd2015-11-04 15:11:48 +00003105
3106 /**
Robin Lee92b83c62016-08-31 13:27:51 +01003107 * Broadcast sent to the system user when the 'device locked' state changes for any user.
3108 * Carries an extra {@link #EXTRA_USER_HANDLE} that specifies the ID of the user for which
3109 * the device was locked or unlocked.
3110 *
3111 * This is only sent to registered receivers.
3112 *
3113 * @hide
3114 */
3115 public static final String ACTION_DEVICE_LOCKED_CHANGED =
3116 "android.intent.action.DEVICE_LOCKED_CHANGED";
3117
3118 /**
Daniel Sandler2e7d25b2012-10-01 16:43:26 -04003119 * Sent when the user taps on the clock widget in the system's "quick settings" area.
3120 */
3121 public static final String ACTION_QUICK_CLOCK =
3122 "android.intent.action.QUICK_CLOCK";
3123
Michael Wright0087a142013-02-05 16:29:39 -08003124 /**
Alan Viverette5a399492014-07-14 16:19:38 -07003125 * Activity Action: Shows the brightness setting dialog.
Michael Wright0087a142013-02-05 16:29:39 -08003126 * @hide
3127 */
3128 public static final String ACTION_SHOW_BRIGHTNESS_DIALOG =
Clara Bayarri847d8682017-03-06 16:48:44 +00003129 "com.android.intent.action.SHOW_BRIGHTNESS_DIALOG";
Michael Wright0087a142013-02-05 16:29:39 -08003130
Justin Kohd378ad72013-04-01 12:18:26 -07003131 /**
3132 * Broadcast Action: A global button was pressed. Includes a single
3133 * extra field, {@link #EXTRA_KEY_EVENT}, containing the key event that
3134 * caused the broadcast.
3135 * @hide
3136 */
3137 public static final String ACTION_GLOBAL_BUTTON = "android.intent.action.GLOBAL_BUTTON";
3138
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003139 /**
Dongwon Kang2034a4c2015-12-14 21:57:34 +09003140 * Broadcast Action: Sent when media resource is granted.
3141 * <p>
3142 * {@link #EXTRA_PACKAGES} specifies the packages on the process holding the media resource
3143 * granted.
3144 * </p>
3145 * <p class="note">
3146 * This is a protected intent that can only be sent by the system.
3147 * </p>
3148 * <p class="note">
Dongwon Kang32cb9ab2016-01-13 18:11:10 -08003149 * This requires {@link android.Manifest.permission#RECEIVE_MEDIA_RESOURCE_USAGE} permission.
Dongwon Kang2034a4c2015-12-14 21:57:34 +09003150 * </p>
3151 *
3152 * @hide
3153 */
3154 public static final String ACTION_MEDIA_RESOURCE_GRANTED =
3155 "android.intent.action.MEDIA_RESOURCE_GRANTED";
3156
3157 /**
MÃ¥rten Kongstadeabc9e92015-12-15 16:40:23 +01003158 * Broadcast Action: An overlay package has been installed. The data
3159 * contains the name of the added overlay package.
3160 * @hide
3161 */
3162 public static final String ACTION_OVERLAY_ADDED = "android.intent.action.OVERLAY_ADDED";
3163
3164 /**
3165 * Broadcast Action: An overlay package has changed. The data contains the
3166 * name of the overlay package which has changed. This is broadcast on all
3167 * changes to the OverlayInfo returned by {@link
3168 * android.content.om.IOverlayManager#getOverlayInfo(String, int)}. The
3169 * most common change is a state change that will change whether the
3170 * overlay is enabled or not.
3171 * @hide
3172 */
3173 public static final String ACTION_OVERLAY_CHANGED = "android.intent.action.OVERLAY_CHANGED";
3174
3175 /**
3176 * Broadcast Action: An overlay package has been removed. The data contains
3177 * the name of the overlay package which has been removed.
3178 * @hide
3179 */
3180 public static final String ACTION_OVERLAY_REMOVED = "android.intent.action.OVERLAY_REMOVED";
3181
3182 /**
3183 * Broadcast Action: The order of a package's list of overlay packages has
3184 * changed. The data contains the package name of the overlay package that
3185 * had its position in the list adjusted.
3186 * @hide
3187 */
3188 public static final String
3189 ACTION_OVERLAY_PRIORITY_CHANGED = "android.intent.action.OVERLAY_PRIORITY_CHANGED";
3190
3191 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003192 * Activity Action: Allow the user to select and return one or more existing
3193 * documents. When invoked, the system will display the various
3194 * {@link DocumentsProvider} instances installed on the device, letting the
3195 * user interactively navigate through them. These documents include local
3196 * media, such as photos and video, and documents provided by installed
3197 * cloud storage providers.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003198 * <p>
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003199 * Each document is represented as a {@code content://} URI backed by a
3200 * {@link DocumentsProvider}, which can be opened as a stream with
3201 * {@link ContentResolver#openFileDescriptor(Uri, String)}, or queried for
3202 * {@link android.provider.DocumentsContract.Document} metadata.
3203 * <p>
3204 * All selected documents are returned to the calling application with
3205 * persistable read and write permission grants. If you want to maintain
3206 * access to the documents across device reboots, you need to explicitly
3207 * take the persistable permissions using
3208 * {@link ContentResolver#takePersistableUriPermission(Uri, int)}.
3209 * <p>
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003210 * Callers must indicate the acceptable document MIME types through
3211 * {@link #setType(String)}. For example, to select photos, use
3212 * {@code image/*}. If multiple disjoint MIME types are acceptable, define
3213 * them in {@link #EXTRA_MIME_TYPES} and {@link #setType(String)} to
3214 * {@literal *}/*.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003215 * <p>
3216 * If the caller can handle multiple returned items (the user performing
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003217 * multiple selection), then you can specify {@link #EXTRA_ALLOW_MULTIPLE}
3218 * to indicate this.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003219 * <p>
Tomasz Mikolajewskia8057a92015-11-16 11:41:28 +09003220 * Callers must include {@link #CATEGORY_OPENABLE} in the Intent to obtain
3221 * URIs that can be opened with
Jeff Sharkeybd3b9022013-08-20 15:20:04 -07003222 * {@link ContentResolver#openFileDescriptor(Uri, String)}.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003223 * <p>
Garfield Tanb44ae612016-11-07 16:46:37 -08003224 * Callers can set a document URI through
3225 * {@link DocumentsContract#EXTRA_INITIAL_URI} to indicate the initial
3226 * location of documents navigator. System will do its best to launch the
3227 * navigator in the specified document if it's a folder, or the folder that
3228 * contains the specified document if not.
Garfield Tan0b3cf662016-10-31 12:59:45 -07003229 * <p>
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003230 * Output: The URI of the item that was picked, returned in
3231 * {@link #getData()}. This must be a {@code content://} URI so that any
3232 * receiver can access it. If multiple documents were selected, they are
3233 * returned in {@link #getClipData()}.
Jeff Sharkeybd3b9022013-08-20 15:20:04 -07003234 *
3235 * @see DocumentsContract
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003236 * @see #ACTION_OPEN_DOCUMENT_TREE
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003237 * @see #ACTION_CREATE_DOCUMENT
3238 * @see #FLAG_GRANT_PERSISTABLE_URI_PERMISSION
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003239 */
3240 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
3241 public static final String ACTION_OPEN_DOCUMENT = "android.intent.action.OPEN_DOCUMENT";
3242
3243 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003244 * Activity Action: Allow the user to create a new document. When invoked,
3245 * the system will display the various {@link DocumentsProvider} instances
3246 * installed on the device, letting the user navigate through them. The
3247 * returned document may be a newly created document with no content, or it
3248 * may be an existing document with the requested MIME type.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003249 * <p>
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003250 * Each document is represented as a {@code content://} URI backed by a
3251 * {@link DocumentsProvider}, which can be opened as a stream with
3252 * {@link ContentResolver#openFileDescriptor(Uri, String)}, or queried for
3253 * {@link android.provider.DocumentsContract.Document} metadata.
3254 * <p>
3255 * Callers must indicate the concrete MIME type of the document being
3256 * created by setting {@link #setType(String)}. This MIME type cannot be
3257 * changed after the document is created.
3258 * <p>
3259 * Callers can provide an initial display name through {@link #EXTRA_TITLE},
3260 * but the user may change this value before creating the file.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003261 * <p>
Tomasz Mikolajewskia8057a92015-11-16 11:41:28 +09003262 * Callers must include {@link #CATEGORY_OPENABLE} in the Intent to obtain
3263 * URIs that can be opened with
Jeff Sharkeybd3b9022013-08-20 15:20:04 -07003264 * {@link ContentResolver#openFileDescriptor(Uri, String)}.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003265 * <p>
Garfield Tanb44ae612016-11-07 16:46:37 -08003266 * Callers can set a document URI through
3267 * {@link DocumentsContract#EXTRA_INITIAL_URI} to indicate the initial
3268 * location of documents navigator. System will do its best to launch the
3269 * navigator in the specified document if it's a folder, or the folder that
3270 * contains the specified document if not.
Garfield Tan0b3cf662016-10-31 12:59:45 -07003271 * <p>
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003272 * Output: The URI of the item that was created. This must be a
3273 * {@code content://} URI so that any receiver can access it.
Jeff Sharkeybd3b9022013-08-20 15:20:04 -07003274 *
3275 * @see DocumentsContract
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003276 * @see #ACTION_OPEN_DOCUMENT
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003277 * @see #ACTION_OPEN_DOCUMENT_TREE
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003278 * @see #FLAG_GRANT_PERSISTABLE_URI_PERMISSION
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003279 */
3280 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
3281 public static final String ACTION_CREATE_DOCUMENT = "android.intent.action.CREATE_DOCUMENT";
3282
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003283 /**
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003284 * Activity Action: Allow the user to pick a directory subtree. When
3285 * invoked, the system will display the various {@link DocumentsProvider}
3286 * instances installed on the device, letting the user navigate through
3287 * them. Apps can fully manage documents within the returned directory.
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003288 * <p>
3289 * To gain access to descendant (child, grandchild, etc) documents, use
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003290 * {@link DocumentsContract#buildDocumentUriUsingTree(Uri, String)} and
3291 * {@link DocumentsContract#buildChildDocumentsUriUsingTree(Uri, String)}
3292 * with the returned URI.
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003293 * <p>
Garfield Tanb44ae612016-11-07 16:46:37 -08003294 * Callers can set a document URI through
3295 * {@link DocumentsContract#EXTRA_INITIAL_URI} to indicate the initial
3296 * location of documents navigator. System will do its best to launch the
3297 * navigator in the specified document if it's a folder, or the folder that
3298 * contains the specified document if not.
Garfield Tan0b3cf662016-10-31 12:59:45 -07003299 * <p>
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003300 * Output: The URI representing the selected directory tree.
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003301 *
3302 * @see DocumentsContract
3303 */
3304 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003305 public static final String
3306 ACTION_OPEN_DOCUMENT_TREE = "android.intent.action.OPEN_DOCUMENT_TREE";
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003307
Felipe Lemec7b1f892016-01-15 15:02:31 -08003308 /**
Peng Xua35b5532016-01-20 00:05:45 -08003309 * Broadcast Action: List of dynamic sensor is changed due to new sensor being connected or
3310 * exisiting sensor being disconnected.
3311 *
3312 * <p class="note">This is a protected intent that can only be sent by the system.</p>
3313 *
3314 * {@hide}
3315 */
3316 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3317 public static final String
3318 ACTION_DYNAMIC_SENSOR_CHANGED = "android.intent.action.DYNAMIC_SENSOR_CHANGED";
3319
Lenka Trochtova73aeea22016-11-18 17:34:34 +01003320 /**
3321 * Deprecated - use {@link #ACTION_FACTORY_RESET} instead.
3322 *
3323 * {@hide}
3324 */
3325 @Deprecated
Jeff Sharkey004a4b22014-09-24 11:45:24 -07003326 public static final String ACTION_MASTER_CLEAR = "android.intent.action.MASTER_CLEAR";
3327
Christopher Tate6597e342015-02-17 12:15:25 -08003328 /**
Amith Yamasanicbabb8d2017-02-17 16:50:05 -08003329 * Broadcast intent sent by the RecoverySystem to inform listeners that a master clear (wipe)
3330 * is about to be performed.
3331 * @hide
3332 */
3333 @SystemApi
3334 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3335 public static final String ACTION_MASTER_CLEAR_NOTIFICATION
3336 = "android.intent.action.MASTER_CLEAR_NOTIFICATION";
3337
3338 /**
Lenka Trochtova73aeea22016-11-18 17:34:34 +01003339 * Boolean intent extra to be used with {@link #ACTION_MASTER_CLEAR} in order to force a factory
3340 * reset even if {@link android.os.UserManager#DISALLOW_FACTORY_RESET} is set.
3341 *
3342 * <p>Deprecated - use {@link #EXTRA_FORCE_FACTORY_RESET} instead.
3343 *
Benjamin Franzf9d5e6a2016-05-26 14:24:29 +01003344 * @hide
3345 */
Lenka Trochtova73aeea22016-11-18 17:34:34 +01003346 @Deprecated
Benjamin Franzf9d5e6a2016-05-26 14:24:29 +01003347 public static final String EXTRA_FORCE_MASTER_CLEAR =
3348 "android.intent.extra.FORCE_MASTER_CLEAR";
3349
3350 /**
Lenka Trochtova73aeea22016-11-18 17:34:34 +01003351 * A broadcast action to trigger a factory reset.
3352 *
3353 * <p> The sender must hold the {@link android.Manifest.permission#MASTER_CLEAR} permission.
3354 *
3355 * <p>Not for use by third-party applications.
3356 *
3357 * @see #EXTRA_FORCE_MASTER_CLEAR
3358 *
3359 * {@hide}
3360 */
3361 @SystemApi
3362 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3363 public static final String ACTION_FACTORY_RESET = "android.intent.action.FACTORY_RESET";
3364
3365 /**
3366 * Boolean intent extra to be used with {@link #ACTION_MASTER_CLEAR} in order to force a factory
3367 * reset even if {@link android.os.UserManager#DISALLOW_FACTORY_RESET} is set.
3368 *
3369 * <p>Not for use by third-party applications.
3370 *
3371 * @hide
3372 */
3373 @SystemApi
3374 public static final String EXTRA_FORCE_FACTORY_RESET =
3375 "android.intent.extra.FORCE_FACTORY_RESET";
3376
3377 /**
Christopher Tate6597e342015-02-17 12:15:25 -08003378 * Broadcast action: report that a settings element is being restored from backup. The intent
3379 * contains three extras: EXTRA_SETTING_NAME is a string naming the restored setting,
3380 * EXTRA_SETTING_NEW_VALUE is the value being restored, and EXTRA_SETTING_PREVIOUS_VALUE
3381 * is the value of that settings entry prior to the restore operation. All of these values are
3382 * represented as strings.
3383 *
3384 * <p>This broadcast is sent only for settings provider entries known to require special handling
3385 * around restore time. These entries are found in the BROADCAST_ON_RESTORE table within
3386 * the provider's backup agent implementation.
3387 *
3388 * @see #EXTRA_SETTING_NAME
3389 * @see #EXTRA_SETTING_PREVIOUS_VALUE
3390 * @see #EXTRA_SETTING_NEW_VALUE
3391 * {@hide}
3392 */
3393 public static final String ACTION_SETTING_RESTORED = "android.os.action.SETTING_RESTORED";
3394
3395 /** {@hide} */
3396 public static final String EXTRA_SETTING_NAME = "setting_name";
3397 /** {@hide} */
3398 public static final String EXTRA_SETTING_PREVIOUS_VALUE = "previous_value";
3399 /** {@hide} */
3400 public static final String EXTRA_SETTING_NEW_VALUE = "new_value";
3401
Clara Bayarri0a26157a2015-03-26 18:38:55 +00003402 /**
3403 * Activity Action: Process a piece of text.
3404 * <p>Input: {@link #EXTRA_PROCESS_TEXT} contains the text to be processed.
3405 * {@link #EXTRA_PROCESS_TEXT_READONLY} states if the resulting text will be read-only.</p>
3406 * <p>Output: {@link #EXTRA_PROCESS_TEXT} contains the processed text.</p>
3407 */
3408 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
3409 public static final String ACTION_PROCESS_TEXT = "android.intent.action.PROCESS_TEXT";
Amith Yamasanicbabb8d2017-02-17 16:50:05 -08003410
3411 /**
3412 * Broadcast Action: The sim card state has changed.
3413 * For more details see TelephonyIntents.ACTION_SIM_STATE_CHANGED. This is here
3414 * because TelephonyIntents is an internal class.
3415 * @hide
3416 */
3417 @SystemApi
3418 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3419 public static final String ACTION_SIM_STATE_CHANGED = "android.intent.action.SIM_STATE_CHANGED";
3420
Clara Bayarri0a26157a2015-03-26 18:38:55 +00003421 /**
Clara Bayarri92c8e6f2015-05-21 17:50:08 +01003422 * The name of the extra used to define the text to be processed, as a
3423 * CharSequence. Note that this may be a styled CharSequence, so you must use
3424 * {@link Bundle#getCharSequence(String) Bundle.getCharSequence()} to retrieve it.
Clara Bayarri0a26157a2015-03-26 18:38:55 +00003425 */
3426 public static final String EXTRA_PROCESS_TEXT = "android.intent.extra.PROCESS_TEXT";
3427 /**
Clara Bayarri92c8e6f2015-05-21 17:50:08 +01003428 * 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 +00003429 */
3430 public static final String EXTRA_PROCESS_TEXT_READONLY =
3431 "android.intent.extra.PROCESS_TEXT_READONLY";
3432
Bryce Leebc58f592015-09-25 16:43:01 -07003433 /**
3434 * Broadcast action: reports when a new thermal event has been reached. When the device
3435 * is reaching its maximum temperatue, the thermal level reported
3436 * {@hide}
3437 */
3438 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
3439 public static final String ACTION_THERMAL_EVENT = "android.intent.action.THERMAL_EVENT";
3440
3441 /** {@hide} */
3442 public static final String EXTRA_THERMAL_STATE = "android.intent.extra.THERMAL_STATE";
3443
3444 /**
3445 * Thermal state when the device is normal. This state is sent in the
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08003446 * {@link #ACTION_THERMAL_EVENT} broadcast as {@link #EXTRA_THERMAL_STATE}.
Bryce Leebc58f592015-09-25 16:43:01 -07003447 * {@hide}
3448 */
3449 public static final int EXTRA_THERMAL_STATE_NORMAL = 0;
3450
3451 /**
3452 * Thermal state where the device is approaching its maximum threshold. This state is sent in
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08003453 * the {@link #ACTION_THERMAL_EVENT} broadcast as {@link #EXTRA_THERMAL_STATE}.
Bryce Leebc58f592015-09-25 16:43:01 -07003454 * {@hide}
3455 */
3456 public static final int EXTRA_THERMAL_STATE_WARNING = 1;
3457
3458 /**
3459 * Thermal state where the device has reached its maximum threshold. This state is sent in the
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08003460 * {@link #ACTION_THERMAL_EVENT} broadcast as {@link #EXTRA_THERMAL_STATE}.
Bryce Leebc58f592015-09-25 16:43:01 -07003461 * {@hide}
3462 */
3463 public static final int EXTRA_THERMAL_STATE_EXCEEDED = 2;
3464
3465
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003466 // ---------------------------------------------------------------------
3467 // ---------------------------------------------------------------------
3468 // Standard intent categories (see addCategory()).
3469
3470 /**
3471 * Set if the activity should be an option for the default action
3472 * (center press) to perform on a piece of data. Setting this will
3473 * hide from the user any activities without it set when performing an
John Spurlock6098c5d2013-06-17 10:32:46 -04003474 * action on some data. Note that this is normally -not- set in the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003475 * Intent when initiating an action -- it is for use in intent filters
3476 * specified in packages.
3477 */
3478 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3479 public static final String CATEGORY_DEFAULT = "android.intent.category.DEFAULT";
3480 /**
3481 * Activities that can be safely invoked from a browser must support this
3482 * category. For example, if the user is viewing a web page or an e-mail
3483 * and clicks on a link in the text, the Intent generated execute that
3484 * link will require the BROWSABLE category, so that only activities
3485 * supporting this category will be considered as possible actions. By
3486 * supporting this category, you are promising that there is nothing
3487 * damaging (without user intervention) that can happen by invoking any
3488 * matching Intent.
3489 */
3490 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3491 public static final String CATEGORY_BROWSABLE = "android.intent.category.BROWSABLE";
3492 /**
Dianne Hackborn91097de2014-04-04 18:02:06 -07003493 * Categories for activities that can participate in voice interaction.
3494 * An activity that supports this category must be prepared to run with
3495 * no UI shown at all (though in some case it may have a UI shown), and
3496 * rely on {@link android.app.VoiceInteractor} to interact with the user.
3497 */
3498 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3499 public static final String CATEGORY_VOICE = "android.intent.category.VOICE";
3500 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003501 * Set if the activity should be considered as an alternative action to
3502 * the data the user is currently viewing. See also
3503 * {@link #CATEGORY_SELECTED_ALTERNATIVE} for an alternative action that
3504 * applies to the selection in a list of items.
3505 *
3506 * <p>Supporting this category means that you would like your activity to be
3507 * displayed in the set of alternative things the user can do, usually as
3508 * part of the current activity's options menu. You will usually want to
3509 * include a specific label in the &lt;intent-filter&gt; of this action
3510 * describing to the user what it does.
3511 *
3512 * <p>The action of IntentFilter with this category is important in that it
3513 * describes the specific action the target will perform. This generally
3514 * should not be a generic action (such as {@link #ACTION_VIEW}, but rather
3515 * a specific name such as "com.android.camera.action.CROP. Only one
3516 * alternative of any particular action will be shown to the user, so using
3517 * a specific action like this makes sure that your alternative will be
3518 * displayed while also allowing other applications to provide their own
3519 * overrides of that particular action.
3520 */
3521 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3522 public static final String CATEGORY_ALTERNATIVE = "android.intent.category.ALTERNATIVE";
3523 /**
3524 * Set if the activity should be considered as an alternative selection
3525 * action to the data the user has currently selected. This is like
3526 * {@link #CATEGORY_ALTERNATIVE}, but is used in activities showing a list
3527 * of items from which the user can select, giving them alternatives to the
3528 * default action that will be performed on it.
3529 */
3530 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3531 public static final String CATEGORY_SELECTED_ALTERNATIVE = "android.intent.category.SELECTED_ALTERNATIVE";
3532 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09003533 * Intended to be used as a tab inside of a containing TabActivity.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003534 */
3535 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3536 public static final String CATEGORY_TAB = "android.intent.category.TAB";
3537 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003538 * Should be displayed in the top-level launcher.
3539 */
3540 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3541 public static final String CATEGORY_LAUNCHER = "android.intent.category.LAUNCHER";
3542 /**
Jose Lima38b75b62014-03-11 10:41:39 -07003543 * Indicates an activity optimized for Leanback mode, and that should
3544 * be displayed in the Leanback launcher.
3545 */
3546 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3547 public static final String CATEGORY_LEANBACK_LAUNCHER = "android.intent.category.LEANBACK_LAUNCHER";
3548 /**
Jose Lima73915cf2014-07-29 17:16:31 -07003549 * Indicates a Leanback settings activity to be displayed in the Leanback launcher.
3550 * @hide
3551 */
3552 @SystemApi
3553 public static final String CATEGORY_LEANBACK_SETTINGS = "android.intent.category.LEANBACK_SETTINGS";
3554 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003555 * Provides information about the package it is in; typically used if
3556 * a package does not contain a {@link #CATEGORY_LAUNCHER} to provide
3557 * a front-door to the user without having to be shown in the all apps list.
3558 */
3559 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3560 public static final String CATEGORY_INFO = "android.intent.category.INFO";
3561 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003562 * This is the home activity, that is the first activity that is displayed
3563 * when the device boots.
3564 */
3565 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3566 public static final String CATEGORY_HOME = "android.intent.category.HOME";
3567 /**
Anthony Hugh979b81a2015-09-29 16:50:35 -07003568 * This is the home activity that is displayed when the device is finished setting up and ready
3569 * for use.
3570 * @hide
3571 */
3572 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3573 public static final String CATEGORY_HOME_MAIN = "android.intent.category.HOME_MAIN";
3574 /**
Svet Ganov50a8bf42015-07-15 11:04:18 -07003575 * This is the setup wizard activity, that is the first activity that is displayed
3576 * when the user sets up the device for the first time.
3577 * @hide
3578 */
3579 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3580 public static final String CATEGORY_SETUP_WIZARD = "android.intent.category.SETUP_WIZARD";
3581 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003582 * This activity is a preference panel.
3583 */
3584 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3585 public static final String CATEGORY_PREFERENCE = "android.intent.category.PREFERENCE";
3586 /**
3587 * This activity is a development preference panel.
3588 */
3589 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3590 public static final String CATEGORY_DEVELOPMENT_PREFERENCE = "android.intent.category.DEVELOPMENT_PREFERENCE";
3591 /**
3592 * Capable of running inside a parent activity container.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003593 */
3594 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3595 public static final String CATEGORY_EMBED = "android.intent.category.EMBED";
3596 /**
Patrick Dubroy6dabe242010-08-30 10:43:47 -07003597 * This activity allows the user to browse and download new applications.
3598 */
3599 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3600 public static final String CATEGORY_APP_MARKET = "android.intent.category.APP_MARKET";
3601 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003602 * This activity may be exercised by the monkey or other automated test tools.
3603 */
3604 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3605 public static final String CATEGORY_MONKEY = "android.intent.category.MONKEY";
3606 /**
3607 * To be used as a test (not part of the normal user experience).
3608 */
3609 public static final String CATEGORY_TEST = "android.intent.category.TEST";
3610 /**
3611 * To be used as a unit test (run through the Test Harness).
3612 */
3613 public static final String CATEGORY_UNIT_TEST = "android.intent.category.UNIT_TEST";
3614 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09003615 * To be used as a sample code example (not part of the normal user
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003616 * experience).
3617 */
3618 public static final String CATEGORY_SAMPLE_CODE = "android.intent.category.SAMPLE_CODE";
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003619
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003620 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003621 * Used to indicate that an intent only wants URIs that can be opened with
3622 * {@link ContentResolver#openFileDescriptor(Uri, String)}. Openable URIs
3623 * must support at least the columns defined in {@link OpenableColumns} when
3624 * queried.
3625 *
3626 * @see #ACTION_GET_CONTENT
3627 * @see #ACTION_OPEN_DOCUMENT
3628 * @see #ACTION_CREATE_DOCUMENT
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003629 */
3630 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3631 public static final String CATEGORY_OPENABLE = "android.intent.category.OPENABLE";
3632
3633 /**
Tomasz Mikolajewski28a815c2016-10-28 15:54:11 +09003634 * Used to indicate that an intent filter can accept files which are not necessarily
3635 * openable by {@link ContentResolver#openFileDescriptor(Uri, String)}, but
3636 * at least streamable via
3637 * {@link ContentResolver#openTypedAssetFileDescriptor(Uri, String, Bundle)}
3638 * using one of the stream types exposed via
3639 * {@link ContentResolver#getStreamTypes(Uri, String)}.
3640 *
3641 * @see #ACTION_SEND
3642 * @see #ACTION_SEND_MULTIPLE
3643 */
3644 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3645 public static final String CATEGORY_TYPED_OPENABLE =
3646 "android.intent.category.TYPED_OPENABLE";
3647
3648 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003649 * To be used as code under test for framework instrumentation tests.
3650 */
3651 public static final String CATEGORY_FRAMEWORK_INSTRUMENTATION_TEST =
3652 "android.intent.category.FRAMEWORK_INSTRUMENTATION_TEST";
Mike Lockwood9092ab42009-09-16 13:01:32 -04003653 /**
3654 * An activity to run when device is inserted into a car dock.
Dianne Hackborn7299c412010-03-04 18:41:49 -08003655 * Used with {@link #ACTION_MAIN} to launch an activity. For more
3656 * information, see {@link android.app.UiModeManager}.
Mike Lockwood9092ab42009-09-16 13:01:32 -04003657 */
3658 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3659 public static final String CATEGORY_CAR_DOCK = "android.intent.category.CAR_DOCK";
3660 /**
3661 * An activity to run when device is inserted into a car dock.
Dianne Hackborn7299c412010-03-04 18:41:49 -08003662 * Used with {@link #ACTION_MAIN} to launch an activity. For more
3663 * information, see {@link android.app.UiModeManager}.
Mike Lockwood9092ab42009-09-16 13:01:32 -04003664 */
3665 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3666 public static final String CATEGORY_DESK_DOCK = "android.intent.category.DESK_DOCK";
Praveen Bharathi21e941b2010-10-06 15:23:14 -05003667 /**
3668 * An activity to run when device is inserted into a analog (low end) dock.
3669 * Used with {@link #ACTION_MAIN} to launch an activity. For more
3670 * information, see {@link android.app.UiModeManager}.
3671 */
3672 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3673 public static final String CATEGORY_LE_DESK_DOCK = "android.intent.category.LE_DESK_DOCK";
3674
3675 /**
3676 * An activity to run when device is inserted into a digital (high end) dock.
3677 * Used with {@link #ACTION_MAIN} to launch an activity. For more
3678 * information, see {@link android.app.UiModeManager}.
3679 */
3680 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3681 public static final String CATEGORY_HE_DESK_DOCK = "android.intent.category.HE_DESK_DOCK";
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05003682
Bernd Holzheyaea4b672010-03-31 09:46:13 +02003683 /**
3684 * Used to indicate that the activity can be used in a car environment.
3685 */
3686 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3687 public static final String CATEGORY_CAR_MODE = "android.intent.category.CAR_MODE";
3688
Zak Cohendb6ca492017-01-26 14:09:00 -08003689 /**
3690 * An activity to use for the launcher when the device is placed in a VR Headset viewer.
3691 * Used with {@link #ACTION_MAIN} to launch an activity. For more
3692 * information, see {@link android.app.UiModeManager}.
3693 */
3694 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3695 public static final String CATEGORY_VR_HOME = "android.intent.category.VR_HOME";
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003696 // ---------------------------------------------------------------------
3697 // ---------------------------------------------------------------------
Jeff Brown6651a632011-11-28 12:59:11 -08003698 // Application launch intent categories (see addCategory()).
3699
3700 /**
3701 * Used with {@link #ACTION_MAIN} to launch the browser application.
3702 * The activity should be able to browse the Internet.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003703 * <p>NOTE: This should not be used as the primary key of an Intent,
3704 * since it will not result in the app launching with the correct
3705 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003706 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003707 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003708 */
3709 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3710 public static final String CATEGORY_APP_BROWSER = "android.intent.category.APP_BROWSER";
3711
3712 /**
3713 * Used with {@link #ACTION_MAIN} to launch the calculator application.
3714 * The activity should be able to perform standard arithmetic operations.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003715 * <p>NOTE: This should not be used as the primary key of an Intent,
3716 * since it will not result in the app launching with the correct
3717 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003718 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003719 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003720 */
3721 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3722 public static final String CATEGORY_APP_CALCULATOR = "android.intent.category.APP_CALCULATOR";
3723
3724 /**
3725 * Used with {@link #ACTION_MAIN} to launch the calendar application.
3726 * The activity should be able to view and manipulate calendar entries.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003727 * <p>NOTE: This should not be used as the primary key of an Intent,
3728 * since it will not result in the app launching with the correct
3729 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003730 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003731 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003732 */
3733 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3734 public static final String CATEGORY_APP_CALENDAR = "android.intent.category.APP_CALENDAR";
3735
3736 /**
3737 * Used with {@link #ACTION_MAIN} to launch the contacts application.
3738 * The activity should be able to view and manipulate address book entries.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003739 * <p>NOTE: This should not be used as the primary key of an Intent,
3740 * since it will not result in the app launching with the correct
3741 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003742 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003743 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003744 */
3745 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3746 public static final String CATEGORY_APP_CONTACTS = "android.intent.category.APP_CONTACTS";
3747
3748 /**
3749 * Used with {@link #ACTION_MAIN} to launch the email application.
3750 * The activity should be able to send and receive email.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003751 * <p>NOTE: This should not be used as the primary key of an Intent,
3752 * since it will not result in the app launching with the correct
3753 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003754 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003755 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003756 */
3757 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3758 public static final String CATEGORY_APP_EMAIL = "android.intent.category.APP_EMAIL";
3759
3760 /**
3761 * Used with {@link #ACTION_MAIN} to launch the gallery application.
3762 * The activity should be able to view and manipulate image and video files
3763 * stored on the device.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003764 * <p>NOTE: This should not be used as the primary key of an Intent,
3765 * since it will not result in the app launching with the correct
3766 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003767 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003768 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003769 */
3770 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3771 public static final String CATEGORY_APP_GALLERY = "android.intent.category.APP_GALLERY";
3772
3773 /**
3774 * Used with {@link #ACTION_MAIN} to launch the maps application.
3775 * The activity should be able to show the user's current location and surroundings.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003776 * <p>NOTE: This should not be used as the primary key of an Intent,
3777 * since it will not result in the app launching with the correct
3778 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003779 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003780 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003781 */
3782 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3783 public static final String CATEGORY_APP_MAPS = "android.intent.category.APP_MAPS";
3784
3785 /**
3786 * Used with {@link #ACTION_MAIN} to launch the messaging application.
3787 * The activity should be able to send and receive text messages.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003788 * <p>NOTE: This should not be used as the primary key of an Intent,
3789 * since it will not result in the app launching with the correct
3790 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003791 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003792 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003793 */
3794 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3795 public static final String CATEGORY_APP_MESSAGING = "android.intent.category.APP_MESSAGING";
3796
3797 /**
3798 * Used with {@link #ACTION_MAIN} to launch the music application.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003799 * The activity should be able to play, browse, or manipulate music files
3800 * stored on the device.
3801 * <p>NOTE: This should not be used as the primary key of an Intent,
3802 * since it will not result in the app launching with the correct
3803 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003804 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003805 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003806 */
3807 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3808 public static final String CATEGORY_APP_MUSIC = "android.intent.category.APP_MUSIC";
3809
3810 // ---------------------------------------------------------------------
3811 // ---------------------------------------------------------------------
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003812 // Standard extra data keys.
3813
3814 /**
3815 * The initial data to place in a newly created record. Use with
3816 * {@link #ACTION_INSERT}. The data here is a Map containing the same
3817 * fields as would be given to the underlying ContentProvider.insert()
3818 * call.
3819 */
3820 public static final String EXTRA_TEMPLATE = "android.intent.extra.TEMPLATE";
3821
3822 /**
3823 * A constant CharSequence that is associated with the Intent, used with
3824 * {@link #ACTION_SEND} to supply the literal data to be sent. Note that
3825 * this may be a styled CharSequence, so you must use
3826 * {@link Bundle#getCharSequence(String) Bundle.getCharSequence()} to
3827 * retrieve it.
3828 */
3829 public static final String EXTRA_TEXT = "android.intent.extra.TEXT";
3830
3831 /**
Dianne Hackbornacb69bb2012-04-13 15:36:06 -07003832 * A constant String that is associated with the Intent, used with
3833 * {@link #ACTION_SEND} to supply an alternative to {@link #EXTRA_TEXT}
3834 * as HTML formatted text. Note that you <em>must</em> also supply
3835 * {@link #EXTRA_TEXT}.
3836 */
3837 public static final String EXTRA_HTML_TEXT = "android.intent.extra.HTML_TEXT";
3838
3839 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003840 * A content: URI holding a stream of data associated with the Intent,
3841 * used with {@link #ACTION_SEND} to supply the data being sent.
3842 */
3843 public static final String EXTRA_STREAM = "android.intent.extra.STREAM";
3844
3845 /**
3846 * A String[] holding e-mail addresses that should be delivered to.
3847 */
3848 public static final String EXTRA_EMAIL = "android.intent.extra.EMAIL";
3849
3850 /**
3851 * A String[] holding e-mail addresses that should be carbon copied.
3852 */
3853 public static final String EXTRA_CC = "android.intent.extra.CC";
3854
3855 /**
3856 * A String[] holding e-mail addresses that should be blind carbon copied.
3857 */
3858 public static final String EXTRA_BCC = "android.intent.extra.BCC";
3859
3860 /**
3861 * A constant string holding the desired subject line of a message.
3862 */
3863 public static final String EXTRA_SUBJECT = "android.intent.extra.SUBJECT";
3864
3865 /**
3866 * An Intent describing the choices you would like shown with
Adam Powell2ed547e2015-04-29 18:45:04 -07003867 * {@link #ACTION_PICK_ACTIVITY} or {@link #ACTION_CHOOSER}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003868 */
3869 public static final String EXTRA_INTENT = "android.intent.extra.INTENT";
3870
3871 /**
Clara Bayarrif7fea162015-10-22 16:09:52 +01003872 * An int representing the user id to be used.
3873 *
3874 * @hide
3875 */
3876 public static final String EXTRA_USER_ID = "android.intent.extra.USER_ID";
3877
3878 /**
Clara Bayarriea9b10e2015-12-04 15:36:26 +00003879 * An int representing the task id to be retrieved. This is used when a launch from recents is
3880 * intercepted by another action such as credentials confirmation to remember which task should
3881 * be resumed when complete.
3882 *
3883 * @hide
3884 */
3885 public static final String EXTRA_TASK_ID = "android.intent.extra.TASK_ID";
3886
3887 /**
Adam Powell2ed547e2015-04-29 18:45:04 -07003888 * An Intent[] describing additional, alternate choices you would like shown with
3889 * {@link #ACTION_CHOOSER}.
3890 *
3891 * <p>An app may be capable of providing several different payload types to complete a
3892 * user's intended action. For example, an app invoking {@link #ACTION_SEND} to share photos
3893 * with another app may use EXTRA_ALTERNATE_INTENTS to have the chooser transparently offer
3894 * several different supported sending mechanisms for sharing, such as the actual "image/*"
3895 * photo data or a hosted link where the photos can be viewed.</p>
3896 *
3897 * <p>The intent present in {@link #EXTRA_INTENT} will be treated as the
3898 * first/primary/preferred intent in the set. Additional intents specified in
3899 * this extra are ordered; by default intents that appear earlier in the array will be
3900 * preferred over intents that appear later in the array as matches for the same
3901 * target component. To alter this preference, a calling app may also supply
3902 * {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER}.</p>
3903 */
3904 public static final String EXTRA_ALTERNATE_INTENTS = "android.intent.extra.ALTERNATE_INTENTS";
3905
3906 /**
Adam Powell52c39212016-04-07 15:14:18 -07003907 * A {@link ComponentName ComponentName[]} describing components that should be filtered out
3908 * and omitted from a list of components presented to the user.
3909 *
3910 * <p>When used with {@link #ACTION_CHOOSER}, the chooser will omit any of the components
3911 * in this array if it otherwise would have shown them. Useful for omitting specific targets
3912 * from your own package or other apps from your organization if the idea of sending to those
3913 * targets would be redundant with other app functionality. Filtered components will not
3914 * be able to present targets from an associated <code>ChooserTargetService</code>.</p>
3915 */
3916 public static final String EXTRA_EXCLUDE_COMPONENTS
3917 = "android.intent.extra.EXCLUDE_COMPONENTS";
3918
3919 /**
3920 * A {@link android.service.chooser.ChooserTarget ChooserTarget[]} for {@link #ACTION_CHOOSER}
3921 * describing additional high-priority deep-link targets for the chooser to present to the user.
3922 *
3923 * <p>Targets provided in this way will be presented inline with all other targets provided
3924 * by services from other apps. They will be prioritized before other service targets, but
3925 * after those targets provided by sources that the user has manually pinned to the front.</p>
3926 *
3927 * @see #ACTION_CHOOSER
3928 */
3929 public static final String EXTRA_CHOOSER_TARGETS = "android.intent.extra.CHOOSER_TARGETS";
3930
3931 /**
Adam Powell2ed547e2015-04-29 18:45:04 -07003932 * An {@link IntentSender} for an Activity that will be invoked when the user makes a selection
3933 * from the chooser activity presented by {@link #ACTION_CHOOSER}.
3934 *
3935 * <p>An app preparing an action for another app to complete may wish to allow the user to
3936 * disambiguate between several options for completing the action based on the chosen target
3937 * or otherwise refine the action before it is invoked.
3938 * </p>
3939 *
3940 * <p>When sent, this IntentSender may be filled in with the following extras:</p>
3941 * <ul>
3942 * <li>{@link #EXTRA_INTENT} The first intent that matched the user's chosen target</li>
3943 * <li>{@link #EXTRA_ALTERNATE_INTENTS} Any additional intents that also matched the user's
3944 * chosen target beyond the first</li>
3945 * <li>{@link #EXTRA_RESULT_RECEIVER} A {@link ResultReceiver} that the refinement activity
3946 * should fill in and send once the disambiguation is complete</li>
3947 * </ul>
3948 */
3949 public static final String EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER
3950 = "android.intent.extra.CHOOSER_REFINEMENT_INTENT_SENDER";
3951
3952 /**
Kang Li9fa2a2c2017-01-06 13:33:24 -08003953 * An {@code ArrayList} of {@code String} annotations describing content for
3954 * {@link #ACTION_CHOOSER}.
3955 *
3956 * <p>If {@link #EXTRA_CONTENT_ANNOTATIONS} is present in an intent used to start a
3957 * {@link #ACTION_CHOOSER} activity, the first three annotations will be used to rank apps.</p>
3958 *
3959 * <p>Annotations should describe the major components or topics of the content. It is up to
3960 * apps initiating {@link #ACTION_CHOOSER} to learn and add annotations. Annotations should be
3961 * learned in advance, e.g., when creating or saving content, to avoid increasing latency to
3962 * start {@link #ACTION_CHOOSER}. Performance on customized annotations can suffer, if they are
3963 * rarely used for {@link #ACTION_CHOOSER} in the past 14 days. Therefore, it is recommended to
3964 * use the following annotations when applicable:</p>
3965 * <ul>
3966 * <li>"product": represents that the topic of the content is mainly about products, e.g.,
3967 * health & beauty, and office supplies.</li>
3968 * <li>"emotion": represents that the topic of the content is mainly about emotions, e.g.,
3969 * happy, and sad.</li>
3970 * <li>"person": represents that the topic of the content is mainly about persons, e.g.,
3971 * face, finger, standing, and walking.</li>
3972 * <li>"child": represents that the topic of the content is mainly about children, e.g.,
3973 * child, and baby.</li>
3974 * <li>"selfie": represents that the topic of the content is mainly about selfies.</li>
3975 * <li>"crowd": represents that the topic of the content is mainly about crowds.</li>
3976 * <li>"party": represents that the topic of the content is mainly about parties.</li>
3977 * <li>"animal": represent that the topic of the content is mainly about animals.</li>
3978 * <li>"plant": represents that the topic of the content is mainly about plants, e.g.,
3979 * flowers.</li>
3980 * <li>"vacation": represents that the topic of the content is mainly about vacations.</li>
3981 * <li>"fashion": represents that the topic of the content is mainly about fashion, e.g.
3982 * sunglasses, jewelry, handbags and clothing.</li>
3983 * <li>"material": represents that the topic of the content is mainly about materials, e.g.,
3984 * paper, and silk.</li>
3985 * <li>"vehicle": represents that the topic of the content is mainly about vehicles, like
3986 * cars, and boats.</li>
3987 * <li>"document": represents that the topic of the content is mainly about documents, e.g.
3988 * posters.</li>
3989 * <li>"design": represents that the topic of the content is mainly about design, e.g. arts
3990 * and designs of houses.</li>
3991 * <li>"holiday": represents that the topic of the content is mainly about holidays, e.g.,
3992 * Christmas and Thanksgiving.</li>
3993 * </ul>
3994 */
3995 public static final String EXTRA_CONTENT_ANNOTATIONS
3996 = "android.intent.extra.CONTENT_ANNOTATIONS";
3997
3998 /**
Adam Powell2ed547e2015-04-29 18:45:04 -07003999 * A {@link ResultReceiver} used to return data back to the sender.
4000 *
4001 * <p>Used to complete an app-specific
4002 * {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER refinement} for {@link #ACTION_CHOOSER}.</p>
4003 *
4004 * <p>If {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER} is present in the intent
4005 * used to start a {@link #ACTION_CHOOSER} activity this extra will be
4006 * {@link #fillIn(Intent, int) filled in} to that {@link IntentSender} and sent
4007 * when the user selects a target component from the chooser. It is up to the recipient
4008 * to send a result to this ResultReceiver to signal that disambiguation is complete
4009 * and that the chooser should invoke the user's choice.</p>
4010 *
4011 * <p>The disambiguator should provide a Bundle to the ResultReceiver with an intent
4012 * assigned to the key {@link #EXTRA_INTENT}. This supplied intent will be used by the chooser
4013 * to match and fill in the final Intent or ChooserTarget before starting it.
4014 * The supplied intent must {@link #filterEquals(Intent) match} one of the intents from
4015 * {@link #EXTRA_INTENT} or {@link #EXTRA_ALTERNATE_INTENTS} passed to
4016 * {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER} to be accepted.</p>
4017 *
4018 * <p>The result code passed to the ResultReceiver should be
4019 * {@link android.app.Activity#RESULT_OK} if the refinement succeeded and the supplied intent's
4020 * target in the chooser should be started, or {@link android.app.Activity#RESULT_CANCELED} if
4021 * the chooser should finish without starting a target.</p>
4022 */
4023 public static final String EXTRA_RESULT_RECEIVER
4024 = "android.intent.extra.RESULT_RECEIVER";
4025
4026 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004027 * A CharSequence dialog title to provide to the user when used with a
Jim Miller4d64746d2014-08-13 21:08:41 +00004028 * {@link #ACTION_CHOOSER}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004029 */
4030 public static final String EXTRA_TITLE = "android.intent.extra.TITLE";
4031
4032 /**
Dianne Hackborneb034652009-09-07 00:49:58 -07004033 * A Parcelable[] of {@link Intent} or
4034 * {@link android.content.pm.LabeledIntent} objects as set with
4035 * {@link #putExtra(String, Parcelable[])} of additional activities to place
4036 * a the front of the list of choices, when shown to the user with a
4037 * {@link #ACTION_CHOOSER}.
4038 */
4039 public static final String EXTRA_INITIAL_INTENTS = "android.intent.extra.INITIAL_INTENTS";
4040
4041 /**
Todd Kennedy7440f172015-12-09 14:31:22 -08004042 * A {@link IntentSender} to start after ephemeral installation success.
4043 * @hide
4044 */
Todd Kennedy7440f172015-12-09 14:31:22 -08004045 public static final String EXTRA_EPHEMERAL_SUCCESS = "android.intent.extra.EPHEMERAL_SUCCESS";
4046
4047 /**
4048 * A {@link IntentSender} to start after ephemeral installation failure.
4049 * @hide
4050 */
Todd Kennedy7440f172015-12-09 14:31:22 -08004051 public static final String EXTRA_EPHEMERAL_FAILURE = "android.intent.extra.EPHEMERAL_FAILURE";
4052
4053 /**
Todd Kennedy01ad0c72016-11-11 15:33:12 -08004054 * The host name that triggered an ephemeral resolution.
4055 * @hide
4056 */
4057 public static final String EXTRA_EPHEMERAL_HOSTNAME = "android.intent.extra.EPHEMERAL_HOSTNAME";
4058
4059 /**
4060 * An opaque token to track ephemeral resolution.
4061 * @hide
4062 */
4063 public static final String EXTRA_EPHEMERAL_TOKEN = "android.intent.extra.EPHEMERAL_TOKEN";
4064
4065 /**
Todd Kennedy316c2f22017-01-23 15:40:07 -08004066 * The version code of the app to install components from.
4067 * @hide
4068 */
4069 public static final String EXTRA_VERSION_CODE = "android.intent.extra.VERSION_CODE";
4070
4071 /**
Adam Powelle49d9392014-07-17 18:45:19 -07004072 * A Bundle forming a mapping of potential target package names to different extras Bundles
4073 * to add to the default intent extras in {@link #EXTRA_INTENT} when used with
4074 * {@link #ACTION_CHOOSER}. Each key should be a package name. The package need not
4075 * be currently installed on the device.
4076 *
4077 * <p>An application may choose to provide alternate extras for the case where a user
4078 * selects an activity from a predetermined set of target packages. If the activity
4079 * the user selects from the chooser belongs to a package with its package name as
4080 * a key in this bundle, the corresponding extras for that package will be merged with
4081 * the extras already present in the intent at {@link #EXTRA_INTENT}. If a replacement
4082 * extra has the same key as an extra already present in the intent it will overwrite
4083 * the extra from the intent.</p>
4084 *
4085 * <p><em>Examples:</em>
4086 * <ul>
4087 * <li>An application may offer different {@link #EXTRA_TEXT} to an application
4088 * when sharing with it via {@link #ACTION_SEND}, augmenting a link with additional query
4089 * parameters for that target.</li>
4090 * <li>An application may offer additional metadata for known targets of a given intent
4091 * to pass along information only relevant to that target such as account or content
4092 * identifiers already known to that application.</li>
4093 * </ul></p>
4094 */
4095 public static final String EXTRA_REPLACEMENT_EXTRAS =
4096 "android.intent.extra.REPLACEMENT_EXTRAS";
4097
4098 /**
Adam Powell0b3c1122014-10-09 12:50:14 -07004099 * An {@link IntentSender} that will be notified if a user successfully chooses a target
4100 * component to handle an action in an {@link #ACTION_CHOOSER} activity. The IntentSender
4101 * will have the extra {@link #EXTRA_CHOSEN_COMPONENT} appended to it containing the
4102 * {@link ComponentName} of the chosen component.
4103 *
4104 * <p>In some situations this callback may never come, for example if the user abandons
4105 * the chooser, switches to another task or any number of other reasons. Apps should not
4106 * be written assuming that this callback will always occur.</p>
4107 */
4108 public static final String EXTRA_CHOSEN_COMPONENT_INTENT_SENDER =
4109 "android.intent.extra.CHOSEN_COMPONENT_INTENT_SENDER";
4110
4111 /**
4112 * The {@link ComponentName} chosen by the user to complete an action.
4113 *
4114 * @see #EXTRA_CHOSEN_COMPONENT_INTENT_SENDER
4115 */
4116 public static final String EXTRA_CHOSEN_COMPONENT = "android.intent.extra.CHOSEN_COMPONENT";
4117
4118 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004119 * A {@link android.view.KeyEvent} object containing the event that
4120 * triggered the creation of the Intent it is in.
4121 */
4122 public static final String EXTRA_KEY_EVENT = "android.intent.extra.KEY_EVENT";
4123
4124 /**
Mike Lockwoodbad80e02009-07-30 01:21:08 -07004125 * Set to true in {@link #ACTION_REQUEST_SHUTDOWN} to request confirmation from the user
4126 * before shutting down.
4127 *
4128 * {@hide}
4129 */
4130 public static final String EXTRA_KEY_CONFIRM = "android.intent.extra.KEY_CONFIRM";
4131
4132 /**
Yusuke Sato705ffd12015-07-21 15:52:11 -07004133 * Set to true in {@link #ACTION_REQUEST_SHUTDOWN} to indicate that the shutdown is
4134 * requested by the user.
4135 *
4136 * {@hide}
4137 */
4138 public static final String EXTRA_USER_REQUESTED_SHUTDOWN =
4139 "android.intent.extra.USER_REQUESTED_SHUTDOWN";
4140
4141 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09004142 * 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 -07004143 * {@link android.content.Intent#ACTION_PACKAGE_CHANGED} intents to override the default action
4144 * of restarting the application.
4145 */
4146 public static final String EXTRA_DONT_KILL_APP = "android.intent.extra.DONT_KILL_APP";
4147
4148 /**
4149 * A String holding the phone number originally entered in
4150 * {@link android.content.Intent#ACTION_NEW_OUTGOING_CALL}, or the actual
4151 * number to call in a {@link android.content.Intent#ACTION_CALL}.
4152 */
4153 public static final String EXTRA_PHONE_NUMBER = "android.intent.extra.PHONE_NUMBER";
Bernd Holzheyaea4b672010-03-31 09:46:13 +02004154
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004155 /**
4156 * Used as an int extra field in {@link android.content.Intent#ACTION_UID_REMOVED}
4157 * intents to supply the uid the package had been assigned. Also an optional
4158 * extra in {@link android.content.Intent#ACTION_PACKAGE_REMOVED} or
4159 * {@link android.content.Intent#ACTION_PACKAGE_CHANGED} for the same
4160 * purpose.
4161 */
4162 public static final String EXTRA_UID = "android.intent.extra.UID";
4163
4164 /**
Dianne Hackborn21f1bd12010-02-19 17:02:21 -08004165 * @hide String array of package names.
4166 */
Soonil Nagarkar0e8fd092015-02-10 10:37:36 -08004167 @SystemApi
Dianne Hackborn21f1bd12010-02-19 17:02:21 -08004168 public static final String EXTRA_PACKAGES = "android.intent.extra.PACKAGES";
4169
4170 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004171 * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED}
4172 * intents to indicate whether this represents a full uninstall (removing
4173 * both the code and its data) or a partial uninstall (leaving its data,
4174 * implying that this is an update).
4175 */
4176 public static final String EXTRA_DATA_REMOVED = "android.intent.extra.DATA_REMOVED";
The Android Open Source Project10592532009-03-18 17:39:46 -07004177
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004178 /**
Dianne Hackbornc72fc672012-09-20 13:12:03 -07004179 * @hide
4180 * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED}
4181 * intents to indicate that at this point the package has been removed for
4182 * all users on the device.
4183 */
4184 public static final String EXTRA_REMOVED_FOR_ALL_USERS
4185 = "android.intent.extra.REMOVED_FOR_ALL_USERS";
4186
4187 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004188 * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED}
4189 * intents to indicate that this is a replacement of the package, so this
4190 * broadcast will immediately be followed by an add broadcast for a
4191 * different version of the same package.
4192 */
4193 public static final String EXTRA_REPLACING = "android.intent.extra.REPLACING";
The Android Open Source Project10592532009-03-18 17:39:46 -07004194
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004195 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004196 * Used as an int extra field in {@link android.app.AlarmManager} intents
4197 * to tell the application being invoked how many pending alarms are being
4198 * delievered with the intent. For one-shot alarms this will always be 1.
4199 * For recurring alarms, this might be greater than 1 if the device was
4200 * asleep or powered off at the time an earlier alarm would have been
4201 * delivered.
4202 */
4203 public static final String EXTRA_ALARM_COUNT = "android.intent.extra.ALARM_COUNT";
Romain Guy4969af72009-06-17 10:53:19 -07004204
Jacek Surazski86b6c532009-05-13 14:38:28 +02004205 /**
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05004206 * Used as an int extra field in {@link android.content.Intent#ACTION_DOCK_EVENT}
4207 * intents to request the dock state. Possible values are
Mike Lockwood725fcbf2009-08-24 13:09:20 -07004208 * {@link android.content.Intent#EXTRA_DOCK_STATE_UNDOCKED},
4209 * {@link android.content.Intent#EXTRA_DOCK_STATE_DESK}, or
Praveen Bharathi21e941b2010-10-06 15:23:14 -05004210 * {@link android.content.Intent#EXTRA_DOCK_STATE_CAR}, or
4211 * {@link android.content.Intent#EXTRA_DOCK_STATE_LE_DESK}, or
4212 * {@link android.content.Intent#EXTRA_DOCK_STATE_HE_DESK}.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05004213 */
4214 public static final String EXTRA_DOCK_STATE = "android.intent.extra.DOCK_STATE";
4215
4216 /**
4217 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
4218 * to represent that the phone is not in any dock.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05004219 */
4220 public static final int EXTRA_DOCK_STATE_UNDOCKED = 0;
4221
4222 /**
4223 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
4224 * to represent that the phone is in a desk dock.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05004225 */
4226 public static final int EXTRA_DOCK_STATE_DESK = 1;
4227
4228 /**
4229 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
4230 * to represent that the phone is in a car dock.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05004231 */
4232 public static final int EXTRA_DOCK_STATE_CAR = 2;
4233
4234 /**
Praveen Bharathi21e941b2010-10-06 15:23:14 -05004235 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
4236 * to represent that the phone is in a analog (low end) dock.
4237 */
4238 public static final int EXTRA_DOCK_STATE_LE_DESK = 3;
4239
4240 /**
4241 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
4242 * to represent that the phone is in a digital (high end) dock.
4243 */
4244 public static final int EXTRA_DOCK_STATE_HE_DESK = 4;
4245
4246 /**
Dianne Hackborn9bfb7072009-09-22 11:37:40 -07004247 * Boolean that can be supplied as meta-data with a dock activity, to
4248 * indicate that the dock should take over the home key when it is active.
4249 */
4250 public static final String METADATA_DOCK_HOME = "android.dock_home";
Tom Taylord4a47292009-12-21 13:59:18 -08004251
Dianne Hackborn9bfb7072009-09-22 11:37:40 -07004252 /**
Jacek Surazski86b6c532009-05-13 14:38:28 +02004253 * Used as a parcelable extra field in {@link #ACTION_APP_ERROR}, containing
4254 * the bug report.
Jacek Surazski86b6c532009-05-13 14:38:28 +02004255 */
4256 public static final String EXTRA_BUG_REPORT = "android.intent.extra.BUG_REPORT";
4257
4258 /**
Wei Huang97ecc9c2009-05-11 17:44:20 -07004259 * Used in the extra field in the remote intent. It's astring token passed with the
4260 * remote intent.
4261 */
4262 public static final String EXTRA_REMOTE_INTENT_TOKEN =
4263 "android.intent.extra.remote_intent_token";
4264
Suchi Amalapurapu0214e942009-09-02 11:03:18 -07004265 /**
Dianne Hackborn1d62ea92009-11-17 12:49:50 -08004266 * @deprecated See {@link #EXTRA_CHANGED_COMPONENT_NAME_LIST}; this field
Dianne Hackborn86a72da2009-11-11 20:12:41 -08004267 * will contain only the first name in the list.
Suchi Amalapurapu0214e942009-09-02 11:03:18 -07004268 */
Dianne Hackborn1d62ea92009-11-17 12:49:50 -08004269 @Deprecated public static final String EXTRA_CHANGED_COMPONENT_NAME =
Suchi Amalapurapu0214e942009-09-02 11:03:18 -07004270 "android.intent.extra.changed_component_name";
4271
Dianne Hackborndd9b82c2009-09-03 00:18:47 -07004272 /**
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08004273 * This field is part of {@link android.content.Intent#ACTION_PACKAGE_CHANGED},
Dianne Hackbornfd7aded2013-01-22 17:10:23 -08004274 * and contains a string array of all of the components that have changed. If
4275 * the state of the overall package has changed, then it will contain an entry
4276 * with the package name itself.
Dianne Hackborn86a72da2009-11-11 20:12:41 -08004277 */
4278 public static final String EXTRA_CHANGED_COMPONENT_NAME_LIST =
4279 "android.intent.extra.changed_component_name_list";
4280
4281 /**
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08004282 * This field is part of
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08004283 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_AVAILABLE},
Andrei Stingaceanu69d5ebc2016-01-14 12:59:03 +00004284 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE},
4285 * {@link android.content.Intent#ACTION_PACKAGES_SUSPENDED},
4286 * {@link android.content.Intent#ACTION_PACKAGES_UNSUSPENDED}
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08004287 * and contains a string array of all of the components that have changed.
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08004288 */
4289 public static final String EXTRA_CHANGED_PACKAGE_LIST =
4290 "android.intent.extra.changed_package_list";
4291
4292 /**
4293 * This field is part of
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08004294 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_AVAILABLE},
4295 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE}
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08004296 * and contains an integer array of uids of all of the components
4297 * that have changed.
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08004298 */
4299 public static final String EXTRA_CHANGED_UID_LIST =
4300 "android.intent.extra.changed_uid_list";
4301
4302 /**
Dianne Hackborndd9b82c2009-09-03 00:18:47 -07004303 * @hide
4304 * Magic extra system code can use when binding, to give a label for
4305 * who it is that has bound to a service. This is an integer giving
4306 * a framework string resource that can be displayed to the user.
4307 */
4308 public static final String EXTRA_CLIENT_LABEL =
4309 "android.intent.extra.client_label";
4310
4311 /**
4312 * @hide
4313 * Magic extra system code can use when binding, to give a PendingIntent object
4314 * that can be launched for the user to disable the system's use of this
4315 * service.
4316 */
4317 public static final String EXTRA_CLIENT_INTENT =
4318 "android.intent.extra.client_intent";
4319
Dianne Hackbornc4d0e6f2011-01-25 14:55:06 -08004320 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004321 * Extra used to indicate that an intent should only return data that is on
4322 * the local device. This is a boolean extra; the default is false. If true,
4323 * an implementation should only allow the user to select data that is
4324 * already on the device, not requiring it be downloaded from a remote
4325 * service when opened.
4326 *
4327 * @see #ACTION_GET_CONTENT
4328 * @see #ACTION_OPEN_DOCUMENT
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07004329 * @see #ACTION_OPEN_DOCUMENT_TREE
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004330 * @see #ACTION_CREATE_DOCUMENT
Dianne Hackbornc4d0e6f2011-01-25 14:55:06 -08004331 */
4332 public static final String EXTRA_LOCAL_ONLY =
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004333 "android.intent.extra.LOCAL_ONLY";
Daniel Lehmanna5b58df2011-10-12 16:24:22 -07004334
Amith Yamasani13593602012-03-22 16:16:17 -07004335 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004336 * Extra used to indicate that an intent can allow the user to select and
4337 * return multiple items. This is a boolean extra; the default is false. If
4338 * true, an implementation is allowed to present the user with a UI where
4339 * they can pick multiple items that are all returned to the caller. When
4340 * this happens, they should be returned as the {@link #getClipData()} part
4341 * of the result Intent.
4342 *
4343 * @see #ACTION_GET_CONTENT
4344 * @see #ACTION_OPEN_DOCUMENT
Dianne Hackbornfdb3f092013-01-28 15:10:48 -08004345 */
4346 public static final String EXTRA_ALLOW_MULTIPLE =
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004347 "android.intent.extra.ALLOW_MULTIPLE";
Dianne Hackbornfdb3f092013-01-28 15:10:48 -08004348
4349 /**
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01004350 * The integer userHandle carried with broadcast intents related to addition, removal and
4351 * switching of users and managed profiles - {@link #ACTION_USER_ADDED},
4352 * {@link #ACTION_USER_REMOVED} and {@link #ACTION_USER_SWITCHED}.
4353 *
Amith Yamasani13593602012-03-22 16:16:17 -07004354 * @hide
4355 */
Amith Yamasani2a003292012-08-14 18:25:45 -07004356 public static final String EXTRA_USER_HANDLE =
4357 "android.intent.extra.user_handle";
Jean-Michel Trivi3114ce32012-06-11 15:03:52 -07004358
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08004359 /**
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01004360 * The UserHandle carried with broadcasts intents related to addition and removal of managed
4361 * profiles - {@link #ACTION_MANAGED_PROFILE_ADDED} and {@link #ACTION_MANAGED_PROFILE_REMOVED}.
4362 */
4363 public static final String EXTRA_USER =
Alexandra Gherghina3315f6b2014-09-05 15:48:06 +01004364 "android.intent.extra.USER";
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01004365
4366 /**
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08004367 * Extra used in the response from a BroadcastReceiver that handles
Amith Yamasani7e99bc02013-04-16 18:24:51 -07004368 * {@link #ACTION_GET_RESTRICTION_ENTRIES}. The type of the extra is
4369 * <code>ArrayList&lt;RestrictionEntry&gt;</code>.
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08004370 */
Amith Yamasani7e99bc02013-04-16 18:24:51 -07004371 public static final String EXTRA_RESTRICTIONS_LIST = "android.intent.extra.restrictions_list";
4372
4373 /**
4374 * Extra sent in the intent to the BroadcastReceiver that handles
4375 * {@link #ACTION_GET_RESTRICTION_ENTRIES}. The type of the extra is a Bundle containing
4376 * the restrictions as key/value pairs.
4377 */
4378 public static final String EXTRA_RESTRICTIONS_BUNDLE =
4379 "android.intent.extra.restrictions_bundle";
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08004380
Amith Yamasani86118ba2013-03-28 14:33:16 -07004381 /**
4382 * Extra used in the response from a BroadcastReceiver that handles
4383 * {@link #ACTION_GET_RESTRICTION_ENTRIES}.
4384 */
4385 public static final String EXTRA_RESTRICTIONS_INTENT =
4386 "android.intent.extra.restrictions_intent";
4387
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07004388 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004389 * Extra used to communicate a set of acceptable MIME types. The type of the
4390 * extra is {@code String[]}. Values may be a combination of concrete MIME
4391 * types (such as "image/png") and/or partial MIME types (such as
4392 * "audio/*").
4393 *
4394 * @see #ACTION_GET_CONTENT
4395 * @see #ACTION_OPEN_DOCUMENT
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07004396 */
4397 public static final String EXTRA_MIME_TYPES = "android.intent.extra.MIME_TYPES";
4398
Dianne Hackborn57a7f592013-07-22 18:21:32 -07004399 /**
4400 * Optional extra for {@link #ACTION_SHUTDOWN} that allows the sender to qualify that
4401 * this shutdown is only for the user space of the system, not a complete shutdown.
Dianne Hackbornd318e0b2013-09-03 14:34:12 -07004402 * When this is true, hardware devices can use this information to determine that
4403 * they shouldn't do a complete shutdown of their device since this is not a
4404 * complete shutdown down to the kernel, but only user space restarting.
4405 * The default if not supplied is false.
Dianne Hackborn57a7f592013-07-22 18:21:32 -07004406 */
4407 public static final String EXTRA_SHUTDOWN_USERSPACE_ONLY
4408 = "android.intent.extra.SHUTDOWN_USERSPACE_ONLY";
4409
Narayan Kamathccb2a0862013-12-19 14:49:36 +00004410 /**
Neil Fullerb7146fe2016-11-15 16:52:15 +00004411 * Optional int extra for {@link #ACTION_TIME_CHANGED} that indicates the
4412 * user has set their time format preference. See {@link #EXTRA_TIME_PREF_VALUE_USE_12_HOUR},
4413 * {@link #EXTRA_TIME_PREF_VALUE_USE_24_HOUR} and
4414 * {@link #EXTRA_TIME_PREF_VALUE_USE_LOCALE_DEFAULT}. The value must not be negative.
Narayan Kamathccb2a0862013-12-19 14:49:36 +00004415 *
4416 * @hide for internal use only.
4417 */
4418 public static final String EXTRA_TIME_PREF_24_HOUR_FORMAT =
4419 "android.intent.extra.TIME_PREF_24_HOUR_FORMAT";
Neil Fullerb7146fe2016-11-15 16:52:15 +00004420 /** @hide */
4421 public static final int EXTRA_TIME_PREF_VALUE_USE_12_HOUR = 0;
4422 /** @hide */
4423 public static final int EXTRA_TIME_PREF_VALUE_USE_24_HOUR = 1;
4424 /** @hide */
4425 public static final int EXTRA_TIME_PREF_VALUE_USE_LOCALE_DEFAULT = 2;
Narayan Kamathccb2a0862013-12-19 14:49:36 +00004426
Jeff Sharkey004a4b22014-09-24 11:45:24 -07004427 /** {@hide} */
4428 public static final String EXTRA_REASON = "android.intent.extra.REASON";
4429
Rubin Xue8490f12015-06-25 12:17:48 +01004430 /** {@hide} */
4431 public static final String EXTRA_WIPE_EXTERNAL_STORAGE = "android.intent.extra.WIPE_EXTERNAL_STORAGE";
4432
Santos Cordon15a13782015-03-31 18:32:31 -07004433 /**
4434 * Optional {@link android.app.PendingIntent} extra used to deliver the result of the SIM
4435 * activation request.
4436 * TODO: Add information about the structure and response data used with the pending intent.
4437 * @hide
4438 */
4439 public static final String EXTRA_SIM_ACTIVATION_RESPONSE =
4440 "android.intent.extra.SIM_ACTIVATION_RESPONSE";
4441
Tomasz Mikolajewski319fb492016-01-20 12:24:01 +09004442 /**
4443 * Optional index with semantics depending on the intent action.
Tomasz Mikolajewskife023132016-03-10 17:42:35 +09004444 *
4445 * <p>The value must be an integer greater or equal to 0.
Tomasz Mikolajewski867addf2017-02-01 14:16:39 +09004446 * @see ACTION_QUICK_VIEW
Tomasz Mikolajewski319fb492016-01-20 12:24:01 +09004447 */
Steve McKay6eaf38632015-08-04 10:11:01 -07004448 public static final String EXTRA_INDEX = "android.intent.extra.INDEX";
4449
Rubin Xu0a29ecd2015-11-04 15:11:48 +00004450 /**
Tomasz Mikolajewski17c50da2017-02-16 14:38:04 +09004451 * Tells the quick viewer to show additional UI actions suitable for the passed Uris,
4452 * such as opening in other apps, sharing, opening, editing, printing, deleting,
4453 * casting, etc.
Tomasz Mikolajewski867addf2017-02-01 14:16:39 +09004454 *
4455 * <p>The value is boolean. By default false.
4456 * @see ACTION_QUICK_VIEW
4457 */
Tomasz Mikolajewski17c50da2017-02-16 14:38:04 +09004458 public static final String EXTRA_QUICK_VIEW_ADVANCED =
4459 "android.intent.extra.QUICK_VIEW_ADVANCED";
Tomasz Mikolajewski867addf2017-02-01 14:16:39 +09004460
4461 /**
Rubin Xu0a29ecd2015-11-04 15:11:48 +00004462 * Optional boolean extra indicating whether quiet mode has been switched on or off.
Rubin Xue95057a2016-04-01 16:49:25 +01004463 * When a profile goes into quiet mode, all apps in the profile are killed and the
4464 * profile user is stopped. Widgets originating from the profile are masked, and app
4465 * launcher icons are grayed out.
Rubin Xu0a29ecd2015-11-04 15:11:48 +00004466 */
4467 public static final String EXTRA_QUIET_MODE = "android.intent.extra.QUIET_MODE";
Dongwon Kang2034a4c2015-12-14 21:57:34 +09004468
4469 /**
Dongwon Kang32cb9ab2016-01-13 18:11:10 -08004470 * Used as an int extra field in {@link #ACTION_MEDIA_RESOURCE_GRANTED}
Dongwon Kang2034a4c2015-12-14 21:57:34 +09004471 * intents to specify the resource type granted. Possible values are
Dongwon Kang32cb9ab2016-01-13 18:11:10 -08004472 * {@link #EXTRA_MEDIA_RESOURCE_TYPE_VIDEO_CODEC} or
4473 * {@link #EXTRA_MEDIA_RESOURCE_TYPE_AUDIO_CODEC}.
Dongwon Kang2034a4c2015-12-14 21:57:34 +09004474 *
4475 * @hide
4476 */
4477 public static final String EXTRA_MEDIA_RESOURCE_TYPE =
4478 "android.intent.extra.MEDIA_RESOURCE_TYPE";
4479
4480 /**
Ben Lin145b0ca2016-10-14 14:23:40 -07004481 * Used as a boolean extra field in {@link #ACTION_CHOOSER} intents to specify
4482 * whether to show the chooser or not when there is only one application available
4483 * to choose from.
4484 *
4485 * @hide
4486 */
4487 public static final String EXTRA_AUTO_LAUNCH_SINGLE_CHOICE =
4488 "android.intent.extra.AUTO_LAUNCH_SINGLE_CHOICE";
4489
4490 /**
Dongwon Kang32cb9ab2016-01-13 18:11:10 -08004491 * Used as an int value for {@link #EXTRA_MEDIA_RESOURCE_TYPE}
Dongwon Kang2034a4c2015-12-14 21:57:34 +09004492 * to represent that a video codec is allowed to use.
4493 *
4494 * @hide
4495 */
4496 public static final int EXTRA_MEDIA_RESOURCE_TYPE_VIDEO_CODEC = 0;
4497
4498 /**
Dongwon Kang32cb9ab2016-01-13 18:11:10 -08004499 * Used as an int value for {@link #EXTRA_MEDIA_RESOURCE_TYPE}
Dongwon Kang2034a4c2015-12-14 21:57:34 +09004500 * to represent that a audio codec is allowed to use.
4501 *
4502 * @hide
4503 */
4504 public static final int EXTRA_MEDIA_RESOURCE_TYPE_AUDIO_CODEC = 1;
4505
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004506 // ---------------------------------------------------------------------
4507 // ---------------------------------------------------------------------
4508 // Intent flags (see mFlags variable).
4509
Tor Norbyed9273d62013-05-30 15:59:53 -07004510 /** @hide */
Jeff Sharkey846318a2014-04-04 12:12:41 -07004511 @IntDef(flag = true, value = {
4512 FLAG_GRANT_READ_URI_PERMISSION, FLAG_GRANT_WRITE_URI_PERMISSION,
4513 FLAG_GRANT_PERSISTABLE_URI_PERMISSION, FLAG_GRANT_PREFIX_URI_PERMISSION })
Tor Norbyed9273d62013-05-30 15:59:53 -07004514 @Retention(RetentionPolicy.SOURCE)
4515 public @interface GrantUriMode {}
4516
Jeff Sharkey846318a2014-04-04 12:12:41 -07004517 /** @hide */
4518 @IntDef(flag = true, value = {
4519 FLAG_GRANT_READ_URI_PERMISSION, FLAG_GRANT_WRITE_URI_PERMISSION })
4520 @Retention(RetentionPolicy.SOURCE)
4521 public @interface AccessUriMode {}
4522
4523 /**
4524 * Test if given mode flags specify an access mode, which must be at least
4525 * read and/or write.
4526 *
4527 * @hide
4528 */
4529 public static boolean isAccessUriMode(int modeFlags) {
4530 return (modeFlags & (Intent.FLAG_GRANT_READ_URI_PERMISSION
4531 | Intent.FLAG_GRANT_WRITE_URI_PERMISSION)) != 0;
4532 }
4533
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004534 /**
4535 * If set, the recipient of this Intent will be granted permission to
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004536 * perform read operations on the URI in the Intent's data and any URIs
Dianne Hackborn21c241e2012-03-08 13:57:23 -08004537 * specified in its ClipData. When applying to an Intent's ClipData,
4538 * all URIs as well as recursive traversals through data or other ClipData
4539 * in Intent items will be granted; only the grant flags of the top-level
4540 * Intent are used.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004541 */
4542 public static final int FLAG_GRANT_READ_URI_PERMISSION = 0x00000001;
4543 /**
4544 * If set, the recipient of this Intent will be granted permission to
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004545 * perform write operations on the URI in the Intent's data and any URIs
Dianne Hackborn21c241e2012-03-08 13:57:23 -08004546 * specified in its ClipData. When applying to an Intent's ClipData,
4547 * all URIs as well as recursive traversals through data or other ClipData
4548 * in Intent items will be granted; only the grant flags of the top-level
4549 * Intent are used.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004550 */
4551 public static final int FLAG_GRANT_WRITE_URI_PERMISSION = 0x00000002;
4552 /**
4553 * Can be set by the caller to indicate that this Intent is coming from
4554 * a background operation, not from direct user interaction.
4555 */
4556 public static final int FLAG_FROM_BACKGROUND = 0x00000004;
4557 /**
4558 * A flag you can enable for debugging: when set, log messages will be
4559 * printed during the resolution of this intent to show you what has
4560 * been found to create the final resolved list.
4561 */
4562 public static final int FLAG_DEBUG_LOG_RESOLUTION = 0x00000008;
Dianne Hackborne7f97212011-02-24 14:40:20 -08004563 /**
4564 * If set, this intent will not match any components in packages that
4565 * are currently stopped. If this is not set, then the default behavior
4566 * is to include such applications in the result.
4567 */
4568 public static final int FLAG_EXCLUDE_STOPPED_PACKAGES = 0x00000010;
4569 /**
4570 * If set, this intent will always match any components in packages that
4571 * are currently stopped. This is the default behavior when
4572 * {@link #FLAG_EXCLUDE_STOPPED_PACKAGES} is not set. If both of these
4573 * flags are set, this one wins (it allows overriding of exclude for
4574 * places where the framework may automatically set the exclude flag).
4575 */
4576 public static final int FLAG_INCLUDE_STOPPED_PACKAGES = 0x00000020;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004577
4578 /**
Jeff Sharkey328ebf22013-03-21 18:09:39 -07004579 * When combined with {@link #FLAG_GRANT_READ_URI_PERMISSION} and/or
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004580 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, the URI permission grant can be
Jeff Sharkeye66c1772013-09-20 14:30:59 -07004581 * persisted across device reboots until explicitly revoked with
4582 * {@link Context#revokeUriPermission(Uri, int)}. This flag only offers the
4583 * grant for possible persisting; the receiving application must call
4584 * {@link ContentResolver#takePersistableUriPermission(Uri, int)} to
4585 * actually persist.
4586 *
4587 * @see ContentResolver#takePersistableUriPermission(Uri, int)
4588 * @see ContentResolver#releasePersistableUriPermission(Uri, int)
4589 * @see ContentResolver#getPersistedUriPermissions()
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004590 * @see ContentResolver#getOutgoingPersistedUriPermissions()
Jeff Sharkey328ebf22013-03-21 18:09:39 -07004591 */
Jeff Sharkeye66c1772013-09-20 14:30:59 -07004592 public static final int FLAG_GRANT_PERSISTABLE_URI_PERMISSION = 0x00000040;
Jeff Sharkey328ebf22013-03-21 18:09:39 -07004593
4594 /**
Jeff Sharkey846318a2014-04-04 12:12:41 -07004595 * When combined with {@link #FLAG_GRANT_READ_URI_PERMISSION} and/or
4596 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, the URI permission grant
4597 * applies to any URI that is a prefix match against the original granted
4598 * URI. (Without this flag, the URI must match exactly for access to be
4599 * granted.) Another URI is considered a prefix match only when scheme,
4600 * authority, and all path segments defined by the prefix are an exact
4601 * match.
4602 */
4603 public static final int FLAG_GRANT_PREFIX_URI_PERMISSION = 0x00000080;
4604
4605 /**
Jeff Sharkey2a9e3f82015-12-18 10:57:58 -07004606 * Internal flag used to indicate that a system component has done their
Jeff Sharkey2f3e3532015-12-21 14:16:43 -07004607 * homework and verified that they correctly handle packages and components
4608 * that come and go over time. In particular:
4609 * <ul>
4610 * <li>Apps installed on external storage, which will appear to be
4611 * uninstalled while the the device is ejected.
4612 * <li>Apps with encryption unaware components, which will appear to not
4613 * exist while the device is locked.
4614 * </ul>
Jeff Sharkey2a9e3f82015-12-18 10:57:58 -07004615 *
4616 * @hide
4617 */
Jeff Sharkey2f3e3532015-12-21 14:16:43 -07004618 public static final int FLAG_DEBUG_TRIAGED_MISSING = 0x00000100;
Jeff Sharkey2a9e3f82015-12-18 10:57:58 -07004619
4620 /**
Todd Kennedy8e2d9d12016-06-28 14:09:55 -07004621 * Internal flag used to indicate ephemeral applications should not be
4622 * considered when resolving the intent.
4623 *
4624 * @hide
4625 */
4626 public static final int FLAG_IGNORE_EPHEMERAL = 0x00000200;
4627
4628 /**
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08004629 * If set, the new activity is not kept in the history stack. As soon as
4630 * the user navigates away from it, the activity is finished. This may also
4631 * be set with the {@link android.R.styleable#AndroidManifestActivity_noHistory
4632 * noHistory} attribute.
Ricardo Cervera92f6a742014-04-04 11:17:06 -07004633 *
4634 * <p>If set, {@link android.app.Activity#onActivityResult onActivityResult()}
4635 * is never invoked when the current activity starts a new activity which
4636 * sets a result and finishes.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004637 */
4638 public static final int FLAG_ACTIVITY_NO_HISTORY = 0x40000000;
4639 /**
4640 * If set, the activity will not be launched if it is already running
4641 * at the top of the history stack.
4642 */
4643 public static final int FLAG_ACTIVITY_SINGLE_TOP = 0x20000000;
4644 /**
4645 * If set, this activity will become the start of a new task on this
4646 * history stack. A task (from the activity that started it to the
4647 * next task activity) defines an atomic group of activities that the
4648 * user can move to. Tasks can be moved to the foreground and background;
4649 * all of the activities inside of a particular task always remain in
The Android Open Source Project10592532009-03-18 17:39:46 -07004650 * the same order. See
Scott Main7aee61f2011-02-08 11:25:01 -08004651 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
4652 * Stack</a> for more information about tasks.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004653 *
4654 * <p>This flag is generally used by activities that want
4655 * to present a "launcher" style behavior: they give the user a list of
4656 * separate things that can be done, which otherwise run completely
4657 * independently of the activity launching them.
4658 *
4659 * <p>When using this flag, if a task is already running for the activity
4660 * you are now starting, then a new activity will not be started; instead,
4661 * the current task will simply be brought to the front of the screen with
4662 * the state it was last in. See {@link #FLAG_ACTIVITY_MULTIPLE_TASK} for a flag
4663 * to disable this behavior.
4664 *
4665 * <p>This flag can not be used when the caller is requesting a result from
4666 * the activity being launched.
4667 */
4668 public static final int FLAG_ACTIVITY_NEW_TASK = 0x10000000;
4669 /**
Craig Mautnerd00f4742014-03-12 14:17:26 -07004670 * This flag is used to create a new task and launch an activity into it.
4671 * This flag is always paired with either {@link #FLAG_ACTIVITY_NEW_DOCUMENT}
4672 * or {@link #FLAG_ACTIVITY_NEW_TASK}. In both cases these flags alone would
4673 * search through existing tasks for ones matching this Intent. Only if no such
4674 * task is found would a new task be created. When paired with
4675 * FLAG_ACTIVITY_MULTIPLE_TASK both of these behaviors are modified to skip
4676 * the search for a matching task and unconditionally start a new task.
4677 *
4678 * <strong>When used with {@link #FLAG_ACTIVITY_NEW_TASK} do not use this
4679 * flag unless you are implementing your own
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004680 * top-level application launcher.</strong> Used in conjunction with
4681 * {@link #FLAG_ACTIVITY_NEW_TASK} to disable the
4682 * behavior of bringing an existing task to the foreground. When set,
4683 * a new task is <em>always</em> started to host the Activity for the
4684 * Intent, regardless of whether there is already an existing task running
4685 * the same thing.
4686 *
4687 * <p><strong>Because the default system does not include graphical task management,
4688 * you should not use this flag unless you provide some way for a user to
4689 * return back to the tasks you have launched.</strong>
The Android Open Source Project10592532009-03-18 17:39:46 -07004690 *
Craig Mautnerd00f4742014-03-12 14:17:26 -07004691 * See {@link #FLAG_ACTIVITY_NEW_DOCUMENT} for details of this flag's use for
4692 * creating new document tasks.
4693 *
4694 * <p>This flag is ignored if one of {@link #FLAG_ACTIVITY_NEW_TASK} or
Paul Soulos628cb742014-09-19 11:00:52 -07004695 * {@link #FLAG_ACTIVITY_NEW_DOCUMENT} is not also set.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004696 *
Scott Main7aee61f2011-02-08 11:25:01 -08004697 * <p>See
4698 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
4699 * Stack</a> for more information about tasks.
Craig Mautnerd00f4742014-03-12 14:17:26 -07004700 *
4701 * @see #FLAG_ACTIVITY_NEW_DOCUMENT
4702 * @see #FLAG_ACTIVITY_NEW_TASK
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004703 */
4704 public static final int FLAG_ACTIVITY_MULTIPLE_TASK = 0x08000000;
4705 /**
4706 * If set, and the activity being launched is already running in the
4707 * current task, then instead of launching a new instance of that activity,
4708 * all of the other activities on top of it will be closed and this Intent
4709 * will be delivered to the (now on top) old activity as a new Intent.
4710 *
4711 * <p>For example, consider a task consisting of the activities: A, B, C, D.
4712 * If D calls startActivity() with an Intent that resolves to the component
4713 * of activity B, then C and D will be finished and B receive the given
4714 * Intent, resulting in the stack now being: A, B.
4715 *
Dianne Hackbornaa52f9a2009-08-25 16:01:15 -07004716 * <p>The currently running instance of activity B in the above example will
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004717 * either receive the new intent you are starting here in its
4718 * onNewIntent() method, or be itself finished and restarted with the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004719 * new intent. If it has declared its launch mode to be "multiple" (the
Dianne Hackbornaa52f9a2009-08-25 16:01:15 -07004720 * default) and you have not set {@link #FLAG_ACTIVITY_SINGLE_TOP} in
4721 * the same intent, then it will be finished and re-created; for all other
4722 * launch modes or if {@link #FLAG_ACTIVITY_SINGLE_TOP} is set then this
4723 * Intent will be delivered to the current instance's onNewIntent().
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004724 *
4725 * <p>This launch mode can also be used to good effect in conjunction with
4726 * {@link #FLAG_ACTIVITY_NEW_TASK}: if used to start the root activity
4727 * of a task, it will bring any currently running instance of that task
4728 * to the foreground, and then clear it to its root state. This is
4729 * especially useful, for example, when launching an activity from the
4730 * notification manager.
4731 *
Scott Main7aee61f2011-02-08 11:25:01 -08004732 * <p>See
4733 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
4734 * Stack</a> for more information about tasks.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004735 */
4736 public static final int FLAG_ACTIVITY_CLEAR_TOP = 0x04000000;
4737 /**
4738 * If set and this intent is being used to launch a new activity from an
4739 * existing one, then the reply target of the existing activity will be
4740 * transfered to the new activity. This way the new activity can call
4741 * {@link android.app.Activity#setResult} and have that result sent back to
4742 * the reply target of the original activity.
4743 */
4744 public static final int FLAG_ACTIVITY_FORWARD_RESULT = 0x02000000;
4745 /**
4746 * If set and this intent is being used to launch a new activity from an
4747 * existing one, the current activity will not be counted as the top
4748 * activity for deciding whether the new intent should be delivered to
4749 * the top instead of starting a new one. The previous activity will
4750 * be used as the top, with the assumption being that the current activity
4751 * will finish itself immediately.
4752 */
4753 public static final int FLAG_ACTIVITY_PREVIOUS_IS_TOP = 0x01000000;
4754 /**
4755 * If set, the new activity is not kept in the list of recently launched
4756 * activities.
4757 */
4758 public static final int FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS = 0x00800000;
4759 /**
4760 * This flag is not normally set by application code, but set for you by
4761 * the system as described in the
4762 * {@link android.R.styleable#AndroidManifestActivity_launchMode
4763 * launchMode} documentation for the singleTask mode.
4764 */
4765 public static final int FLAG_ACTIVITY_BROUGHT_TO_FRONT = 0x00400000;
4766 /**
4767 * If set, and this activity is either being started in a new task or
4768 * bringing to the top an existing task, then it will be launched as
4769 * the front door of the task. This will result in the application of
4770 * any affinities needed to have that task in the proper state (either
4771 * moving activities to or from it), or simply resetting that task to
4772 * its initial state if needed.
4773 */
4774 public static final int FLAG_ACTIVITY_RESET_TASK_IF_NEEDED = 0x00200000;
4775 /**
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08004776 * This flag is not normally set by application code, but set for you by
4777 * the system if this activity is being launched from history
4778 * (longpress home key).
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004779 */
4780 public static final int FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY = 0x00100000;
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08004781 /**
Craig Mautnerf357c0c2014-06-09 09:23:27 -07004782 * @deprecated As of API 21 this performs identically to
4783 * {@link #FLAG_ACTIVITY_NEW_DOCUMENT} which should be used instead of this.
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08004784 */
Aurimas Liutikas514c5ef2016-05-24 15:22:55 -07004785 @Deprecated
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08004786 public static final int FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET = 0x00080000;
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08004787 /**
Craig Mautner026596b2014-05-21 15:35:44 -07004788 * This flag is used to open a document into a new task rooted at the activity launched
4789 * by this Intent. Through the use of this flag, or its equivalent attribute,
4790 * {@link android.R.attr#documentLaunchMode} multiple instances of the same activity
Chet Haase0d1c27a2014-11-03 18:35:16 +00004791 * containing different documents will appear in the recent tasks list.
Craig Mautnerd00f4742014-03-12 14:17:26 -07004792 *
Craig Mautner026596b2014-05-21 15:35:44 -07004793 * <p>The use of the activity attribute form of this,
4794 * {@link android.R.attr#documentLaunchMode}, is
4795 * preferred over the Intent flag described here. The attribute form allows the
4796 * Activity to specify multiple document behavior for all launchers of the Activity
4797 * whereas using this flag requires each Intent that launches the Activity to specify it.
Craig Mautnerd00f4742014-03-12 14:17:26 -07004798 *
Dianne Hackborn13420f22014-07-18 15:43:56 -07004799 * <p>Note that the default semantics of this flag w.r.t. whether the recents entry for
4800 * it is kept after the activity is finished is different than the use of
4801 * {@link #FLAG_ACTIVITY_NEW_TASK} and {@link android.R.attr#documentLaunchMode} -- if
4802 * this flag is being used to create a new recents entry, then by default that entry
4803 * will be removed once the activity is finished. You can modify this behavior with
4804 * {@link #FLAG_ACTIVITY_RETAIN_IN_RECENTS}.
4805 *
Craig Mautner026596b2014-05-21 15:35:44 -07004806 * <p>FLAG_ACTIVITY_NEW_DOCUMENT may be used in conjunction with {@link
4807 * #FLAG_ACTIVITY_MULTIPLE_TASK}. When used alone it is the
4808 * equivalent of the Activity manifest specifying {@link
4809 * android.R.attr#documentLaunchMode}="intoExisting". When used with
4810 * FLAG_ACTIVITY_MULTIPLE_TASK it is the equivalent of the Activity manifest specifying
4811 * {@link android.R.attr#documentLaunchMode}="always".
Craig Mautnerd00f4742014-03-12 14:17:26 -07004812 *
Craig Mautner026596b2014-05-21 15:35:44 -07004813 * Refer to {@link android.R.attr#documentLaunchMode} for more information.
Craig Mautnerd00f4742014-03-12 14:17:26 -07004814 *
Craig Mautner026596b2014-05-21 15:35:44 -07004815 * @see android.R.attr#documentLaunchMode
Craig Mautnerd00f4742014-03-12 14:17:26 -07004816 * @see #FLAG_ACTIVITY_MULTIPLE_TASK
4817 */
Craig Mautnerf357c0c2014-06-09 09:23:27 -07004818 public static final int FLAG_ACTIVITY_NEW_DOCUMENT = FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET;
Craig Mautnerd00f4742014-03-12 14:17:26 -07004819 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004820 * If set, this flag will prevent the normal {@link android.app.Activity#onUserLeaveHint}
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08004821 * callback from occurring on the current frontmost activity before it is
4822 * paused as the newly-started activity is brought to the front.
The Android Open Source Project10592532009-03-18 17:39:46 -07004823 *
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08004824 * <p>Typically, an activity can rely on that callback to indicate that an
4825 * explicit user action has caused their activity to be moved out of the
4826 * foreground. The callback marks an appropriate point in the activity's
4827 * lifecycle for it to dismiss any notifications that it intends to display
4828 * "until the user has seen them," such as a blinking LED.
The Android Open Source Project10592532009-03-18 17:39:46 -07004829 *
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08004830 * <p>If an activity is ever started via any non-user-driven events such as
4831 * phone-call receipt or an alarm handler, this flag should be passed to {@link
4832 * Context#startActivity Context.startActivity}, ensuring that the pausing
The Android Open Source Project10592532009-03-18 17:39:46 -07004833 * activity does not think the user has acknowledged its notification.
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08004834 */
4835 public static final int FLAG_ACTIVITY_NO_USER_ACTION = 0x00040000;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004836 /**
4837 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
4838 * this flag will cause the launched activity to be brought to the front of its
4839 * task's history stack if it is already running.
The Android Open Source Project10592532009-03-18 17:39:46 -07004840 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004841 * <p>For example, consider a task consisting of four activities: A, B, C, D.
4842 * If D calls startActivity() with an Intent that resolves to the component
4843 * of activity B, then B will be brought to the front of the history stack,
4844 * with this resulting order: A, C, D, B.
The Android Open Source Project10592532009-03-18 17:39:46 -07004845 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004846 * This flag will be ignored if {@link #FLAG_ACTIVITY_CLEAR_TOP} is also
The Android Open Source Project10592532009-03-18 17:39:46 -07004847 * specified.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004848 */
4849 public static final int FLAG_ACTIVITY_REORDER_TO_FRONT = 0X00020000;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004850 /**
Dianne Hackbornbfe319e2009-09-21 00:34:05 -07004851 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
4852 * this flag will prevent the system from applying an activity transition
4853 * animation to go to the next activity state. This doesn't mean an
4854 * animation will never run -- if another activity change happens that doesn't
4855 * specify this flag before the activity started here is displayed, then
Dianne Hackborn621e17d2010-11-22 15:59:56 -08004856 * that transition will be used. This flag can be put to good use
Dianne Hackbornbfe319e2009-09-21 00:34:05 -07004857 * when you are going to do a series of activity operations but the
4858 * animation seen by the user shouldn't be driven by the first activity
4859 * change but rather a later one.
4860 */
4861 public static final int FLAG_ACTIVITY_NO_ANIMATION = 0X00010000;
4862 /**
Dianne Hackborn621e17d2010-11-22 15:59:56 -08004863 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
4864 * this flag will cause any existing task that would be associated with the
4865 * activity to be cleared before the activity is started. That is, the activity
4866 * becomes the new root of an otherwise empty task, and any old activities
4867 * are finished. This can only be used in conjunction with {@link #FLAG_ACTIVITY_NEW_TASK}.
4868 */
4869 public static final int FLAG_ACTIVITY_CLEAR_TASK = 0X00008000;
4870 /**
4871 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
4872 * this flag will cause a newly launching task to be placed on top of the current
4873 * home activity task (if there is one). That is, pressing back from the task
4874 * will always return the user to home even if that was not the last activity they
4875 * saw. This can only be used in conjunction with {@link #FLAG_ACTIVITY_NEW_TASK}.
4876 */
4877 public static final int FLAG_ACTIVITY_TASK_ON_HOME = 0X00004000;
4878 /**
Dianne Hackborn13420f22014-07-18 15:43:56 -07004879 * By default a document created by {@link #FLAG_ACTIVITY_NEW_DOCUMENT} will
4880 * have its entry in recent tasks removed when the user closes it (with back
Jeff Sharkey9f991a22014-08-13 11:37:41 -07004881 * or however else it may finish()). If you would like to instead allow the
Dianne Hackborn13420f22014-07-18 15:43:56 -07004882 * document to be kept in recents so that it can be re-launched, you can use
Jeff Sharkey9f991a22014-08-13 11:37:41 -07004883 * this flag. When set and the task's activity is finished, the recents
4884 * entry will remain in the interface for the user to re-launch it, like a
4885 * recents entry for a top-level application.
4886 * <p>
4887 * The receiving activity can override this request with
4888 * {@link android.R.attr#autoRemoveFromRecents} or by explcitly calling
4889 * {@link android.app.Activity#finishAndRemoveTask()
Dianne Hackborn13420f22014-07-18 15:43:56 -07004890 * Activity.finishAndRemoveTask()}.
Craig Mautner2dac0562014-05-06 09:06:44 -07004891 */
Dianne Hackborn13420f22014-07-18 15:43:56 -07004892 public static final int FLAG_ACTIVITY_RETAIN_IN_RECENTS = 0x00002000;
Craig Mautnera228ae92014-07-09 05:44:55 -07004893
4894 /**
Wale Ogunwale2a25a622016-01-30 11:27:21 -08004895 * This flag is only used in split-screen multi-window mode. The new activity will be displayed
4896 * adjacent to the one launching it. This can only be used in conjunction with
Wale Ogunwale6bdf2572016-03-11 15:22:38 -08004897 * {@link #FLAG_ACTIVITY_NEW_TASK}. Also, setting {@link #FLAG_ACTIVITY_MULTIPLE_TASK} is
4898 * required if you want a new instance of an existing activity to be created.
Filip Gruszczynski80e29f12015-12-14 14:58:30 -08004899 */
Wale Ogunwale2a25a622016-01-30 11:27:21 -08004900 public static final int FLAG_ACTIVITY_LAUNCH_ADJACENT = 0x00001000;
Filip Gruszczynski80e29f12015-12-14 14:58:30 -08004901
4902 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004903 * If set, when sending a broadcast only registered receivers will be
4904 * called -- no BroadcastReceiver components will be launched.
4905 */
4906 public static final int FLAG_RECEIVER_REGISTERED_ONLY = 0x40000000;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004907 /**
Dianne Hackborn1c633fc2009-12-08 19:45:14 -08004908 * If set, when sending a broadcast the new broadcast will replace
4909 * any existing pending broadcast that matches it. Matching is defined
4910 * by {@link Intent#filterEquals(Intent) Intent.filterEquals} returning
4911 * true for the intents of the two broadcasts. When a match is found,
4912 * the new broadcast (and receivers associated with it) will replace the
4913 * existing one in the pending broadcast list, remaining at the same
4914 * position in the list.
Tom Taylord4a47292009-12-21 13:59:18 -08004915 *
Dianne Hackborn1c633fc2009-12-08 19:45:14 -08004916 * <p>This flag is most typically used with sticky broadcasts, which
4917 * only care about delivering the most recent values of the broadcast
4918 * to their receivers.
4919 */
4920 public static final int FLAG_RECEIVER_REPLACE_PENDING = 0x20000000;
4921 /**
Christopher Tatef46723b2012-01-26 14:19:24 -08004922 * If set, when sending a broadcast the recipient is allowed to run at
4923 * foreground priority, with a shorter timeout interval. During normal
4924 * broadcasts the receivers are not automatically hoisted out of the
4925 * background priority class.
4926 */
4927 public static final int FLAG_RECEIVER_FOREGROUND = 0x10000000;
4928 /**
Dianne Hackborn6285a322013-09-18 12:09:47 -07004929 * If this is an ordered broadcast, don't allow receivers to abort the broadcast.
4930 * They can still propagate results through to later receivers, but they can not prevent
4931 * later receivers from seeing the broadcast.
4932 */
4933 public static final int FLAG_RECEIVER_NO_ABORT = 0x08000000;
4934 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004935 * If set, when sending a broadcast <i>before boot has completed</i> only
4936 * registered receivers will be called -- no BroadcastReceiver components
4937 * will be launched. Sticky intent state will be recorded properly even
4938 * if no receivers wind up being called. If {@link #FLAG_RECEIVER_REGISTERED_ONLY}
4939 * is specified in the broadcast intent, this flag is unnecessary.
The Android Open Source Project10592532009-03-18 17:39:46 -07004940 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004941 * <p>This flag is only for use by system sevices as a convenience to
4942 * avoid having to implement a more complex mechanism around detection
4943 * of boot completion.
The Android Open Source Project10592532009-03-18 17:39:46 -07004944 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004945 * @hide
4946 */
Dianne Hackborn6285a322013-09-18 12:09:47 -07004947 public static final int FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT = 0x04000000;
Dianne Hackborn9acc0302009-08-25 00:27:12 -07004948 /**
4949 * Set when this broadcast is for a boot upgrade, a special mode that
4950 * allows the broadcast to be sent before the system is ready and launches
4951 * the app process with no providers running in it.
4952 * @hide
4953 */
Dianne Hackborn6285a322013-09-18 12:09:47 -07004954 public static final int FLAG_RECEIVER_BOOT_UPGRADE = 0x02000000;
Dianne Hackborn6ac42ae2015-12-08 17:22:10 -08004955 /**
4956 * If set, the broadcast will always go to manifest receivers in background (cached
4957 * or not running) apps, regardless of whether that would be done by default. By
4958 * default they will only receive broadcasts if the broadcast has specified an
4959 * explicit component or package name.
Christopher Tatebdc39412017-01-23 12:21:13 -08004960 *
4961 * NOTE: dumpstate uses this flag numerically, so when its value is changed
4962 * the broadcast code there must also be changed to match.
4963 *
Dianne Hackborn6ac42ae2015-12-08 17:22:10 -08004964 * @hide
4965 */
4966 public static final int FLAG_RECEIVER_INCLUDE_BACKGROUND = 0x01000000;
4967 /**
4968 * If set, the broadcast will never go to manifest receivers in background (cached
4969 * or not running) apps, regardless of whether that would be done by default. By
4970 * default they will receive broadcasts if the broadcast has specified an
4971 * explicit component or package name.
4972 * @hide
4973 */
4974 public static final int FLAG_RECEIVER_EXCLUDE_BACKGROUND = 0x00800000;
Jeff Sharkey6a34e562016-12-21 09:56:00 -07004975 /**
4976 * If set, this broadcast is being sent from the shell.
4977 * @hide
4978 */
4979 public static final int FLAG_RECEIVER_FROM_SHELL = 0x00400000;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004980
Dianne Hackbornfa82f222009-09-17 15:14:12 -07004981 /**
4982 * @hide Flags that can't be changed with PendingIntent.
4983 */
Jeff Sharkey846318a2014-04-04 12:12:41 -07004984 public static final int IMMUTABLE_FLAGS = FLAG_GRANT_READ_URI_PERMISSION
4985 | FLAG_GRANT_WRITE_URI_PERMISSION | FLAG_GRANT_PERSISTABLE_URI_PERMISSION
4986 | FLAG_GRANT_PREFIX_URI_PERMISSION;
Tom Taylord4a47292009-12-21 13:59:18 -08004987
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004988 // ---------------------------------------------------------------------
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004989 // ---------------------------------------------------------------------
4990 // toUri() and parseUri() options.
4991
4992 /**
4993 * Flag for use with {@link #toUri} and {@link #parseUri}: the URI string
4994 * always has the "intent:" scheme. This syntax can be used when you want
4995 * to later disambiguate between URIs that are intended to describe an
4996 * Intent vs. all others that should be treated as raw URIs. When used
4997 * with {@link #parseUri}, any other scheme will result in a generic
4998 * VIEW action for that raw URI.
4999 */
5000 public static final int URI_INTENT_SCHEME = 1<<0;
Tom Taylord4a47292009-12-21 13:59:18 -08005001
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005002 /**
5003 * Flag for use with {@link #toUri} and {@link #parseUri}: the URI string
5004 * always has the "android-app:" scheme. This is a variation of
5005 * {@link #URI_INTENT_SCHEME} whose format is simpler for the case of an
5006 * http/https URI being delivered to a specific package name. The format
5007 * is:
5008 *
5009 * <pre class="prettyprint">
Dianne Hackborn0ee10f62015-01-14 16:16:13 -08005010 * android-app://{package_id}[/{scheme}[/{host}[/{path}]]][#Intent;{...}]</pre>
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005011 *
Dianne Hackborn0ee10f62015-01-14 16:16:13 -08005012 * <p>In this scheme, only the <code>package_id</code> is required. If you include a host,
5013 * you must also include a scheme; including a path also requires both a host and a scheme.
5014 * The final #Intent; fragment can be used without a scheme, host, or path.
5015 * Note that this can not be
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005016 * used with intents that have a {@link #setSelector}, since the base intent
5017 * will always have an explicit package name.</p>
5018 *
5019 * <p>Some examples of how this scheme maps to Intent objects:</p>
5020 * <table border="2" width="85%" align="center" frame="hsides" rules="rows">
5021 * <colgroup align="left" />
5022 * <colgroup align="left" />
5023 * <thead>
5024 * <tr><th>URI</th> <th>Intent</th></tr>
5025 * </thead>
5026 *
5027 * <tbody>
5028 * <tr><td><code>android-app://com.example.app</code></td>
5029 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
5030 * <tr><td>Action: </td><td>{@link #ACTION_MAIN}</td></tr>
5031 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
5032 * </table></td>
5033 * </tr>
5034 * <tr><td><code>android-app://com.example.app/http/example.com</code></td>
5035 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
5036 * <tr><td>Action: </td><td>{@link #ACTION_VIEW}</td></tr>
5037 * <tr><td>Data: </td><td><code>http://example.com/</code></td></tr>
5038 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
5039 * </table></td>
5040 * </tr>
5041 * <tr><td><code>android-app://com.example.app/http/example.com/foo?1234</code></td>
5042 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
5043 * <tr><td>Action: </td><td>{@link #ACTION_VIEW}</td></tr>
5044 * <tr><td>Data: </td><td><code>http://example.com/foo?1234</code></td></tr>
5045 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
5046 * </table></td>
5047 * </tr>
5048 * <tr><td><code>android-app://com.example.app/<br />#Intent;action=com.example.MY_ACTION;end</code></td>
5049 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
5050 * <tr><td>Action: </td><td><code>com.example.MY_ACTION</code></td></tr>
5051 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
5052 * </table></td>
5053 * </tr>
5054 * <tr><td><code>android-app://com.example.app/http/example.com/foo?1234<br />#Intent;action=com.example.MY_ACTION;end</code></td>
5055 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
5056 * <tr><td>Action: </td><td><code>com.example.MY_ACTION</code></td></tr>
5057 * <tr><td>Data: </td><td><code>http://example.com/foo?1234</code></td></tr>
5058 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
5059 * </table></td>
5060 * </tr>
5061 * <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>
5062 * <td><table border="" style="margin:0" >
5063 * <tr><td>Action: </td><td><code>com.example.MY_ACTION</code></td></tr>
5064 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
5065 * <tr><td>Extras: </td><td><code>some_int=(int)100<br />some_str=(String)hello</code></td></tr>
5066 * </table></td>
5067 * </tr>
5068 * </tbody>
5069 * </table>
5070 */
5071 public static final int URI_ANDROID_APP_SCHEME = 1<<1;
5072
Dianne Hackborn24b1c232014-11-20 17:17:39 -08005073 /**
5074 * Flag for use with {@link #toUri} and {@link #parseUri}: allow parsing
5075 * of unsafe information. In particular, the flags {@link #FLAG_GRANT_READ_URI_PERMISSION},
5076 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, {@link #FLAG_GRANT_PERSISTABLE_URI_PERMISSION},
5077 * and {@link #FLAG_GRANT_PREFIX_URI_PERMISSION} flags can not be set, so that the
5078 * generated Intent can not cause unexpected data access to happen.
5079 *
5080 * <p>If you do not trust the source of the URI being parsed, you should still do further
5081 * processing to protect yourself from it. In particular, when using it to start an
5082 * activity you should usually add in {@link #CATEGORY_BROWSABLE} to limit the activities
5083 * that can handle it.</p>
5084 */
5085 public static final int URI_ALLOW_UNSAFE = 1<<2;
5086
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005087 // ---------------------------------------------------------------------
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005088
5089 private String mAction;
5090 private Uri mData;
5091 private String mType;
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005092 private String mPackage;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005093 private ComponentName mComponent;
5094 private int mFlags;
Dianne Hackbornadd005c2013-07-17 18:43:12 -07005095 private ArraySet<String> mCategories;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005096 private Bundle mExtras;
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08005097 private Rect mSourceBounds;
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005098 private Intent mSelector;
Dianne Hackborn21c241e2012-03-08 13:57:23 -08005099 private ClipData mClipData;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01005100 private int mContentUserHint = UserHandle.USER_CURRENT;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005101
5102 // ---------------------------------------------------------------------
5103
5104 /**
5105 * Create an empty intent.
5106 */
5107 public Intent() {
5108 }
5109
5110 /**
5111 * Copy constructor.
5112 */
5113 public Intent(Intent o) {
5114 this.mAction = o.mAction;
5115 this.mData = o.mData;
5116 this.mType = o.mType;
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005117 this.mPackage = o.mPackage;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005118 this.mComponent = o.mComponent;
5119 this.mFlags = o.mFlags;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01005120 this.mContentUserHint = o.mContentUserHint;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005121 if (o.mCategories != null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07005122 this.mCategories = new ArraySet<String>(o.mCategories);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005123 }
5124 if (o.mExtras != null) {
5125 this.mExtras = new Bundle(o.mExtras);
5126 }
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08005127 if (o.mSourceBounds != null) {
5128 this.mSourceBounds = new Rect(o.mSourceBounds);
5129 }
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005130 if (o.mSelector != null) {
5131 this.mSelector = new Intent(o.mSelector);
5132 }
Dianne Hackborn21c241e2012-03-08 13:57:23 -08005133 if (o.mClipData != null) {
5134 this.mClipData = new ClipData(o.mClipData);
5135 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005136 }
5137
5138 @Override
5139 public Object clone() {
5140 return new Intent(this);
5141 }
5142
5143 private Intent(Intent o, boolean all) {
5144 this.mAction = o.mAction;
5145 this.mData = o.mData;
5146 this.mType = o.mType;
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005147 this.mPackage = o.mPackage;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005148 this.mComponent = o.mComponent;
5149 if (o.mCategories != null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07005150 this.mCategories = new ArraySet<String>(o.mCategories);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005151 }
5152 }
5153
5154 /**
5155 * Make a clone of only the parts of the Intent that are relevant for
5156 * filter matching: the action, data, type, component, and categories.
5157 */
5158 public Intent cloneFilter() {
5159 return new Intent(this, false);
5160 }
5161
5162 /**
5163 * Create an intent with a given action. All other fields (data, type,
5164 * class) are null. Note that the action <em>must</em> be in a
5165 * namespace because Intents are used globally in the system -- for
5166 * example the system VIEW action is android.intent.action.VIEW; an
5167 * application's custom action would be something like
5168 * com.google.app.myapp.CUSTOM_ACTION.
5169 *
5170 * @param action The Intent action, such as ACTION_VIEW.
5171 */
5172 public Intent(String action) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08005173 setAction(action);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005174 }
5175
5176 /**
5177 * Create an intent with a given action and for a given data url. Note
5178 * that the action <em>must</em> be in a namespace because Intents are
5179 * used globally in the system -- for example the system VIEW action is
5180 * android.intent.action.VIEW; an application's custom action would be
5181 * something like com.google.app.myapp.CUSTOM_ACTION.
5182 *
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07005183 * <p><em>Note: scheme and host name matching in the Android framework is
5184 * case-sensitive, unlike the formal RFC. As a result,
5185 * you should always ensure that you write your Uri with these elements
5186 * using lower case letters, and normalize any Uris you receive from
5187 * outside of Android to ensure the scheme and host is lower case.</em></p>
5188 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005189 * @param action The Intent action, such as ACTION_VIEW.
5190 * @param uri The Intent data URI.
5191 */
5192 public Intent(String action, Uri uri) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08005193 setAction(action);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005194 mData = uri;
5195 }
5196
5197 /**
5198 * Create an intent for a specific component. All other fields (action, data,
5199 * type, class) are null, though they can be modified later with explicit
5200 * calls. This provides a convenient way to create an intent that is
5201 * intended to execute a hard-coded class name, rather than relying on the
5202 * system to find an appropriate class for you; see {@link #setComponent}
5203 * for more information on the repercussions of this.
5204 *
5205 * @param packageContext A Context of the application package implementing
5206 * this class.
5207 * @param cls The component class that is to be used for the intent.
5208 *
5209 * @see #setClass
5210 * @see #setComponent
5211 * @see #Intent(String, android.net.Uri , Context, Class)
5212 */
5213 public Intent(Context packageContext, Class<?> cls) {
5214 mComponent = new ComponentName(packageContext, cls);
5215 }
5216
5217 /**
5218 * Create an intent for a specific component with a specified action and data.
Craig Mautner2dac0562014-05-06 09:06:44 -07005219 * This is equivalent to using {@link #Intent(String, android.net.Uri)} to
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005220 * construct the Intent and then calling {@link #setClass} to set its
5221 * class.
5222 *
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07005223 * <p><em>Note: scheme and host name matching in the Android framework is
5224 * case-sensitive, unlike the formal RFC. As a result,
5225 * you should always ensure that you write your Uri with these elements
5226 * using lower case letters, and normalize any Uris you receive from
5227 * outside of Android to ensure the scheme and host is lower case.</em></p>
5228 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005229 * @param action The Intent action, such as ACTION_VIEW.
5230 * @param uri The Intent data URI.
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 #Intent(String, android.net.Uri)
5236 * @see #Intent(Context, Class)
5237 * @see #setClass
5238 * @see #setComponent
5239 */
5240 public Intent(String action, Uri uri,
5241 Context packageContext, Class<?> cls) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08005242 setAction(action);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005243 mData = uri;
5244 mComponent = new ComponentName(packageContext, cls);
5245 }
5246
5247 /**
Dianne Hackborn30d71892010-12-11 10:37:55 -08005248 * Create an intent to launch the main (root) activity of a task. This
5249 * is the Intent that is started when the application's is launched from
5250 * Home. For anything else that wants to launch an application in the
5251 * same way, it is important that they use an Intent structured the same
5252 * way, and can use this function to ensure this is the case.
5253 *
5254 * <p>The returned Intent has the given Activity component as its explicit
5255 * component, {@link #ACTION_MAIN} as its action, and includes the
5256 * category {@link #CATEGORY_LAUNCHER}. This does <em>not</em> have
5257 * {@link #FLAG_ACTIVITY_NEW_TASK} set, though typically you will want
5258 * to do that through {@link #addFlags(int)} on the returned Intent.
5259 *
5260 * @param mainActivity The main activity component that this Intent will
5261 * launch.
5262 * @return Returns a newly created Intent that can be used to launch the
5263 * activity as a main application entry.
5264 *
5265 * @see #setClass
5266 * @see #setComponent
5267 */
5268 public static Intent makeMainActivity(ComponentName mainActivity) {
5269 Intent intent = new Intent(ACTION_MAIN);
5270 intent.setComponent(mainActivity);
5271 intent.addCategory(CATEGORY_LAUNCHER);
5272 return intent;
5273 }
5274
5275 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005276 * Make an Intent for the main activity of an application, without
5277 * specifying a specific activity to run but giving a selector to find
5278 * the activity. This results in a final Intent that is structured
5279 * the same as when the application is launched from
5280 * Home. For anything else that wants to launch an application in the
5281 * same way, it is important that they use an Intent structured the same
5282 * way, and can use this function to ensure this is the case.
5283 *
5284 * <p>The returned Intent has {@link #ACTION_MAIN} as its action, and includes the
5285 * category {@link #CATEGORY_LAUNCHER}. This does <em>not</em> have
5286 * {@link #FLAG_ACTIVITY_NEW_TASK} set, though typically you will want
5287 * to do that through {@link #addFlags(int)} on the returned Intent.
5288 *
5289 * @param selectorAction The action name of the Intent's selector.
5290 * @param selectorCategory The name of a category to add to the Intent's
5291 * selector.
5292 * @return Returns a newly created Intent that can be used to launch the
5293 * activity as a main application entry.
5294 *
5295 * @see #setSelector(Intent)
5296 */
5297 public static Intent makeMainSelectorActivity(String selectorAction,
5298 String selectorCategory) {
5299 Intent intent = new Intent(ACTION_MAIN);
5300 intent.addCategory(CATEGORY_LAUNCHER);
5301 Intent selector = new Intent();
5302 selector.setAction(selectorAction);
5303 selector.addCategory(selectorCategory);
5304 intent.setSelector(selector);
5305 return intent;
5306 }
5307
5308 /**
Dianne Hackborn30d71892010-12-11 10:37:55 -08005309 * Make an Intent that can be used to re-launch an application's task
5310 * in its base state. This is like {@link #makeMainActivity(ComponentName)},
5311 * but also sets the flags {@link #FLAG_ACTIVITY_NEW_TASK} and
5312 * {@link #FLAG_ACTIVITY_CLEAR_TASK}.
5313 *
5314 * @param mainActivity The activity component that is the root of the
5315 * task; this is the activity that has been published in the application's
5316 * manifest as the main launcher icon.
5317 *
5318 * @return Returns a newly created Intent that can be used to relaunch the
5319 * activity's task in its root state.
5320 */
5321 public static Intent makeRestartActivityTask(ComponentName mainActivity) {
5322 Intent intent = makeMainActivity(mainActivity);
5323 intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK
5324 | Intent.FLAG_ACTIVITY_CLEAR_TASK);
5325 return intent;
5326 }
5327
5328 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005329 * Call {@link #parseUri} with 0 flags.
5330 * @deprecated Use {@link #parseUri} instead.
5331 */
5332 @Deprecated
5333 public static Intent getIntent(String uri) throws URISyntaxException {
5334 return parseUri(uri, 0);
5335 }
Tom Taylord4a47292009-12-21 13:59:18 -08005336
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005337 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005338 * Create an intent from a URI. This URI may encode the action,
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005339 * category, and other intent fields, if it was returned by
Dianne Hackborn7f205432009-07-28 00:13:47 -07005340 * {@link #toUri}. If the Intent was not generate by toUri(), its data
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005341 * will be the entire URI and its action will be ACTION_VIEW.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005342 *
5343 * <p>The URI given here must not be relative -- that is, it must include
5344 * the scheme and full path.
5345 *
5346 * @param uri The URI to turn into an Intent.
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005347 * @param flags Additional processing flags. Either 0,
5348 * {@link #URI_INTENT_SCHEME}, or {@link #URI_ANDROID_APP_SCHEME}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005349 *
5350 * @return Intent The newly created Intent object.
5351 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005352 * @throws URISyntaxException Throws URISyntaxError if the basic URI syntax
5353 * it bad (as parsed by the Uri class) or the Intent data within the
5354 * URI is invalid.
Tom Taylord4a47292009-12-21 13:59:18 -08005355 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005356 * @see #toUri
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005357 */
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005358 public static Intent parseUri(String uri, int flags) throws URISyntaxException {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005359 int i = 0;
5360 try {
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005361 final boolean androidApp = uri.startsWith("android-app:");
5362
5363 // Validate intent scheme if requested.
5364 if ((flags&(URI_INTENT_SCHEME|URI_ANDROID_APP_SCHEME)) != 0) {
5365 if (!uri.startsWith("intent:") && !androidApp) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005366 Intent intent = new Intent(ACTION_VIEW);
5367 try {
5368 intent.setData(Uri.parse(uri));
5369 } catch (IllegalArgumentException e) {
5370 throw new URISyntaxException(uri, e.getMessage());
5371 }
5372 return intent;
5373 }
5374 }
Tom Taylord4a47292009-12-21 13:59:18 -08005375
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005376 i = uri.lastIndexOf("#");
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005377 // simple case
5378 if (i == -1) {
5379 if (!androidApp) {
5380 return new Intent(ACTION_VIEW, Uri.parse(uri));
5381 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005382
5383 // old format Intent URI
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005384 } else if (!uri.startsWith("#Intent;", i)) {
5385 if (!androidApp) {
Dianne Hackborn24b1c232014-11-20 17:17:39 -08005386 return getIntentOld(uri, flags);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005387 } else {
5388 i = -1;
5389 }
5390 }
The Android Open Source Project10592532009-03-18 17:39:46 -07005391
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005392 // new format
5393 Intent intent = new Intent(ACTION_VIEW);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005394 Intent baseIntent = intent;
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005395 boolean explicitAction = false;
5396 boolean inSelector = false;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005397
5398 // fetch data part, if present
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005399 String scheme = null;
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005400 String data;
5401 if (i >= 0) {
5402 data = uri.substring(0, i);
5403 i += 8; // length of "#Intent;"
5404 } else {
5405 data = uri;
5406 }
The Android Open Source Project10592532009-03-18 17:39:46 -07005407
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005408 // loop over contents of Intent, all name=value;
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005409 while (i >= 0 && !uri.startsWith("end", i)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005410 int eq = uri.indexOf('=', i);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005411 if (eq < 0) eq = i-1;
5412 int semi = uri.indexOf(';', i);
5413 String value = eq < semi ? Uri.decode(uri.substring(eq + 1, semi)) : "";
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005414
5415 // action
5416 if (uri.startsWith("action=", i)) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08005417 intent.setAction(value);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005418 if (!inSelector) {
5419 explicitAction = true;
5420 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005421 }
5422
5423 // categories
5424 else if (uri.startsWith("category=", i)) {
5425 intent.addCategory(value);
5426 }
5427
5428 // type
5429 else if (uri.startsWith("type=", i)) {
5430 intent.mType = value;
5431 }
5432
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08005433 // launch flags
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005434 else if (uri.startsWith("launchFlags=", i)) {
5435 intent.mFlags = Integer.decode(value).intValue();
Dianne Hackborn24b1c232014-11-20 17:17:39 -08005436 if ((flags& URI_ALLOW_UNSAFE) == 0) {
5437 intent.mFlags &= ~IMMUTABLE_FLAGS;
5438 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005439 }
5440
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005441 // package
5442 else if (uri.startsWith("package=", i)) {
5443 intent.mPackage = value;
5444 }
5445
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005446 // component
5447 else if (uri.startsWith("component=", i)) {
5448 intent.mComponent = ComponentName.unflattenFromString(value);
5449 }
The Android Open Source Project10592532009-03-18 17:39:46 -07005450
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005451 // scheme
5452 else if (uri.startsWith("scheme=", i)) {
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005453 if (inSelector) {
Dianne Hackborn80b1c562014-12-09 20:22:08 -08005454 intent.mData = Uri.parse(value + ":");
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005455 } else {
5456 scheme = value;
5457 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005458 }
5459
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08005460 // source bounds
5461 else if (uri.startsWith("sourceBounds=", i)) {
5462 intent.mSourceBounds = Rect.unflattenFromString(value);
5463 }
5464
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005465 // selector
5466 else if (semi == (i+3) && uri.startsWith("SEL", i)) {
5467 intent = new Intent();
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005468 inSelector = true;
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005469 }
5470
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005471 // extra
5472 else {
5473 String key = Uri.decode(uri.substring(i + 2, eq));
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005474 // create Bundle if it doesn't already exist
5475 if (intent.mExtras == null) intent.mExtras = new Bundle();
5476 Bundle b = intent.mExtras;
5477 // add EXTRA
5478 if (uri.startsWith("S.", i)) b.putString(key, value);
5479 else if (uri.startsWith("B.", i)) b.putBoolean(key, Boolean.parseBoolean(value));
5480 else if (uri.startsWith("b.", i)) b.putByte(key, Byte.parseByte(value));
5481 else if (uri.startsWith("c.", i)) b.putChar(key, value.charAt(0));
5482 else if (uri.startsWith("d.", i)) b.putDouble(key, Double.parseDouble(value));
5483 else if (uri.startsWith("f.", i)) b.putFloat(key, Float.parseFloat(value));
5484 else if (uri.startsWith("i.", i)) b.putInt(key, Integer.parseInt(value));
5485 else if (uri.startsWith("l.", i)) b.putLong(key, Long.parseLong(value));
5486 else if (uri.startsWith("s.", i)) b.putShort(key, Short.parseShort(value));
5487 else throw new URISyntaxException(uri, "unknown EXTRA type", i);
5488 }
The Android Open Source Project10592532009-03-18 17:39:46 -07005489
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005490 // move to the next item
5491 i = semi + 1;
5492 }
5493
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005494 if (inSelector) {
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005495 // The Intent had a selector; fix it up.
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005496 if (baseIntent.mPackage == null) {
5497 baseIntent.setSelector(intent);
5498 }
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005499 intent = baseIntent;
5500 }
5501
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005502 if (data != null) {
5503 if (data.startsWith("intent:")) {
5504 data = data.substring(7);
5505 if (scheme != null) {
5506 data = scheme + ':' + data;
5507 }
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005508 } else if (data.startsWith("android-app:")) {
5509 if (data.charAt(12) == '/' && data.charAt(13) == '/') {
5510 // Correctly formed android-app, first part is package name.
5511 int end = data.indexOf('/', 14);
5512 if (end < 0) {
5513 // All we have is a package name.
5514 intent.mPackage = data.substring(14);
5515 if (!explicitAction) {
5516 intent.setAction(ACTION_MAIN);
5517 }
5518 data = "";
5519 } else {
5520 // Target the Intent at the given package name always.
5521 String authority = null;
5522 intent.mPackage = data.substring(14, end);
5523 int newEnd;
Dianne Hackborn80b1c562014-12-09 20:22:08 -08005524 if ((end+1) < data.length()) {
5525 if ((newEnd=data.indexOf('/', end+1)) >= 0) {
5526 // Found a scheme, remember it.
5527 scheme = data.substring(end+1, newEnd);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005528 end = newEnd;
Dianne Hackborn80b1c562014-12-09 20:22:08 -08005529 if (end < data.length() && (newEnd=data.indexOf('/', end+1)) >= 0) {
5530 // Found a authority, remember it.
5531 authority = data.substring(end+1, newEnd);
5532 end = newEnd;
5533 }
5534 } else {
5535 // All we have is a scheme.
5536 scheme = data.substring(end+1);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005537 }
5538 }
5539 if (scheme == null) {
5540 // If there was no scheme, then this just targets the package.
5541 if (!explicitAction) {
5542 intent.setAction(ACTION_MAIN);
5543 }
5544 data = "";
5545 } else if (authority == null) {
5546 data = scheme + ":";
5547 } else {
5548 data = scheme + "://" + authority + data.substring(end);
5549 }
5550 }
5551 } else {
5552 data = "";
5553 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005554 }
Tom Taylord4a47292009-12-21 13:59:18 -08005555
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005556 if (data.length() > 0) {
5557 try {
5558 intent.mData = Uri.parse(data);
5559 } catch (IllegalArgumentException e) {
5560 throw new URISyntaxException(uri, e.getMessage());
5561 }
5562 }
5563 }
Tom Taylord4a47292009-12-21 13:59:18 -08005564
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005565 return intent;
The Android Open Source Project10592532009-03-18 17:39:46 -07005566
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005567 } catch (IndexOutOfBoundsException e) {
5568 throw new URISyntaxException(uri, "illegal Intent URI format", i);
5569 }
5570 }
The Android Open Source Project10592532009-03-18 17:39:46 -07005571
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005572 public static Intent getIntentOld(String uri) throws URISyntaxException {
Dianne Hackborn24b1c232014-11-20 17:17:39 -08005573 return getIntentOld(uri, 0);
5574 }
5575
5576 private static Intent getIntentOld(String uri, int flags) throws URISyntaxException {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005577 Intent intent;
5578
5579 int i = uri.lastIndexOf('#');
5580 if (i >= 0) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005581 String action = null;
Dianne Hackborn6cca1592009-09-20 12:40:03 -07005582 final int intentFragmentStart = i;
5583 boolean isIntentFragment = false;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005584
5585 i++;
5586
5587 if (uri.regionMatches(i, "action(", 0, 7)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07005588 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005589 i += 7;
5590 int j = uri.indexOf(')', i);
5591 action = uri.substring(i, j);
5592 i = j + 1;
5593 }
5594
Dianne Hackborn6cca1592009-09-20 12:40:03 -07005595 intent = new Intent(action);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005596
5597 if (uri.regionMatches(i, "categories(", 0, 11)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07005598 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005599 i += 11;
5600 int j = uri.indexOf(')', i);
5601 while (i < j) {
5602 int sep = uri.indexOf('!', i);
Alan Viverette0adf32b2014-09-18 12:53:16 -07005603 if (sep < 0 || sep > j) sep = j;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005604 if (i < sep) {
5605 intent.addCategory(uri.substring(i, sep));
5606 }
5607 i = sep + 1;
5608 }
5609 i = j + 1;
5610 }
5611
5612 if (uri.regionMatches(i, "type(", 0, 5)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07005613 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005614 i += 5;
5615 int j = uri.indexOf(')', i);
5616 intent.mType = uri.substring(i, j);
5617 i = j + 1;
5618 }
5619
5620 if (uri.regionMatches(i, "launchFlags(", 0, 12)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07005621 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005622 i += 12;
5623 int j = uri.indexOf(')', i);
5624 intent.mFlags = Integer.decode(uri.substring(i, j)).intValue();
Dianne Hackborn24b1c232014-11-20 17:17:39 -08005625 if ((flags& URI_ALLOW_UNSAFE) == 0) {
5626 intent.mFlags &= ~IMMUTABLE_FLAGS;
5627 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005628 i = j + 1;
5629 }
5630
5631 if (uri.regionMatches(i, "component(", 0, 10)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07005632 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005633 i += 10;
5634 int j = uri.indexOf(')', i);
5635 int sep = uri.indexOf('!', i);
5636 if (sep >= 0 && sep < j) {
5637 String pkg = uri.substring(i, sep);
5638 String cls = uri.substring(sep + 1, j);
5639 intent.mComponent = new ComponentName(pkg, cls);
5640 }
5641 i = j + 1;
5642 }
5643
5644 if (uri.regionMatches(i, "extras(", 0, 7)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07005645 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005646 i += 7;
The Android Open Source Project10592532009-03-18 17:39:46 -07005647
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005648 final int closeParen = uri.indexOf(')', i);
5649 if (closeParen == -1) throw new URISyntaxException(uri,
5650 "EXTRA missing trailing ')'", i);
5651
5652 while (i < closeParen) {
5653 // fetch the key value
5654 int j = uri.indexOf('=', i);
5655 if (j <= i + 1 || i >= closeParen) {
5656 throw new URISyntaxException(uri, "EXTRA missing '='", i);
5657 }
5658 char type = uri.charAt(i);
5659 i++;
5660 String key = uri.substring(i, j);
5661 i = j + 1;
The Android Open Source Project10592532009-03-18 17:39:46 -07005662
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005663 // get type-value
5664 j = uri.indexOf('!', i);
5665 if (j == -1 || j >= closeParen) j = closeParen;
5666 if (i >= j) throw new URISyntaxException(uri, "EXTRA missing '!'", i);
5667 String value = uri.substring(i, j);
5668 i = j;
5669
5670 // create Bundle if it doesn't already exist
5671 if (intent.mExtras == null) intent.mExtras = new Bundle();
The Android Open Source Project10592532009-03-18 17:39:46 -07005672
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005673 // add item to bundle
5674 try {
5675 switch (type) {
5676 case 'S':
5677 intent.mExtras.putString(key, Uri.decode(value));
5678 break;
5679 case 'B':
5680 intent.mExtras.putBoolean(key, Boolean.parseBoolean(value));
5681 break;
5682 case 'b':
5683 intent.mExtras.putByte(key, Byte.parseByte(value));
5684 break;
5685 case 'c':
5686 intent.mExtras.putChar(key, Uri.decode(value).charAt(0));
5687 break;
5688 case 'd':
5689 intent.mExtras.putDouble(key, Double.parseDouble(value));
5690 break;
5691 case 'f':
5692 intent.mExtras.putFloat(key, Float.parseFloat(value));
5693 break;
5694 case 'i':
5695 intent.mExtras.putInt(key, Integer.parseInt(value));
5696 break;
5697 case 'l':
5698 intent.mExtras.putLong(key, Long.parseLong(value));
5699 break;
5700 case 's':
5701 intent.mExtras.putShort(key, Short.parseShort(value));
5702 break;
5703 default:
5704 throw new URISyntaxException(uri, "EXTRA has unknown type", i);
5705 }
5706 } catch (NumberFormatException e) {
5707 throw new URISyntaxException(uri, "EXTRA value can't be parsed", i);
5708 }
The Android Open Source Project10592532009-03-18 17:39:46 -07005709
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005710 char ch = uri.charAt(i);
5711 if (ch == ')') break;
5712 if (ch != '!') throw new URISyntaxException(uri, "EXTRA missing '!'", i);
5713 i++;
5714 }
5715 }
5716
Dianne Hackborn6cca1592009-09-20 12:40:03 -07005717 if (isIntentFragment) {
5718 intent.mData = Uri.parse(uri.substring(0, intentFragmentStart));
5719 } else {
5720 intent.mData = Uri.parse(uri);
5721 }
Tom Taylord4a47292009-12-21 13:59:18 -08005722
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005723 if (intent.mAction == null) {
5724 // By default, if no action is specified, then use VIEW.
5725 intent.mAction = ACTION_VIEW;
5726 }
5727
5728 } else {
5729 intent = new Intent(ACTION_VIEW, Uri.parse(uri));
5730 }
5731
5732 return intent;
5733 }
5734
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08005735 /** @hide */
5736 public interface CommandOptionHandler {
5737 boolean handleOption(String opt, ShellCommand cmd);
5738 }
5739
5740 /** @hide */
5741 public static Intent parseCommandArgs(ShellCommand cmd, CommandOptionHandler optionHandler)
5742 throws URISyntaxException {
5743 Intent intent = new Intent();
5744 Intent baseIntent = intent;
5745 boolean hasIntentInfo = false;
5746
5747 Uri data = null;
5748 String type = null;
5749
5750 String opt;
5751 while ((opt=cmd.getNextOption()) != null) {
5752 switch (opt) {
5753 case "-a":
5754 intent.setAction(cmd.getNextArgRequired());
5755 if (intent == baseIntent) {
5756 hasIntentInfo = true;
5757 }
5758 break;
5759 case "-d":
5760 data = Uri.parse(cmd.getNextArgRequired());
5761 if (intent == baseIntent) {
5762 hasIntentInfo = true;
5763 }
5764 break;
5765 case "-t":
5766 type = cmd.getNextArgRequired();
5767 if (intent == baseIntent) {
5768 hasIntentInfo = true;
5769 }
5770 break;
5771 case "-c":
5772 intent.addCategory(cmd.getNextArgRequired());
5773 if (intent == baseIntent) {
5774 hasIntentInfo = true;
5775 }
5776 break;
5777 case "-e":
5778 case "--es": {
5779 String key = cmd.getNextArgRequired();
5780 String value = cmd.getNextArgRequired();
5781 intent.putExtra(key, value);
5782 }
5783 break;
5784 case "--esn": {
5785 String key = cmd.getNextArgRequired();
5786 intent.putExtra(key, (String) null);
5787 }
5788 break;
5789 case "--ei": {
5790 String key = cmd.getNextArgRequired();
5791 String value = cmd.getNextArgRequired();
5792 intent.putExtra(key, Integer.decode(value));
5793 }
5794 break;
5795 case "--eu": {
5796 String key = cmd.getNextArgRequired();
5797 String value = cmd.getNextArgRequired();
5798 intent.putExtra(key, Uri.parse(value));
5799 }
5800 break;
5801 case "--ecn": {
5802 String key = cmd.getNextArgRequired();
5803 String value = cmd.getNextArgRequired();
5804 ComponentName cn = ComponentName.unflattenFromString(value);
5805 if (cn == null)
5806 throw new IllegalArgumentException("Bad component name: " + value);
5807 intent.putExtra(key, cn);
5808 }
5809 break;
5810 case "--eia": {
5811 String key = cmd.getNextArgRequired();
5812 String value = cmd.getNextArgRequired();
5813 String[] strings = value.split(",");
5814 int[] list = new int[strings.length];
5815 for (int i = 0; i < strings.length; i++) {
5816 list[i] = Integer.decode(strings[i]);
5817 }
5818 intent.putExtra(key, list);
5819 }
5820 break;
5821 case "--eial": {
5822 String key = cmd.getNextArgRequired();
5823 String value = cmd.getNextArgRequired();
5824 String[] strings = value.split(",");
5825 ArrayList<Integer> list = new ArrayList<>(strings.length);
5826 for (int i = 0; i < strings.length; i++) {
5827 list.add(Integer.decode(strings[i]));
5828 }
5829 intent.putExtra(key, list);
5830 }
5831 break;
5832 case "--el": {
5833 String key = cmd.getNextArgRequired();
5834 String value = cmd.getNextArgRequired();
5835 intent.putExtra(key, Long.valueOf(value));
5836 }
5837 break;
5838 case "--ela": {
5839 String key = cmd.getNextArgRequired();
5840 String value = cmd.getNextArgRequired();
5841 String[] strings = value.split(",");
5842 long[] list = new long[strings.length];
5843 for (int i = 0; i < strings.length; i++) {
5844 list[i] = Long.valueOf(strings[i]);
5845 }
5846 intent.putExtra(key, list);
5847 hasIntentInfo = true;
5848 }
5849 break;
5850 case "--elal": {
5851 String key = cmd.getNextArgRequired();
5852 String value = cmd.getNextArgRequired();
5853 String[] strings = value.split(",");
5854 ArrayList<Long> list = new ArrayList<>(strings.length);
5855 for (int i = 0; i < strings.length; i++) {
5856 list.add(Long.valueOf(strings[i]));
5857 }
5858 intent.putExtra(key, list);
5859 hasIntentInfo = true;
5860 }
5861 break;
5862 case "--ef": {
5863 String key = cmd.getNextArgRequired();
5864 String value = cmd.getNextArgRequired();
5865 intent.putExtra(key, Float.valueOf(value));
5866 hasIntentInfo = true;
5867 }
5868 break;
5869 case "--efa": {
5870 String key = cmd.getNextArgRequired();
5871 String value = cmd.getNextArgRequired();
5872 String[] strings = value.split(",");
5873 float[] list = new float[strings.length];
5874 for (int i = 0; i < strings.length; i++) {
5875 list[i] = Float.valueOf(strings[i]);
5876 }
5877 intent.putExtra(key, list);
5878 hasIntentInfo = true;
5879 }
5880 break;
5881 case "--efal": {
5882 String key = cmd.getNextArgRequired();
5883 String value = cmd.getNextArgRequired();
5884 String[] strings = value.split(",");
5885 ArrayList<Float> list = new ArrayList<>(strings.length);
5886 for (int i = 0; i < strings.length; i++) {
5887 list.add(Float.valueOf(strings[i]));
5888 }
5889 intent.putExtra(key, list);
5890 hasIntentInfo = true;
5891 }
5892 break;
5893 case "--esa": {
5894 String key = cmd.getNextArgRequired();
5895 String value = cmd.getNextArgRequired();
5896 // Split on commas unless they are preceeded by an escape.
5897 // The escape character must be escaped for the string and
5898 // again for the regex, thus four escape characters become one.
5899 String[] strings = value.split("(?<!\\\\),");
5900 intent.putExtra(key, strings);
5901 hasIntentInfo = true;
5902 }
5903 break;
5904 case "--esal": {
5905 String key = cmd.getNextArgRequired();
5906 String value = cmd.getNextArgRequired();
5907 // Split on commas unless they are preceeded by an escape.
5908 // The escape character must be escaped for the string and
5909 // again for the regex, thus four escape characters become one.
5910 String[] strings = value.split("(?<!\\\\),");
5911 ArrayList<String> list = new ArrayList<>(strings.length);
5912 for (int i = 0; i < strings.length; i++) {
5913 list.add(strings[i]);
5914 }
5915 intent.putExtra(key, list);
5916 hasIntentInfo = true;
5917 }
5918 break;
5919 case "--ez": {
5920 String key = cmd.getNextArgRequired();
5921 String value = cmd.getNextArgRequired().toLowerCase();
5922 // Boolean.valueOf() results in false for anything that is not "true", which is
5923 // error-prone in shell commands
5924 boolean arg;
5925 if ("true".equals(value) || "t".equals(value)) {
5926 arg = true;
5927 } else if ("false".equals(value) || "f".equals(value)) {
5928 arg = false;
5929 } else {
5930 try {
5931 arg = Integer.decode(value) != 0;
5932 } catch (NumberFormatException ex) {
5933 throw new IllegalArgumentException("Invalid boolean value: " + value);
5934 }
5935 }
5936
5937 intent.putExtra(key, arg);
5938 }
5939 break;
5940 case "-n": {
5941 String str = cmd.getNextArgRequired();
5942 ComponentName cn = ComponentName.unflattenFromString(str);
5943 if (cn == null)
5944 throw new IllegalArgumentException("Bad component name: " + str);
5945 intent.setComponent(cn);
5946 if (intent == baseIntent) {
5947 hasIntentInfo = true;
5948 }
5949 }
5950 break;
5951 case "-p": {
5952 String str = cmd.getNextArgRequired();
5953 intent.setPackage(str);
5954 if (intent == baseIntent) {
5955 hasIntentInfo = true;
5956 }
5957 }
5958 break;
5959 case "-f":
5960 String str = cmd.getNextArgRequired();
5961 intent.setFlags(Integer.decode(str).intValue());
5962 break;
5963 case "--grant-read-uri-permission":
5964 intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
5965 break;
5966 case "--grant-write-uri-permission":
5967 intent.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
5968 break;
5969 case "--grant-persistable-uri-permission":
5970 intent.addFlags(Intent.FLAG_GRANT_PERSISTABLE_URI_PERMISSION);
5971 break;
5972 case "--grant-prefix-uri-permission":
5973 intent.addFlags(Intent.FLAG_GRANT_PREFIX_URI_PERMISSION);
5974 break;
5975 case "--exclude-stopped-packages":
5976 intent.addFlags(Intent.FLAG_EXCLUDE_STOPPED_PACKAGES);
5977 break;
5978 case "--include-stopped-packages":
5979 intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
5980 break;
5981 case "--debug-log-resolution":
5982 intent.addFlags(Intent.FLAG_DEBUG_LOG_RESOLUTION);
5983 break;
5984 case "--activity-brought-to-front":
5985 intent.addFlags(Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT);
5986 break;
5987 case "--activity-clear-top":
5988 intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
5989 break;
5990 case "--activity-clear-when-task-reset":
5991 intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
5992 break;
5993 case "--activity-exclude-from-recents":
5994 intent.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
5995 break;
5996 case "--activity-launched-from-history":
5997 intent.addFlags(Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY);
5998 break;
5999 case "--activity-multiple-task":
6000 intent.addFlags(Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
6001 break;
6002 case "--activity-no-animation":
6003 intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
6004 break;
6005 case "--activity-no-history":
6006 intent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
6007 break;
6008 case "--activity-no-user-action":
6009 intent.addFlags(Intent.FLAG_ACTIVITY_NO_USER_ACTION);
6010 break;
6011 case "--activity-previous-is-top":
6012 intent.addFlags(Intent.FLAG_ACTIVITY_PREVIOUS_IS_TOP);
6013 break;
6014 case "--activity-reorder-to-front":
6015 intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
6016 break;
6017 case "--activity-reset-task-if-needed":
6018 intent.addFlags(Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
6019 break;
6020 case "--activity-single-top":
6021 intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
6022 break;
6023 case "--activity-clear-task":
6024 intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
6025 break;
6026 case "--activity-task-on-home":
6027 intent.addFlags(Intent.FLAG_ACTIVITY_TASK_ON_HOME);
6028 break;
6029 case "--receiver-registered-only":
6030 intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY);
6031 break;
6032 case "--receiver-replace-pending":
6033 intent.addFlags(Intent.FLAG_RECEIVER_REPLACE_PENDING);
6034 break;
Felipe Leme3cb48cd2016-01-27 08:39:09 -08006035 case "--receiver-foreground":
6036 intent.addFlags(Intent.FLAG_RECEIVER_FOREGROUND);
6037 break;
Dianne Hackborn797772b12017-02-08 16:33:43 -08006038 case "--receiver-no-abort":
6039 intent.addFlags(Intent.FLAG_RECEIVER_NO_ABORT);
6040 break;
6041 case "--receiver-include-background":
6042 intent.addFlags(Intent.FLAG_RECEIVER_INCLUDE_BACKGROUND);
6043 break;
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08006044 case "--selector":
6045 intent.setDataAndType(data, type);
6046 intent = new Intent();
6047 break;
6048 default:
6049 if (optionHandler != null && optionHandler.handleOption(opt, cmd)) {
6050 // Okay, caller handled this option.
6051 } else {
6052 throw new IllegalArgumentException("Unknown option: " + opt);
6053 }
6054 break;
6055 }
6056 }
6057 intent.setDataAndType(data, type);
6058
6059 final boolean hasSelector = intent != baseIntent;
6060 if (hasSelector) {
6061 // A selector was specified; fix up.
6062 baseIntent.setSelector(intent);
6063 intent = baseIntent;
6064 }
6065
6066 String arg = cmd.getNextArg();
6067 baseIntent = null;
6068 if (arg == null) {
6069 if (hasSelector) {
6070 // If a selector has been specified, and no arguments
6071 // have been supplied for the main Intent, then we can
6072 // assume it is ACTION_MAIN CATEGORY_LAUNCHER; we don't
6073 // need to have a component name specified yet, the
6074 // selector will take care of that.
6075 baseIntent = new Intent(Intent.ACTION_MAIN);
6076 baseIntent.addCategory(Intent.CATEGORY_LAUNCHER);
6077 }
6078 } else if (arg.indexOf(':') >= 0) {
6079 // The argument is a URI. Fully parse it, and use that result
6080 // to fill in any data not specified so far.
6081 baseIntent = Intent.parseUri(arg, Intent.URI_INTENT_SCHEME
6082 | Intent.URI_ANDROID_APP_SCHEME | Intent.URI_ALLOW_UNSAFE);
6083 } else if (arg.indexOf('/') >= 0) {
6084 // The argument is a component name. Build an Intent to launch
6085 // it.
6086 baseIntent = new Intent(Intent.ACTION_MAIN);
6087 baseIntent.addCategory(Intent.CATEGORY_LAUNCHER);
6088 baseIntent.setComponent(ComponentName.unflattenFromString(arg));
6089 } else {
6090 // Assume the argument is a package name.
6091 baseIntent = new Intent(Intent.ACTION_MAIN);
6092 baseIntent.addCategory(Intent.CATEGORY_LAUNCHER);
6093 baseIntent.setPackage(arg);
6094 }
6095 if (baseIntent != null) {
6096 Bundle extras = intent.getExtras();
6097 intent.replaceExtras((Bundle)null);
6098 Bundle uriExtras = baseIntent.getExtras();
6099 baseIntent.replaceExtras((Bundle)null);
6100 if (intent.getAction() != null && baseIntent.getCategories() != null) {
6101 HashSet<String> cats = new HashSet<String>(baseIntent.getCategories());
6102 for (String c : cats) {
6103 baseIntent.removeCategory(c);
6104 }
6105 }
6106 intent.fillIn(baseIntent, Intent.FILL_IN_COMPONENT | Intent.FILL_IN_SELECTOR);
6107 if (extras == null) {
6108 extras = uriExtras;
6109 } else if (uriExtras != null) {
6110 uriExtras.putAll(extras);
6111 extras = uriExtras;
6112 }
6113 intent.replaceExtras(extras);
6114 hasIntentInfo = true;
6115 }
6116
6117 if (!hasIntentInfo) throw new IllegalArgumentException("No intent supplied");
6118 return intent;
6119 }
6120
6121 /** @hide */
6122 public static void printIntentArgsHelp(PrintWriter pw, String prefix) {
6123 final String[] lines = new String[] {
6124 "<INTENT> specifications include these flags and arguments:",
6125 " [-a <ACTION>] [-d <DATA_URI>] [-t <MIME_TYPE>]",
6126 " [-c <CATEGORY> [-c <CATEGORY>] ...]",
6127 " [-e|--es <EXTRA_KEY> <EXTRA_STRING_VALUE> ...]",
6128 " [--esn <EXTRA_KEY> ...]",
6129 " [--ez <EXTRA_KEY> <EXTRA_BOOLEAN_VALUE> ...]",
6130 " [--ei <EXTRA_KEY> <EXTRA_INT_VALUE> ...]",
6131 " [--el <EXTRA_KEY> <EXTRA_LONG_VALUE> ...]",
6132 " [--ef <EXTRA_KEY> <EXTRA_FLOAT_VALUE> ...]",
6133 " [--eu <EXTRA_KEY> <EXTRA_URI_VALUE> ...]",
6134 " [--ecn <EXTRA_KEY> <EXTRA_COMPONENT_NAME_VALUE>]",
6135 " [--eia <EXTRA_KEY> <EXTRA_INT_VALUE>[,<EXTRA_INT_VALUE...]]",
6136 " (mutiple extras passed as Integer[])",
6137 " [--eial <EXTRA_KEY> <EXTRA_INT_VALUE>[,<EXTRA_INT_VALUE...]]",
6138 " (mutiple extras passed as List<Integer>)",
6139 " [--ela <EXTRA_KEY> <EXTRA_LONG_VALUE>[,<EXTRA_LONG_VALUE...]]",
6140 " (mutiple extras passed as Long[])",
6141 " [--elal <EXTRA_KEY> <EXTRA_LONG_VALUE>[,<EXTRA_LONG_VALUE...]]",
6142 " (mutiple extras passed as List<Long>)",
6143 " [--efa <EXTRA_KEY> <EXTRA_FLOAT_VALUE>[,<EXTRA_FLOAT_VALUE...]]",
6144 " (mutiple extras passed as Float[])",
6145 " [--efal <EXTRA_KEY> <EXTRA_FLOAT_VALUE>[,<EXTRA_FLOAT_VALUE...]]",
6146 " (mutiple extras passed as List<Float>)",
6147 " [--esa <EXTRA_KEY> <EXTRA_STRING_VALUE>[,<EXTRA_STRING_VALUE...]]",
6148 " (mutiple extras passed as String[]; to embed a comma into a string,",
6149 " escape it using \"\\,\")",
6150 " [--esal <EXTRA_KEY> <EXTRA_STRING_VALUE>[,<EXTRA_STRING_VALUE...]]",
6151 " (mutiple extras passed as List<String>; to embed a comma into a string,",
6152 " escape it using \"\\,\")",
Felipe Leme545569d2016-01-11 16:27:58 -08006153 " [-f <FLAG>]",
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08006154 " [--grant-read-uri-permission] [--grant-write-uri-permission]",
6155 " [--grant-persistable-uri-permission] [--grant-prefix-uri-permission]",
6156 " [--debug-log-resolution] [--exclude-stopped-packages]",
6157 " [--include-stopped-packages]",
6158 " [--activity-brought-to-front] [--activity-clear-top]",
6159 " [--activity-clear-when-task-reset] [--activity-exclude-from-recents]",
6160 " [--activity-launched-from-history] [--activity-multiple-task]",
6161 " [--activity-no-animation] [--activity-no-history]",
6162 " [--activity-no-user-action] [--activity-previous-is-top]",
6163 " [--activity-reorder-to-front] [--activity-reset-task-if-needed]",
6164 " [--activity-single-top] [--activity-clear-task]",
6165 " [--activity-task-on-home]",
6166 " [--receiver-registered-only] [--receiver-replace-pending]",
Dianne Hackborn797772b12017-02-08 16:33:43 -08006167 " [--receiver-foreground] [--receiver-no-abort]",
6168 " [--receiver-include-background]",
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08006169 " [--selector]",
6170 " [<URI> | <PACKAGE> | <COMPONENT>]"
6171 };
6172 for (String line : lines) {
6173 pw.print(prefix);
6174 pw.println(line);
6175 }
6176 }
6177
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006178 /**
6179 * Retrieve the general action to be performed, such as
6180 * {@link #ACTION_VIEW}. The action describes the general way the rest of
6181 * the information in the intent should be interpreted -- most importantly,
6182 * what to do with the data returned by {@link #getData}.
6183 *
6184 * @return The action of this intent or null if none is specified.
6185 *
6186 * @see #setAction
6187 */
6188 public String getAction() {
6189 return mAction;
6190 }
6191
6192 /**
6193 * Retrieve data this intent is operating on. This URI specifies the name
6194 * of the data; often it uses the content: scheme, specifying data in a
6195 * content provider. Other schemes may be handled by specific activities,
6196 * such as http: by the web browser.
6197 *
6198 * @return The URI of the data this intent is targeting or null.
6199 *
6200 * @see #getScheme
6201 * @see #setData
6202 */
6203 public Uri getData() {
6204 return mData;
6205 }
6206
6207 /**
6208 * The same as {@link #getData()}, but returns the URI as an encoded
6209 * String.
6210 */
6211 public String getDataString() {
6212 return mData != null ? mData.toString() : null;
6213 }
6214
6215 /**
6216 * Return the scheme portion of the intent's data. If the data is null or
6217 * does not include a scheme, null is returned. Otherwise, the scheme
6218 * prefix without the final ':' is returned, i.e. "http".
6219 *
6220 * <p>This is the same as calling getData().getScheme() (and checking for
6221 * null data).
6222 *
6223 * @return The scheme of this intent.
6224 *
6225 * @see #getData
6226 */
6227 public String getScheme() {
6228 return mData != null ? mData.getScheme() : null;
6229 }
6230
6231 /**
6232 * Retrieve any explicit MIME type included in the intent. This is usually
6233 * null, as the type is determined by the intent data.
6234 *
6235 * @return If a type was manually set, it is returned; else null is
6236 * returned.
6237 *
6238 * @see #resolveType(ContentResolver)
6239 * @see #setType
6240 */
6241 public String getType() {
6242 return mType;
6243 }
6244
6245 /**
6246 * Return the MIME data type of this intent. If the type field is
6247 * explicitly set, that is simply returned. Otherwise, if the data is set,
6248 * the type of that data is returned. If neither fields are set, a null is
6249 * returned.
6250 *
6251 * @return The MIME type of this intent.
6252 *
6253 * @see #getType
6254 * @see #resolveType(ContentResolver)
6255 */
6256 public String resolveType(Context context) {
6257 return resolveType(context.getContentResolver());
6258 }
6259
6260 /**
6261 * Return the MIME data type of this intent. If the type field is
6262 * explicitly set, that is simply returned. Otherwise, if the data is set,
6263 * the type of that data is returned. If neither fields are set, a null is
6264 * returned.
6265 *
6266 * @param resolver A ContentResolver that can be used to determine the MIME
6267 * type of the intent's data.
6268 *
6269 * @return The MIME type of this intent.
6270 *
6271 * @see #getType
6272 * @see #resolveType(Context)
6273 */
6274 public String resolveType(ContentResolver resolver) {
6275 if (mType != null) {
6276 return mType;
6277 }
6278 if (mData != null) {
6279 if ("content".equals(mData.getScheme())) {
6280 return resolver.getType(mData);
6281 }
6282 }
6283 return null;
6284 }
6285
6286 /**
6287 * Return the MIME data type of this intent, only if it will be needed for
6288 * intent resolution. This is not generally useful for application code;
6289 * it is used by the frameworks for communicating with back-end system
6290 * services.
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, or null if it is unknown or not
6296 * needed.
6297 */
6298 public String resolveTypeIfNeeded(ContentResolver resolver) {
6299 if (mComponent != null) {
6300 return mType;
6301 }
6302 return resolveType(resolver);
6303 }
6304
6305 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09006306 * Check if a category exists in the intent.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006307 *
6308 * @param category The category to check.
6309 *
6310 * @return boolean True if the intent contains the category, else false.
6311 *
6312 * @see #getCategories
6313 * @see #addCategory
6314 */
6315 public boolean hasCategory(String category) {
6316 return mCategories != null && mCategories.contains(category);
6317 }
6318
6319 /**
6320 * Return the set of all categories in the intent. If there are no categories,
6321 * returns NULL.
6322 *
Dianne Hackbornf5b86712011-12-05 17:42:41 -08006323 * @return The set of categories you can examine. Do not modify!
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006324 *
6325 * @see #hasCategory
6326 * @see #addCategory
6327 */
6328 public Set<String> getCategories() {
6329 return mCategories;
6330 }
6331
6332 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08006333 * Return the specific selector associated with this Intent. If there is
6334 * none, returns null. See {@link #setSelector} for more information.
6335 *
6336 * @see #setSelector
6337 */
6338 public Intent getSelector() {
6339 return mSelector;
6340 }
6341
6342 /**
Dianne Hackborn21c241e2012-03-08 13:57:23 -08006343 * Return the {@link ClipData} associated with this Intent. If there is
6344 * none, returns null. See {@link #setClipData} for more information.
6345 *
John Spurlock125d1332013-11-25 11:58:37 -05006346 * @see #setClipData
Dianne Hackborn21c241e2012-03-08 13:57:23 -08006347 */
6348 public ClipData getClipData() {
6349 return mClipData;
6350 }
6351
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01006352 /** @hide */
6353 public int getContentUserHint() {
6354 return mContentUserHint;
6355 }
6356
Dianne Hackborn21c241e2012-03-08 13:57:23 -08006357 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006358 * Sets the ClassLoader that will be used when unmarshalling
6359 * any Parcelable values from the extras of this Intent.
6360 *
6361 * @param loader a ClassLoader, or null to use the default loader
6362 * at the time of unmarshalling.
6363 */
6364 public void setExtrasClassLoader(ClassLoader loader) {
6365 if (mExtras != null) {
6366 mExtras.setClassLoader(loader);
6367 }
6368 }
6369
6370 /**
6371 * Returns true if an extra value is associated with the given name.
6372 * @param name the extra's name
6373 * @return true if the given extra is present.
6374 */
6375 public boolean hasExtra(String name) {
6376 return mExtras != null && mExtras.containsKey(name);
6377 }
6378
6379 /**
6380 * Returns true if the Intent's extras contain a parcelled file descriptor.
6381 * @return true if the Intent contains a parcelled file descriptor.
6382 */
6383 public boolean hasFileDescriptors() {
6384 return mExtras != null && mExtras.hasFileDescriptors();
6385 }
The Android Open Source Project10592532009-03-18 17:39:46 -07006386
Jeff Sharkeyd136e512016-03-09 22:30:56 -07006387 /** {@hide} */
Dianne Hackborn9ecebbf2011-09-28 23:19:47 -04006388 public void setAllowFds(boolean allowFds) {
6389 if (mExtras != null) {
6390 mExtras.setAllowFds(allowFds);
6391 }
6392 }
6393
Jeff Sharkeyd136e512016-03-09 22:30:56 -07006394 /** {@hide} */
6395 public void setDefusable(boolean defusable) {
6396 if (mExtras != null) {
6397 mExtras.setDefusable(defusable);
6398 }
6399 }
6400
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006401 /**
6402 * Retrieve extended data from the intent.
6403 *
6404 * @param name The name of the desired item.
6405 *
6406 * @return the value of an item that previously added with putExtra()
6407 * or null if none was found.
6408 *
6409 * @deprecated
6410 * @hide
6411 */
6412 @Deprecated
6413 public Object getExtra(String name) {
6414 return getExtra(name, null);
6415 }
6416
6417 /**
6418 * Retrieve extended data from the intent.
6419 *
6420 * @param name The name of the desired item.
6421 * @param defaultValue the value to be returned if no value of the desired
6422 * type is stored with the given name.
6423 *
6424 * @return the value of an item that previously added with putExtra()
6425 * or the default value if none was found.
6426 *
6427 * @see #putExtra(String, boolean)
6428 */
6429 public boolean getBooleanExtra(String name, boolean defaultValue) {
6430 return mExtras == null ? defaultValue :
6431 mExtras.getBoolean(name, defaultValue);
6432 }
6433
6434 /**
6435 * Retrieve extended data from the intent.
6436 *
6437 * @param name The name of the desired item.
6438 * @param defaultValue the value to be returned if no value of the desired
6439 * type is stored with the given name.
6440 *
6441 * @return the value of an item that previously added with putExtra()
6442 * or the default value if none was found.
6443 *
6444 * @see #putExtra(String, byte)
6445 */
6446 public byte getByteExtra(String name, byte defaultValue) {
6447 return mExtras == null ? defaultValue :
6448 mExtras.getByte(name, defaultValue);
6449 }
6450
6451 /**
6452 * Retrieve extended data from the intent.
6453 *
6454 * @param name The name of the desired item.
6455 * @param defaultValue the value to be returned if no value of the desired
6456 * type is stored with the given name.
6457 *
6458 * @return the value of an item that previously added with putExtra()
6459 * or the default value if none was found.
6460 *
6461 * @see #putExtra(String, short)
6462 */
6463 public short getShortExtra(String name, short defaultValue) {
6464 return mExtras == null ? defaultValue :
6465 mExtras.getShort(name, defaultValue);
6466 }
6467
6468 /**
6469 * Retrieve extended data from the intent.
6470 *
6471 * @param name The name of the desired item.
6472 * @param defaultValue the value to be returned if no value of the desired
6473 * type is stored with the given name.
6474 *
6475 * @return the value of an item that previously added with putExtra()
6476 * or the default value if none was found.
6477 *
6478 * @see #putExtra(String, char)
6479 */
6480 public char getCharExtra(String name, char defaultValue) {
6481 return mExtras == null ? defaultValue :
6482 mExtras.getChar(name, defaultValue);
6483 }
6484
6485 /**
6486 * Retrieve extended data from the intent.
6487 *
6488 * @param name The name of the desired item.
6489 * @param defaultValue the value to be returned if no value of the desired
6490 * type is stored with the given name.
6491 *
6492 * @return the value of an item that previously added with putExtra()
6493 * or the default value if none was found.
6494 *
6495 * @see #putExtra(String, int)
6496 */
6497 public int getIntExtra(String name, int defaultValue) {
6498 return mExtras == null ? defaultValue :
6499 mExtras.getInt(name, defaultValue);
6500 }
6501
6502 /**
6503 * Retrieve extended data from the intent.
6504 *
6505 * @param name The name of the desired item.
6506 * @param defaultValue the value to be returned if no value of the desired
6507 * type is stored with the given name.
6508 *
6509 * @return the value of an item that previously added with putExtra()
6510 * or the default value if none was found.
6511 *
6512 * @see #putExtra(String, long)
6513 */
6514 public long getLongExtra(String name, long defaultValue) {
6515 return mExtras == null ? defaultValue :
6516 mExtras.getLong(name, defaultValue);
6517 }
6518
6519 /**
6520 * Retrieve extended data from the intent.
6521 *
6522 * @param name The name of the desired item.
6523 * @param defaultValue the value to be returned if no value of the desired
6524 * type is stored with the given name.
6525 *
6526 * @return the value of an item that previously added with putExtra(),
6527 * or the default value if no such item is present
6528 *
6529 * @see #putExtra(String, float)
6530 */
6531 public float getFloatExtra(String name, float defaultValue) {
6532 return mExtras == null ? defaultValue :
6533 mExtras.getFloat(name, defaultValue);
6534 }
6535
6536 /**
6537 * Retrieve extended data from the intent.
6538 *
6539 * @param name The name of the desired item.
6540 * @param defaultValue the value to be returned if no value of the desired
6541 * type is stored with the given name.
6542 *
6543 * @return the value of an item that previously added with putExtra()
6544 * or the default value if none was found.
6545 *
6546 * @see #putExtra(String, double)
6547 */
6548 public double getDoubleExtra(String name, double defaultValue) {
6549 return mExtras == null ? defaultValue :
6550 mExtras.getDouble(name, defaultValue);
6551 }
6552
6553 /**
6554 * Retrieve extended data from the intent.
6555 *
6556 * @param name The name of the desired item.
6557 *
6558 * @return the value of an item that previously added with putExtra()
6559 * or null if no String value was found.
6560 *
6561 * @see #putExtra(String, String)
6562 */
6563 public String getStringExtra(String name) {
6564 return mExtras == null ? null : mExtras.getString(name);
6565 }
6566
6567 /**
6568 * Retrieve extended data from the intent.
6569 *
6570 * @param name The name of the desired item.
6571 *
6572 * @return the value of an item that previously added with putExtra()
6573 * or null if no CharSequence value was found.
6574 *
6575 * @see #putExtra(String, CharSequence)
6576 */
6577 public CharSequence getCharSequenceExtra(String name) {
6578 return mExtras == null ? null : mExtras.getCharSequence(name);
6579 }
6580
6581 /**
6582 * Retrieve extended data from the intent.
6583 *
6584 * @param name The name of the desired item.
6585 *
6586 * @return the value of an item that previously added with putExtra()
6587 * or null if no Parcelable value was found.
6588 *
6589 * @see #putExtra(String, Parcelable)
6590 */
6591 public <T extends Parcelable> T getParcelableExtra(String name) {
6592 return mExtras == null ? null : mExtras.<T>getParcelable(name);
6593 }
6594
6595 /**
6596 * Retrieve extended data from the intent.
6597 *
6598 * @param name The name of the desired item.
6599 *
6600 * @return the value of an item that previously added with putExtra()
6601 * or null if no Parcelable[] value was found.
6602 *
6603 * @see #putExtra(String, Parcelable[])
6604 */
6605 public Parcelable[] getParcelableArrayExtra(String name) {
6606 return mExtras == null ? null : mExtras.getParcelableArray(name);
6607 }
6608
6609 /**
6610 * Retrieve extended data from the intent.
6611 *
6612 * @param name The name of the desired item.
6613 *
6614 * @return the value of an item that previously added with putExtra()
6615 * or null if no ArrayList<Parcelable> value was found.
6616 *
6617 * @see #putParcelableArrayListExtra(String, ArrayList)
6618 */
6619 public <T extends Parcelable> ArrayList<T> getParcelableArrayListExtra(String name) {
6620 return mExtras == null ? null : mExtras.<T>getParcelableArrayList(name);
6621 }
6622
6623 /**
6624 * Retrieve extended data from the intent.
6625 *
6626 * @param name The name of the desired item.
6627 *
6628 * @return the value of an item that previously added with putExtra()
6629 * or null if no Serializable value was found.
6630 *
6631 * @see #putExtra(String, Serializable)
6632 */
6633 public Serializable getSerializableExtra(String name) {
6634 return mExtras == null ? null : mExtras.getSerializable(name);
6635 }
6636
6637 /**
6638 * Retrieve extended data from the intent.
6639 *
6640 * @param name The name of the desired item.
6641 *
6642 * @return the value of an item that previously added with putExtra()
6643 * or null if no ArrayList<Integer> value was found.
6644 *
6645 * @see #putIntegerArrayListExtra(String, ArrayList)
6646 */
6647 public ArrayList<Integer> getIntegerArrayListExtra(String name) {
6648 return mExtras == null ? null : mExtras.getIntegerArrayList(name);
6649 }
6650
6651 /**
6652 * Retrieve extended data from the intent.
6653 *
6654 * @param name The name of the desired item.
6655 *
6656 * @return the value of an item that previously added with putExtra()
6657 * or null if no ArrayList<String> value was found.
6658 *
6659 * @see #putStringArrayListExtra(String, ArrayList)
6660 */
6661 public ArrayList<String> getStringArrayListExtra(String name) {
6662 return mExtras == null ? null : mExtras.getStringArrayList(name);
6663 }
6664
6665 /**
6666 * Retrieve extended data from the intent.
6667 *
6668 * @param name The name of the desired item.
6669 *
6670 * @return the value of an item that previously added with putExtra()
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00006671 * or null if no ArrayList<CharSequence> value was found.
6672 *
6673 * @see #putCharSequenceArrayListExtra(String, ArrayList)
6674 */
6675 public ArrayList<CharSequence> getCharSequenceArrayListExtra(String name) {
6676 return mExtras == null ? null : mExtras.getCharSequenceArrayList(name);
6677 }
6678
6679 /**
6680 * Retrieve extended data from the intent.
6681 *
6682 * @param name The name of the desired item.
6683 *
6684 * @return the value of an item that previously added with putExtra()
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006685 * or null if no boolean array value was found.
6686 *
6687 * @see #putExtra(String, boolean[])
6688 */
6689 public boolean[] getBooleanArrayExtra(String name) {
6690 return mExtras == null ? null : mExtras.getBooleanArray(name);
6691 }
6692
6693 /**
6694 * Retrieve extended data from the intent.
6695 *
6696 * @param name The name of the desired item.
6697 *
6698 * @return the value of an item that previously added with putExtra()
6699 * or null if no byte array value was found.
6700 *
6701 * @see #putExtra(String, byte[])
6702 */
6703 public byte[] getByteArrayExtra(String name) {
6704 return mExtras == null ? null : mExtras.getByteArray(name);
6705 }
6706
6707 /**
6708 * Retrieve extended data from the intent.
6709 *
6710 * @param name The name of the desired item.
6711 *
6712 * @return the value of an item that previously added with putExtra()
6713 * or null if no short array value was found.
6714 *
6715 * @see #putExtra(String, short[])
6716 */
6717 public short[] getShortArrayExtra(String name) {
6718 return mExtras == null ? null : mExtras.getShortArray(name);
6719 }
6720
6721 /**
6722 * Retrieve extended data from the intent.
6723 *
6724 * @param name The name of the desired item.
6725 *
6726 * @return the value of an item that previously added with putExtra()
6727 * or null if no char array value was found.
6728 *
6729 * @see #putExtra(String, char[])
6730 */
6731 public char[] getCharArrayExtra(String name) {
6732 return mExtras == null ? null : mExtras.getCharArray(name);
6733 }
6734
6735 /**
6736 * Retrieve extended data from the intent.
6737 *
6738 * @param name The name of the desired item.
6739 *
6740 * @return the value of an item that previously added with putExtra()
6741 * or null if no int array value was found.
6742 *
6743 * @see #putExtra(String, int[])
6744 */
6745 public int[] getIntArrayExtra(String name) {
6746 return mExtras == null ? null : mExtras.getIntArray(name);
6747 }
6748
6749 /**
6750 * Retrieve extended data from the intent.
6751 *
6752 * @param name The name of the desired item.
6753 *
6754 * @return the value of an item that previously added with putExtra()
6755 * or null if no long array value was found.
6756 *
6757 * @see #putExtra(String, long[])
6758 */
6759 public long[] getLongArrayExtra(String name) {
6760 return mExtras == null ? null : mExtras.getLongArray(name);
6761 }
6762
6763 /**
6764 * Retrieve extended data from the intent.
6765 *
6766 * @param name The name of the desired item.
6767 *
6768 * @return the value of an item that previously added with putExtra()
6769 * or null if no float array value was found.
6770 *
6771 * @see #putExtra(String, float[])
6772 */
6773 public float[] getFloatArrayExtra(String name) {
6774 return mExtras == null ? null : mExtras.getFloatArray(name);
6775 }
6776
6777 /**
6778 * Retrieve extended data from the intent.
6779 *
6780 * @param name The name of the desired item.
6781 *
6782 * @return the value of an item that previously added with putExtra()
6783 * or null if no double array value was found.
6784 *
6785 * @see #putExtra(String, double[])
6786 */
6787 public double[] getDoubleArrayExtra(String name) {
6788 return mExtras == null ? null : mExtras.getDoubleArray(name);
6789 }
6790
6791 /**
6792 * Retrieve extended data from the intent.
6793 *
6794 * @param name The name of the desired item.
6795 *
6796 * @return the value of an item that previously added with putExtra()
6797 * or null if no String array value was found.
6798 *
6799 * @see #putExtra(String, String[])
6800 */
6801 public String[] getStringArrayExtra(String name) {
6802 return mExtras == null ? null : mExtras.getStringArray(name);
6803 }
6804
6805 /**
6806 * Retrieve extended data from the intent.
6807 *
6808 * @param name The name of the desired item.
6809 *
6810 * @return the value of an item that previously added with putExtra()
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00006811 * or null if no CharSequence array value was found.
6812 *
6813 * @see #putExtra(String, CharSequence[])
6814 */
6815 public CharSequence[] getCharSequenceArrayExtra(String name) {
6816 return mExtras == null ? null : mExtras.getCharSequenceArray(name);
6817 }
6818
6819 /**
6820 * Retrieve extended data from the intent.
6821 *
6822 * @param name The name of the desired item.
6823 *
6824 * @return the value of an item that previously added with putExtra()
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006825 * or null if no Bundle value was found.
6826 *
6827 * @see #putExtra(String, Bundle)
6828 */
6829 public Bundle getBundleExtra(String name) {
6830 return mExtras == null ? null : mExtras.getBundle(name);
6831 }
6832
6833 /**
6834 * Retrieve extended data from the intent.
6835 *
6836 * @param name The name of the desired item.
6837 *
6838 * @return the value of an item that previously added with putExtra()
6839 * or null if no IBinder value was found.
6840 *
6841 * @see #putExtra(String, IBinder)
6842 *
6843 * @deprecated
6844 * @hide
6845 */
6846 @Deprecated
6847 public IBinder getIBinderExtra(String name) {
6848 return mExtras == null ? null : mExtras.getIBinder(name);
6849 }
6850
6851 /**
6852 * Retrieve extended data from the intent.
6853 *
6854 * @param name The name of the desired item.
6855 * @param defaultValue The default value to return in case no item is
6856 * associated with the key 'name'
6857 *
6858 * @return the value of an item that previously added with putExtra()
6859 * or defaultValue if none was found.
6860 *
6861 * @see #putExtra
6862 *
6863 * @deprecated
6864 * @hide
6865 */
6866 @Deprecated
6867 public Object getExtra(String name, Object defaultValue) {
6868 Object result = defaultValue;
6869 if (mExtras != null) {
6870 Object result2 = mExtras.get(name);
6871 if (result2 != null) {
6872 result = result2;
6873 }
6874 }
6875
6876 return result;
6877 }
6878
6879 /**
6880 * Retrieves a map of extended data from the intent.
6881 *
6882 * @return the map of all extras previously added with putExtra(),
6883 * or null if none have been added.
6884 */
6885 public Bundle getExtras() {
6886 return (mExtras != null)
6887 ? new Bundle(mExtras)
6888 : null;
6889 }
6890
6891 /**
Dianne Hackborna83ce1d2015-03-11 15:16:13 -07006892 * Filter extras to only basic types.
6893 * @hide
6894 */
6895 public void removeUnsafeExtras() {
6896 if (mExtras != null) {
Dianne Hackborn851ec492016-10-12 17:20:07 -07006897 mExtras = mExtras.filterValues();
Dianne Hackborna83ce1d2015-03-11 15:16:13 -07006898 }
6899 }
6900
6901 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006902 * Retrieve any special flags associated with this intent. You will
6903 * normally just set them with {@link #setFlags} and let the system
6904 * take the appropriate action with them.
6905 *
6906 * @return int The currently set flags.
6907 *
6908 * @see #setFlags
6909 */
6910 public int getFlags() {
6911 return mFlags;
6912 }
6913
Dianne Hackborne7f97212011-02-24 14:40:20 -08006914 /** @hide */
6915 public boolean isExcludingStopped() {
6916 return (mFlags&(FLAG_EXCLUDE_STOPPED_PACKAGES|FLAG_INCLUDE_STOPPED_PACKAGES))
6917 == FLAG_EXCLUDE_STOPPED_PACKAGES;
6918 }
6919
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006920 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006921 * Retrieve the application package name this Intent is limited to. When
6922 * resolving an Intent, if non-null this limits the resolution to only
6923 * components in the given application package.
6924 *
6925 * @return The name of the application package for the Intent.
6926 *
6927 * @see #resolveActivity
6928 * @see #setPackage
6929 */
6930 public String getPackage() {
6931 return mPackage;
6932 }
6933
6934 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006935 * Retrieve the concrete component associated with the intent. When receiving
6936 * an intent, this is the component that was found to best handle it (that is,
6937 * yourself) and will always be non-null; in all other cases it will be
6938 * null unless explicitly set.
6939 *
6940 * @return The name of the application component to handle the intent.
6941 *
6942 * @see #resolveActivity
6943 * @see #setComponent
6944 */
6945 public ComponentName getComponent() {
6946 return mComponent;
6947 }
6948
6949 /**
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08006950 * Get the bounds of the sender of this intent, in screen coordinates. This can be
6951 * used as a hint to the receiver for animations and the like. Null means that there
6952 * is no source bounds.
6953 */
6954 public Rect getSourceBounds() {
6955 return mSourceBounds;
6956 }
6957
6958 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006959 * Return the Activity component that should be used to handle this intent.
6960 * The appropriate component is determined based on the information in the
6961 * intent, evaluated as follows:
6962 *
6963 * <p>If {@link #getComponent} returns an explicit class, that is returned
6964 * without any further consideration.
6965 *
6966 * <p>The activity must handle the {@link Intent#CATEGORY_DEFAULT} Intent
6967 * category to be considered.
6968 *
6969 * <p>If {@link #getAction} is non-NULL, the activity must handle this
6970 * action.
6971 *
6972 * <p>If {@link #resolveType} returns non-NULL, the activity must handle
6973 * this type.
6974 *
6975 * <p>If {@link #addCategory} has added any categories, the activity must
6976 * handle ALL of the categories specified.
6977 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006978 * <p>If {@link #getPackage} is non-NULL, only activity components in
6979 * that application package will be considered.
6980 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006981 * <p>If there are no activities that satisfy all of these conditions, a
6982 * null string is returned.
6983 *
6984 * <p>If multiple activities are found to satisfy the intent, the one with
6985 * the highest priority will be used. If there are multiple activities
6986 * with the same priority, the system will either pick the best activity
6987 * based on user preference, or resolve to a system class that will allow
6988 * the user to pick an activity and forward from there.
6989 *
6990 * <p>This method is implemented simply by calling
6991 * {@link PackageManager#resolveActivity} with the "defaultOnly" parameter
6992 * true.</p>
6993 * <p> This API is called for you as part of starting an activity from an
6994 * intent. You do not normally need to call it yourself.</p>
6995 *
6996 * @param pm The package manager with which to resolve the Intent.
6997 *
6998 * @return Name of the component implementing an activity that can
6999 * display the intent.
7000 *
7001 * @see #setComponent
7002 * @see #getComponent
7003 * @see #resolveActivityInfo
7004 */
7005 public ComponentName resolveActivity(PackageManager pm) {
7006 if (mComponent != null) {
7007 return mComponent;
7008 }
7009
7010 ResolveInfo info = pm.resolveActivity(
7011 this, PackageManager.MATCH_DEFAULT_ONLY);
7012 if (info != null) {
7013 return new ComponentName(
7014 info.activityInfo.applicationInfo.packageName,
7015 info.activityInfo.name);
7016 }
7017
7018 return null;
7019 }
7020
7021 /**
7022 * Resolve the Intent into an {@link ActivityInfo}
7023 * describing the activity that should execute the intent. Resolution
7024 * follows the same rules as described for {@link #resolveActivity}, but
7025 * you get back the completely information about the resolved activity
7026 * instead of just its class name.
7027 *
7028 * @param pm The package manager with which to resolve the Intent.
7029 * @param flags Addition information to retrieve as per
7030 * {@link PackageManager#getActivityInfo(ComponentName, int)
7031 * PackageManager.getActivityInfo()}.
7032 *
7033 * @return PackageManager.ActivityInfo
7034 *
7035 * @see #resolveActivity
7036 */
7037 public ActivityInfo resolveActivityInfo(PackageManager pm, int flags) {
7038 ActivityInfo ai = null;
7039 if (mComponent != null) {
7040 try {
7041 ai = pm.getActivityInfo(mComponent, flags);
7042 } catch (PackageManager.NameNotFoundException e) {
7043 // ignore
7044 }
7045 } else {
7046 ResolveInfo info = pm.resolveActivity(
Dianne Hackborn9bfb7072009-09-22 11:37:40 -07007047 this, PackageManager.MATCH_DEFAULT_ONLY | flags);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007048 if (info != null) {
7049 ai = info.activityInfo;
7050 }
7051 }
7052
7053 return ai;
7054 }
7055
7056 /**
Dianne Hackborn221ea892013-08-04 16:50:16 -07007057 * Special function for use by the system to resolve service
7058 * intents to system apps. Throws an exception if there are
7059 * multiple potential matches to the Intent. Returns null if
7060 * there are no matches.
7061 * @hide
7062 */
7063 public ComponentName resolveSystemService(PackageManager pm, int flags) {
7064 if (mComponent != null) {
7065 return mComponent;
7066 }
7067
7068 List<ResolveInfo> results = pm.queryIntentServices(this, flags);
7069 if (results == null) {
7070 return null;
7071 }
7072 ComponentName comp = null;
7073 for (int i=0; i<results.size(); i++) {
7074 ResolveInfo ri = results.get(i);
7075 if ((ri.serviceInfo.applicationInfo.flags&ApplicationInfo.FLAG_SYSTEM) == 0) {
7076 continue;
7077 }
7078 ComponentName foundComp = new ComponentName(ri.serviceInfo.applicationInfo.packageName,
7079 ri.serviceInfo.name);
7080 if (comp != null) {
7081 throw new IllegalStateException("Multiple system services handle " + this
7082 + ": " + comp + ", " + foundComp);
7083 }
7084 comp = foundComp;
7085 }
7086 return comp;
7087 }
7088
7089 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007090 * Set the general action to be performed.
7091 *
7092 * @param action An action name, such as ACTION_VIEW. Application-specific
7093 * actions should be prefixed with the vendor's package name.
7094 *
7095 * @return Returns the same Intent object, for chaining multiple calls
7096 * into a single statement.
7097 *
7098 * @see #getAction
7099 */
7100 public Intent setAction(String action) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08007101 mAction = action != null ? action.intern() : null;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007102 return this;
7103 }
7104
7105 /**
7106 * Set the data this intent is operating on. This method automatically
Nick Pellyccae4122012-01-09 14:12:58 -08007107 * clears any type that was previously set by {@link #setType} or
7108 * {@link #setTypeAndNormalize}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007109 *
Nick Pellyccae4122012-01-09 14:12:58 -08007110 * <p><em>Note: scheme matching in the Android framework is
7111 * case-sensitive, unlike the formal RFC. As a result,
7112 * you should always write your Uri with a lower case scheme,
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04007113 * or use {@link Uri#normalizeScheme} or
Nick Pellyccae4122012-01-09 14:12:58 -08007114 * {@link #setDataAndNormalize}
7115 * to ensure that the scheme is converted to lower case.</em>
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07007116 *
Nick Pellyccae4122012-01-09 14:12:58 -08007117 * @param data The Uri of the data this intent is now targeting.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007118 *
7119 * @return Returns the same Intent object, for chaining multiple calls
7120 * into a single statement.
7121 *
7122 * @see #getData
Nick Pellyccae4122012-01-09 14:12:58 -08007123 * @see #setDataAndNormalize
Dianne Hackborn221ea892013-08-04 16:50:16 -07007124 * @see android.net.Uri#normalizeScheme()
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007125 */
7126 public Intent setData(Uri data) {
7127 mData = data;
7128 mType = null;
7129 return this;
7130 }
7131
7132 /**
Nick Pellyccae4122012-01-09 14:12:58 -08007133 * Normalize and set the data this intent is operating on.
7134 *
7135 * <p>This method automatically clears any type that was
7136 * previously set (for example, by {@link #setType}).
7137 *
7138 * <p>The data Uri is normalized using
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04007139 * {@link android.net.Uri#normalizeScheme} before it is set,
Nick Pellyccae4122012-01-09 14:12:58 -08007140 * so really this is just a convenience method for
7141 * <pre>
7142 * setData(data.normalize())
7143 * </pre>
7144 *
7145 * @param data The Uri of the data this intent is now targeting.
7146 *
7147 * @return Returns the same Intent object, for chaining multiple calls
7148 * into a single statement.
7149 *
7150 * @see #getData
7151 * @see #setType
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04007152 * @see android.net.Uri#normalizeScheme
Nick Pellyccae4122012-01-09 14:12:58 -08007153 */
7154 public Intent setDataAndNormalize(Uri data) {
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04007155 return setData(data.normalizeScheme());
Nick Pellyccae4122012-01-09 14:12:58 -08007156 }
7157
7158 /**
7159 * Set an explicit MIME data type.
7160 *
7161 * <p>This is used to create intents that only specify a type and not data,
7162 * for example to indicate the type of data to return.
7163 *
7164 * <p>This method automatically clears any data that was
7165 * previously set (for example by {@link #setData}).
Romain Guy4969af72009-06-17 10:53:19 -07007166 *
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07007167 * <p><em>Note: MIME type matching in the Android framework is
7168 * case-sensitive, unlike formal RFC MIME types. As a result,
7169 * you should always write your MIME types with lower case letters,
Nick Pellyccae4122012-01-09 14:12:58 -08007170 * or use {@link #normalizeMimeType} or {@link #setTypeAndNormalize}
7171 * to ensure that it is converted to lower case.</em>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007172 *
7173 * @param type The MIME type of the data being handled by this intent.
7174 *
7175 * @return Returns the same Intent object, for chaining multiple calls
7176 * into a single statement.
7177 *
7178 * @see #getType
Nick Pellyccae4122012-01-09 14:12:58 -08007179 * @see #setTypeAndNormalize
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007180 * @see #setDataAndType
Nick Pellyccae4122012-01-09 14:12:58 -08007181 * @see #normalizeMimeType
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007182 */
7183 public Intent setType(String type) {
7184 mData = null;
7185 mType = type;
7186 return this;
7187 }
7188
7189 /**
Nick Pellyccae4122012-01-09 14:12:58 -08007190 * Normalize and set an explicit MIME data type.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007191 *
Nick Pellyccae4122012-01-09 14:12:58 -08007192 * <p>This is used to create intents that only specify a type and not data,
7193 * for example to indicate the type of data to return.
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07007194 *
Nick Pellyccae4122012-01-09 14:12:58 -08007195 * <p>This method automatically clears any data that was
7196 * previously set (for example by {@link #setData}).
7197 *
7198 * <p>The MIME type is normalized using
7199 * {@link #normalizeMimeType} before it is set,
7200 * so really this is just a convenience method for
7201 * <pre>
7202 * setType(Intent.normalizeMimeType(type))
7203 * </pre>
7204 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007205 * @param type The MIME type of the data being handled by this intent.
7206 *
7207 * @return Returns the same Intent object, for chaining multiple calls
7208 * into a single statement.
7209 *
Nick Pellyccae4122012-01-09 14:12:58 -08007210 * @see #getType
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007211 * @see #setData
Nick Pellyccae4122012-01-09 14:12:58 -08007212 * @see #normalizeMimeType
7213 */
7214 public Intent setTypeAndNormalize(String type) {
7215 return setType(normalizeMimeType(type));
7216 }
7217
7218 /**
7219 * (Usually optional) Set the data for the intent along with an explicit
7220 * MIME data type. This method should very rarely be used -- it allows you
7221 * to override the MIME type that would ordinarily be inferred from the
7222 * data with your own type given here.
7223 *
7224 * <p><em>Note: MIME type and Uri scheme matching in the
7225 * Android framework is case-sensitive, unlike the formal RFC definitions.
7226 * As a result, you should always write these elements with lower case letters,
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04007227 * or use {@link #normalizeMimeType} or {@link android.net.Uri#normalizeScheme} or
Nick Pellyccae4122012-01-09 14:12:58 -08007228 * {@link #setDataAndTypeAndNormalize}
7229 * to ensure that they are converted to lower case.</em>
7230 *
7231 * @param data The Uri of the data this intent is now targeting.
7232 * @param type The MIME type of the data being handled by this intent.
7233 *
7234 * @return Returns the same Intent object, for chaining multiple calls
7235 * into a single statement.
7236 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007237 * @see #setType
Nick Pellyccae4122012-01-09 14:12:58 -08007238 * @see #setData
7239 * @see #normalizeMimeType
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04007240 * @see android.net.Uri#normalizeScheme
Nick Pellyccae4122012-01-09 14:12:58 -08007241 * @see #setDataAndTypeAndNormalize
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007242 */
7243 public Intent setDataAndType(Uri data, String type) {
7244 mData = data;
7245 mType = type;
7246 return this;
7247 }
7248
7249 /**
Nick Pellyccae4122012-01-09 14:12:58 -08007250 * (Usually optional) Normalize and set both the data Uri and an explicit
7251 * MIME data type. This method should very rarely be used -- it allows you
7252 * to override the MIME type that would ordinarily be inferred from the
7253 * data with your own type given here.
7254 *
7255 * <p>The data Uri and the MIME type are normalize using
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04007256 * {@link android.net.Uri#normalizeScheme} and {@link #normalizeMimeType}
Nick Pellyccae4122012-01-09 14:12:58 -08007257 * before they are set, so really this is just a convenience method for
7258 * <pre>
7259 * setDataAndType(data.normalize(), Intent.normalizeMimeType(type))
7260 * </pre>
7261 *
7262 * @param data The Uri of the data this intent is now targeting.
7263 * @param type The MIME type of the data being handled by this intent.
7264 *
7265 * @return Returns the same Intent object, for chaining multiple calls
7266 * into a single statement.
7267 *
7268 * @see #setType
7269 * @see #setData
7270 * @see #setDataAndType
7271 * @see #normalizeMimeType
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04007272 * @see android.net.Uri#normalizeScheme
Nick Pellyccae4122012-01-09 14:12:58 -08007273 */
7274 public Intent setDataAndTypeAndNormalize(Uri data, String type) {
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04007275 return setDataAndType(data.normalizeScheme(), normalizeMimeType(type));
Nick Pellyccae4122012-01-09 14:12:58 -08007276 }
7277
7278 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007279 * Add a new category to the intent. Categories provide additional detail
Ken Wakasaf76a50c2012-03-09 19:56:35 +09007280 * about the action the intent performs. When resolving an intent, only
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007281 * activities that provide <em>all</em> of the requested categories will be
7282 * used.
7283 *
7284 * @param category The desired category. This can be either one of the
7285 * predefined Intent categories, or a custom category in your own
7286 * namespace.
7287 *
7288 * @return Returns the same Intent object, for chaining multiple calls
7289 * into a single statement.
7290 *
7291 * @see #hasCategory
7292 * @see #removeCategory
7293 */
7294 public Intent addCategory(String category) {
7295 if (mCategories == null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07007296 mCategories = new ArraySet<String>();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007297 }
Jeff Brown2c376fc2011-01-28 17:34:01 -08007298 mCategories.add(category.intern());
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007299 return this;
7300 }
7301
7302 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09007303 * Remove a category from an intent.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007304 *
7305 * @param category The category to remove.
7306 *
7307 * @see #addCategory
7308 */
7309 public void removeCategory(String category) {
7310 if (mCategories != null) {
7311 mCategories.remove(category);
7312 if (mCategories.size() == 0) {
7313 mCategories = null;
7314 }
7315 }
7316 }
7317
7318 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08007319 * Set a selector for this Intent. This is a modification to the kinds of
7320 * things the Intent will match. If the selector is set, it will be used
7321 * when trying to find entities that can handle the Intent, instead of the
7322 * main contents of the Intent. This allows you build an Intent containing
7323 * a generic protocol while targeting it more specifically.
7324 *
7325 * <p>An example of where this may be used is with things like
7326 * {@link #CATEGORY_APP_BROWSER}. This category allows you to build an
7327 * Intent that will launch the Browser application. However, the correct
7328 * main entry point of an application is actually {@link #ACTION_MAIN}
7329 * {@link #CATEGORY_LAUNCHER} with {@link #setComponent(ComponentName)}
7330 * used to specify the actual Activity to launch. If you launch the browser
7331 * with something different, undesired behavior may happen if the user has
7332 * previously or later launches it the normal way, since they do not match.
7333 * Instead, you can build an Intent with the MAIN action (but no ComponentName
7334 * yet specified) and set a selector with {@link #ACTION_MAIN} and
7335 * {@link #CATEGORY_APP_BROWSER} to point it specifically to the browser activity.
7336 *
7337 * <p>Setting a selector does not impact the behavior of
7338 * {@link #filterEquals(Intent)} and {@link #filterHashCode()}. This is part of the
7339 * desired behavior of a selector -- it does not impact the base meaning
7340 * of the Intent, just what kinds of things will be matched against it
7341 * when determining who can handle it.</p>
7342 *
7343 * <p>You can not use both a selector and {@link #setPackage(String)} on
7344 * the same base Intent.</p>
7345 *
7346 * @param selector The desired selector Intent; set to null to not use
7347 * a special selector.
7348 */
7349 public void setSelector(Intent selector) {
7350 if (selector == this) {
7351 throw new IllegalArgumentException(
7352 "Intent being set as a selector of itself");
7353 }
7354 if (selector != null && mPackage != null) {
7355 throw new IllegalArgumentException(
7356 "Can't set selector when package name is already set");
7357 }
7358 mSelector = selector;
7359 }
7360
7361 /**
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007362 * Set a {@link ClipData} associated with this Intent. This replaces any
7363 * previously set ClipData.
7364 *
7365 * <p>The ClipData in an intent is not used for Intent matching or other
7366 * such operations. Semantically it is like extras, used to transmit
7367 * additional data with the Intent. The main feature of using this over
7368 * the extras for data is that {@link #FLAG_GRANT_READ_URI_PERMISSION}
7369 * and {@link #FLAG_GRANT_WRITE_URI_PERMISSION} will operate on any URI
7370 * items included in the clip data. This is useful, in particular, if
7371 * you want to transmit an Intent containing multiple <code>content:</code>
7372 * URIs for which the recipient may not have global permission to access the
7373 * content provider.
7374 *
7375 * <p>If the ClipData contains items that are themselves Intents, any
7376 * grant flags in those Intents will be ignored. Only the top-level flags
7377 * of the main Intent are respected, and will be applied to all Uri or
7378 * Intent items in the clip (or sub-items of the clip).
7379 *
7380 * <p>The MIME type, label, and icon in the ClipData object are not
7381 * directly used by Intent. Applications should generally rely on the
7382 * MIME type of the Intent itself, not what it may find in the ClipData.
7383 * A common practice is to construct a ClipData for use with an Intent
John Spurlock33900182014-01-02 11:04:18 -05007384 * with a MIME type of "*&#47;*".
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007385 *
7386 * @param clip The new clip to set. May be null to clear the current clip.
7387 */
7388 public void setClipData(ClipData clip) {
7389 mClipData = clip;
7390 }
7391
7392 /**
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01007393 * This is NOT a secure mechanism to identify the user who sent the intent.
7394 * When the intent is sent to a different user, it is used to fix uris by adding the userId
7395 * who sent the intent.
7396 * @hide
7397 */
Nicolas Prevot107f7b72015-07-01 16:31:48 +01007398 public void prepareToLeaveUser(int userId) {
7399 // If mContentUserHint is not UserHandle.USER_CURRENT, the intent has already left a user.
7400 // We want mContentUserHint to refer to the original user, so don't do anything.
7401 if (mContentUserHint == UserHandle.USER_CURRENT) {
7402 mContentUserHint = userId;
7403 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01007404 }
7405
7406 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007407 * Add extended data to the intent. The name must include a package
7408 * prefix, for example the app com.android.contacts would use names
7409 * like "com.android.contacts.ShowAll".
7410 *
7411 * @param name The name of the extra data, with package prefix.
7412 * @param value The boolean data value.
7413 *
7414 * @return Returns the same Intent object, for chaining multiple calls
7415 * into a single statement.
7416 *
7417 * @see #putExtras
7418 * @see #removeExtra
7419 * @see #getBooleanExtra(String, boolean)
7420 */
7421 public Intent putExtra(String name, boolean value) {
7422 if (mExtras == null) {
7423 mExtras = new Bundle();
7424 }
7425 mExtras.putBoolean(name, value);
7426 return this;
7427 }
7428
7429 /**
7430 * Add extended data to the intent. The name must include a package
7431 * prefix, for example the app com.android.contacts would use names
7432 * like "com.android.contacts.ShowAll".
7433 *
7434 * @param name The name of the extra data, with package prefix.
7435 * @param value The byte data value.
7436 *
7437 * @return Returns the same Intent object, for chaining multiple calls
7438 * into a single statement.
7439 *
7440 * @see #putExtras
7441 * @see #removeExtra
7442 * @see #getByteExtra(String, byte)
7443 */
7444 public Intent putExtra(String name, byte value) {
7445 if (mExtras == null) {
7446 mExtras = new Bundle();
7447 }
7448 mExtras.putByte(name, value);
7449 return this;
7450 }
7451
7452 /**
7453 * Add extended data to the intent. The name must include a package
7454 * prefix, for example the app com.android.contacts would use names
7455 * like "com.android.contacts.ShowAll".
7456 *
7457 * @param name The name of the extra data, with package prefix.
7458 * @param value The char data value.
7459 *
7460 * @return Returns the same Intent object, for chaining multiple calls
7461 * into a single statement.
7462 *
7463 * @see #putExtras
7464 * @see #removeExtra
7465 * @see #getCharExtra(String, char)
7466 */
7467 public Intent putExtra(String name, char value) {
7468 if (mExtras == null) {
7469 mExtras = new Bundle();
7470 }
7471 mExtras.putChar(name, value);
7472 return this;
7473 }
7474
7475 /**
7476 * Add extended data to the intent. The name must include a package
7477 * prefix, for example the app com.android.contacts would use names
7478 * like "com.android.contacts.ShowAll".
7479 *
7480 * @param name The name of the extra data, with package prefix.
7481 * @param value The short data value.
7482 *
7483 * @return Returns the same Intent object, for chaining multiple calls
7484 * into a single statement.
7485 *
7486 * @see #putExtras
7487 * @see #removeExtra
7488 * @see #getShortExtra(String, short)
7489 */
7490 public Intent putExtra(String name, short value) {
7491 if (mExtras == null) {
7492 mExtras = new Bundle();
7493 }
7494 mExtras.putShort(name, value);
7495 return this;
7496 }
7497
7498 /**
7499 * Add extended data to the intent. The name must include a package
7500 * prefix, for example the app com.android.contacts would use names
7501 * like "com.android.contacts.ShowAll".
7502 *
7503 * @param name The name of the extra data, with package prefix.
7504 * @param value The integer data value.
7505 *
7506 * @return Returns the same Intent object, for chaining multiple calls
7507 * into a single statement.
7508 *
7509 * @see #putExtras
7510 * @see #removeExtra
7511 * @see #getIntExtra(String, int)
7512 */
7513 public Intent putExtra(String name, int value) {
7514 if (mExtras == null) {
7515 mExtras = new Bundle();
7516 }
7517 mExtras.putInt(name, value);
7518 return this;
7519 }
7520
7521 /**
7522 * Add extended data to the intent. The name must include a package
7523 * prefix, for example the app com.android.contacts would use names
7524 * like "com.android.contacts.ShowAll".
7525 *
7526 * @param name The name of the extra data, with package prefix.
7527 * @param value The long data value.
7528 *
7529 * @return Returns the same Intent object, for chaining multiple calls
7530 * into a single statement.
7531 *
7532 * @see #putExtras
7533 * @see #removeExtra
7534 * @see #getLongExtra(String, long)
7535 */
7536 public Intent putExtra(String name, long value) {
7537 if (mExtras == null) {
7538 mExtras = new Bundle();
7539 }
7540 mExtras.putLong(name, value);
7541 return this;
7542 }
7543
7544 /**
7545 * Add extended data to the intent. The name must include a package
7546 * prefix, for example the app com.android.contacts would use names
7547 * like "com.android.contacts.ShowAll".
7548 *
7549 * @param name The name of the extra data, with package prefix.
7550 * @param value The float data value.
7551 *
7552 * @return Returns the same Intent object, for chaining multiple calls
7553 * into a single statement.
7554 *
7555 * @see #putExtras
7556 * @see #removeExtra
7557 * @see #getFloatExtra(String, float)
7558 */
7559 public Intent putExtra(String name, float value) {
7560 if (mExtras == null) {
7561 mExtras = new Bundle();
7562 }
7563 mExtras.putFloat(name, value);
7564 return this;
7565 }
7566
7567 /**
7568 * Add extended data to the intent. The name must include a package
7569 * prefix, for example the app com.android.contacts would use names
7570 * like "com.android.contacts.ShowAll".
7571 *
7572 * @param name The name of the extra data, with package prefix.
7573 * @param value The double data value.
7574 *
7575 * @return Returns the same Intent object, for chaining multiple calls
7576 * into a single statement.
7577 *
7578 * @see #putExtras
7579 * @see #removeExtra
7580 * @see #getDoubleExtra(String, double)
7581 */
7582 public Intent putExtra(String name, double value) {
7583 if (mExtras == null) {
7584 mExtras = new Bundle();
7585 }
7586 mExtras.putDouble(name, value);
7587 return this;
7588 }
7589
7590 /**
7591 * Add extended data to the intent. The name must include a package
7592 * prefix, for example the app com.android.contacts would use names
7593 * like "com.android.contacts.ShowAll".
7594 *
7595 * @param name The name of the extra data, with package prefix.
7596 * @param value The String data value.
7597 *
7598 * @return Returns the same Intent object, for chaining multiple calls
7599 * into a single statement.
7600 *
7601 * @see #putExtras
7602 * @see #removeExtra
7603 * @see #getStringExtra(String)
7604 */
7605 public Intent putExtra(String name, String value) {
7606 if (mExtras == null) {
7607 mExtras = new Bundle();
7608 }
7609 mExtras.putString(name, value);
7610 return this;
7611 }
7612
7613 /**
7614 * Add extended data to the intent. The name must include a package
7615 * prefix, for example the app com.android.contacts would use names
7616 * like "com.android.contacts.ShowAll".
7617 *
7618 * @param name The name of the extra data, with package prefix.
7619 * @param value The CharSequence data value.
7620 *
7621 * @return Returns the same Intent object, for chaining multiple calls
7622 * into a single statement.
7623 *
7624 * @see #putExtras
7625 * @see #removeExtra
7626 * @see #getCharSequenceExtra(String)
7627 */
7628 public Intent putExtra(String name, CharSequence value) {
7629 if (mExtras == null) {
7630 mExtras = new Bundle();
7631 }
7632 mExtras.putCharSequence(name, value);
7633 return this;
7634 }
7635
7636 /**
7637 * Add extended data to the intent. The name must include a package
7638 * prefix, for example the app com.android.contacts would use names
7639 * like "com.android.contacts.ShowAll".
7640 *
7641 * @param name The name of the extra data, with package prefix.
7642 * @param value The Parcelable data value.
7643 *
7644 * @return Returns the same Intent object, for chaining multiple calls
7645 * into a single statement.
7646 *
7647 * @see #putExtras
7648 * @see #removeExtra
7649 * @see #getParcelableExtra(String)
7650 */
7651 public Intent putExtra(String name, Parcelable value) {
7652 if (mExtras == null) {
7653 mExtras = new Bundle();
7654 }
7655 mExtras.putParcelable(name, value);
7656 return this;
7657 }
7658
7659 /**
7660 * Add extended data to the intent. The name must include a package
7661 * prefix, for example the app com.android.contacts would use names
7662 * like "com.android.contacts.ShowAll".
7663 *
7664 * @param name The name of the extra data, with package prefix.
7665 * @param value The Parcelable[] data value.
7666 *
7667 * @return Returns the same Intent object, for chaining multiple calls
7668 * into a single statement.
7669 *
7670 * @see #putExtras
7671 * @see #removeExtra
7672 * @see #getParcelableArrayExtra(String)
7673 */
7674 public Intent putExtra(String name, Parcelable[] value) {
7675 if (mExtras == null) {
7676 mExtras = new Bundle();
7677 }
7678 mExtras.putParcelableArray(name, value);
7679 return this;
7680 }
7681
7682 /**
7683 * Add extended data to the intent. The name must include a package
7684 * prefix, for example the app com.android.contacts would use names
7685 * like "com.android.contacts.ShowAll".
7686 *
7687 * @param name The name of the extra data, with package prefix.
7688 * @param value The ArrayList<Parcelable> data value.
7689 *
7690 * @return Returns the same Intent object, for chaining multiple calls
7691 * into a single statement.
7692 *
7693 * @see #putExtras
7694 * @see #removeExtra
7695 * @see #getParcelableArrayListExtra(String)
7696 */
7697 public Intent putParcelableArrayListExtra(String name, ArrayList<? extends Parcelable> value) {
7698 if (mExtras == null) {
7699 mExtras = new Bundle();
7700 }
7701 mExtras.putParcelableArrayList(name, value);
7702 return this;
7703 }
7704
7705 /**
7706 * Add extended data to the intent. The name must include a package
7707 * prefix, for example the app com.android.contacts would use names
7708 * like "com.android.contacts.ShowAll".
7709 *
7710 * @param name The name of the extra data, with package prefix.
7711 * @param value The ArrayList<Integer> data value.
7712 *
7713 * @return Returns the same Intent object, for chaining multiple calls
7714 * into a single statement.
7715 *
7716 * @see #putExtras
7717 * @see #removeExtra
7718 * @see #getIntegerArrayListExtra(String)
7719 */
7720 public Intent putIntegerArrayListExtra(String name, ArrayList<Integer> value) {
7721 if (mExtras == null) {
7722 mExtras = new Bundle();
7723 }
7724 mExtras.putIntegerArrayList(name, value);
7725 return this;
7726 }
7727
7728 /**
7729 * Add extended data to the intent. The name must include a package
7730 * prefix, for example the app com.android.contacts would use names
7731 * like "com.android.contacts.ShowAll".
7732 *
7733 * @param name The name of the extra data, with package prefix.
7734 * @param value The ArrayList<String> data value.
7735 *
7736 * @return Returns the same Intent object, for chaining multiple calls
7737 * into a single statement.
7738 *
7739 * @see #putExtras
7740 * @see #removeExtra
7741 * @see #getStringArrayListExtra(String)
7742 */
7743 public Intent putStringArrayListExtra(String name, ArrayList<String> value) {
7744 if (mExtras == null) {
7745 mExtras = new Bundle();
7746 }
7747 mExtras.putStringArrayList(name, value);
7748 return this;
7749 }
7750
7751 /**
7752 * Add extended data to the intent. The name must include a package
7753 * prefix, for example the app com.android.contacts would use names
7754 * like "com.android.contacts.ShowAll".
7755 *
7756 * @param name The name of the extra data, with package prefix.
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00007757 * @param value The ArrayList<CharSequence> data value.
7758 *
7759 * @return Returns the same Intent object, for chaining multiple calls
7760 * into a single statement.
7761 *
7762 * @see #putExtras
7763 * @see #removeExtra
7764 * @see #getCharSequenceArrayListExtra(String)
7765 */
7766 public Intent putCharSequenceArrayListExtra(String name, ArrayList<CharSequence> value) {
7767 if (mExtras == null) {
7768 mExtras = new Bundle();
7769 }
7770 mExtras.putCharSequenceArrayList(name, value);
7771 return this;
7772 }
7773
7774 /**
7775 * Add extended data to the intent. The name must include a package
7776 * prefix, for example the app com.android.contacts would use names
7777 * like "com.android.contacts.ShowAll".
7778 *
7779 * @param name The name of the extra data, with package prefix.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007780 * @param value The Serializable data value.
7781 *
7782 * @return Returns the same Intent object, for chaining multiple calls
7783 * into a single statement.
7784 *
7785 * @see #putExtras
7786 * @see #removeExtra
7787 * @see #getSerializableExtra(String)
7788 */
7789 public Intent putExtra(String name, Serializable value) {
7790 if (mExtras == null) {
7791 mExtras = new Bundle();
7792 }
7793 mExtras.putSerializable(name, value);
7794 return this;
7795 }
7796
7797 /**
7798 * Add extended data to the intent. The name must include a package
7799 * prefix, for example the app com.android.contacts would use names
7800 * like "com.android.contacts.ShowAll".
7801 *
7802 * @param name The name of the extra data, with package prefix.
7803 * @param value The boolean array data value.
7804 *
7805 * @return Returns the same Intent object, for chaining multiple calls
7806 * into a single statement.
7807 *
7808 * @see #putExtras
7809 * @see #removeExtra
7810 * @see #getBooleanArrayExtra(String)
7811 */
7812 public Intent putExtra(String name, boolean[] value) {
7813 if (mExtras == null) {
7814 mExtras = new Bundle();
7815 }
7816 mExtras.putBooleanArray(name, value);
7817 return this;
7818 }
7819
7820 /**
7821 * Add extended data to the intent. The name must include a package
7822 * prefix, for example the app com.android.contacts would use names
7823 * like "com.android.contacts.ShowAll".
7824 *
7825 * @param name The name of the extra data, with package prefix.
7826 * @param value The byte array data value.
7827 *
7828 * @return Returns the same Intent object, for chaining multiple calls
7829 * into a single statement.
7830 *
7831 * @see #putExtras
7832 * @see #removeExtra
7833 * @see #getByteArrayExtra(String)
7834 */
7835 public Intent putExtra(String name, byte[] value) {
7836 if (mExtras == null) {
7837 mExtras = new Bundle();
7838 }
7839 mExtras.putByteArray(name, value);
7840 return this;
7841 }
7842
7843 /**
7844 * Add extended data to the intent. The name must include a package
7845 * prefix, for example the app com.android.contacts would use names
7846 * like "com.android.contacts.ShowAll".
7847 *
7848 * @param name The name of the extra data, with package prefix.
7849 * @param value The short array data value.
7850 *
7851 * @return Returns the same Intent object, for chaining multiple calls
7852 * into a single statement.
7853 *
7854 * @see #putExtras
7855 * @see #removeExtra
7856 * @see #getShortArrayExtra(String)
7857 */
7858 public Intent putExtra(String name, short[] value) {
7859 if (mExtras == null) {
7860 mExtras = new Bundle();
7861 }
7862 mExtras.putShortArray(name, value);
7863 return this;
7864 }
7865
7866 /**
7867 * Add extended data to the intent. The name must include a package
7868 * prefix, for example the app com.android.contacts would use names
7869 * like "com.android.contacts.ShowAll".
7870 *
7871 * @param name The name of the extra data, with package prefix.
7872 * @param value The char array data value.
7873 *
7874 * @return Returns the same Intent object, for chaining multiple calls
7875 * into a single statement.
7876 *
7877 * @see #putExtras
7878 * @see #removeExtra
7879 * @see #getCharArrayExtra(String)
7880 */
7881 public Intent putExtra(String name, char[] value) {
7882 if (mExtras == null) {
7883 mExtras = new Bundle();
7884 }
7885 mExtras.putCharArray(name, value);
7886 return this;
7887 }
7888
7889 /**
7890 * Add extended data to the intent. The name must include a package
7891 * prefix, for example the app com.android.contacts would use names
7892 * like "com.android.contacts.ShowAll".
7893 *
7894 * @param name The name of the extra data, with package prefix.
7895 * @param value The int array data value.
7896 *
7897 * @return Returns the same Intent object, for chaining multiple calls
7898 * into a single statement.
7899 *
7900 * @see #putExtras
7901 * @see #removeExtra
7902 * @see #getIntArrayExtra(String)
7903 */
7904 public Intent putExtra(String name, int[] value) {
7905 if (mExtras == null) {
7906 mExtras = new Bundle();
7907 }
7908 mExtras.putIntArray(name, value);
7909 return this;
7910 }
7911
7912 /**
7913 * Add extended data to the intent. The name must include a package
7914 * prefix, for example the app com.android.contacts would use names
7915 * like "com.android.contacts.ShowAll".
7916 *
7917 * @param name The name of the extra data, with package prefix.
7918 * @param value The byte array data value.
7919 *
7920 * @return Returns the same Intent object, for chaining multiple calls
7921 * into a single statement.
7922 *
7923 * @see #putExtras
7924 * @see #removeExtra
7925 * @see #getLongArrayExtra(String)
7926 */
7927 public Intent putExtra(String name, long[] value) {
7928 if (mExtras == null) {
7929 mExtras = new Bundle();
7930 }
7931 mExtras.putLongArray(name, value);
7932 return this;
7933 }
7934
7935 /**
7936 * Add extended data to the intent. The name must include a package
7937 * prefix, for example the app com.android.contacts would use names
7938 * like "com.android.contacts.ShowAll".
7939 *
7940 * @param name The name of the extra data, with package prefix.
7941 * @param value The float array data value.
7942 *
7943 * @return Returns the same Intent object, for chaining multiple calls
7944 * into a single statement.
7945 *
7946 * @see #putExtras
7947 * @see #removeExtra
7948 * @see #getFloatArrayExtra(String)
7949 */
7950 public Intent putExtra(String name, float[] value) {
7951 if (mExtras == null) {
7952 mExtras = new Bundle();
7953 }
7954 mExtras.putFloatArray(name, value);
7955 return this;
7956 }
7957
7958 /**
7959 * Add extended data to the intent. The name must include a package
7960 * prefix, for example the app com.android.contacts would use names
7961 * like "com.android.contacts.ShowAll".
7962 *
7963 * @param name The name of the extra data, with package prefix.
7964 * @param value The double array data value.
7965 *
7966 * @return Returns the same Intent object, for chaining multiple calls
7967 * into a single statement.
7968 *
7969 * @see #putExtras
7970 * @see #removeExtra
7971 * @see #getDoubleArrayExtra(String)
7972 */
7973 public Intent putExtra(String name, double[] value) {
7974 if (mExtras == null) {
7975 mExtras = new Bundle();
7976 }
7977 mExtras.putDoubleArray(name, value);
7978 return this;
7979 }
7980
7981 /**
7982 * Add extended data to the intent. The name must include a package
7983 * prefix, for example the app com.android.contacts would use names
7984 * like "com.android.contacts.ShowAll".
7985 *
7986 * @param name The name of the extra data, with package prefix.
7987 * @param value The String array data value.
7988 *
7989 * @return Returns the same Intent object, for chaining multiple calls
7990 * into a single statement.
7991 *
7992 * @see #putExtras
7993 * @see #removeExtra
7994 * @see #getStringArrayExtra(String)
7995 */
7996 public Intent putExtra(String name, String[] value) {
7997 if (mExtras == null) {
7998 mExtras = new Bundle();
7999 }
8000 mExtras.putStringArray(name, value);
8001 return this;
8002 }
8003
8004 /**
8005 * Add extended data to the intent. The name must include a package
8006 * prefix, for example the app com.android.contacts would use names
8007 * like "com.android.contacts.ShowAll".
8008 *
8009 * @param name The name of the extra data, with package prefix.
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00008010 * @param value The CharSequence array data value.
8011 *
8012 * @return Returns the same Intent object, for chaining multiple calls
8013 * into a single statement.
8014 *
8015 * @see #putExtras
8016 * @see #removeExtra
8017 * @see #getCharSequenceArrayExtra(String)
8018 */
8019 public Intent putExtra(String name, CharSequence[] value) {
8020 if (mExtras == null) {
8021 mExtras = new Bundle();
8022 }
8023 mExtras.putCharSequenceArray(name, value);
8024 return this;
8025 }
8026
8027 /**
8028 * Add extended data to the intent. The name must include a package
8029 * prefix, for example the app com.android.contacts would use names
8030 * like "com.android.contacts.ShowAll".
8031 *
8032 * @param name The name of the extra data, with package prefix.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008033 * @param value The Bundle data value.
8034 *
8035 * @return Returns the same Intent object, for chaining multiple calls
8036 * into a single statement.
8037 *
8038 * @see #putExtras
8039 * @see #removeExtra
8040 * @see #getBundleExtra(String)
8041 */
8042 public Intent putExtra(String name, Bundle value) {
8043 if (mExtras == null) {
8044 mExtras = new Bundle();
8045 }
8046 mExtras.putBundle(name, value);
8047 return this;
8048 }
8049
8050 /**
8051 * Add extended data to the intent. The name must include a package
8052 * prefix, for example the app com.android.contacts would use names
8053 * like "com.android.contacts.ShowAll".
8054 *
8055 * @param name The name of the extra data, with package prefix.
8056 * @param value The IBinder data value.
8057 *
8058 * @return Returns the same Intent object, for chaining multiple calls
8059 * into a single statement.
8060 *
8061 * @see #putExtras
8062 * @see #removeExtra
8063 * @see #getIBinderExtra(String)
8064 *
8065 * @deprecated
8066 * @hide
8067 */
8068 @Deprecated
8069 public Intent putExtra(String name, IBinder value) {
8070 if (mExtras == null) {
8071 mExtras = new Bundle();
8072 }
8073 mExtras.putIBinder(name, value);
8074 return this;
8075 }
8076
8077 /**
8078 * Copy all extras in 'src' in to this intent.
8079 *
8080 * @param src Contains the extras to copy.
8081 *
8082 * @see #putExtra
8083 */
8084 public Intent putExtras(Intent src) {
8085 if (src.mExtras != null) {
8086 if (mExtras == null) {
8087 mExtras = new Bundle(src.mExtras);
8088 } else {
8089 mExtras.putAll(src.mExtras);
8090 }
8091 }
8092 return this;
8093 }
8094
8095 /**
8096 * Add a set of extended data to the intent. The keys must include a package
8097 * prefix, for example the app com.android.contacts would use names
8098 * like "com.android.contacts.ShowAll".
8099 *
8100 * @param extras The Bundle of extras to add to this intent.
8101 *
8102 * @see #putExtra
8103 * @see #removeExtra
8104 */
8105 public Intent putExtras(Bundle extras) {
8106 if (mExtras == null) {
8107 mExtras = new Bundle();
8108 }
8109 mExtras.putAll(extras);
8110 return this;
8111 }
8112
8113 /**
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08008114 * Completely replace the extras in the Intent with the extras in the
8115 * given Intent.
The Android Open Source Project10592532009-03-18 17:39:46 -07008116 *
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08008117 * @param src The exact extras contained in this Intent are copied
8118 * into the target intent, replacing any that were previously there.
8119 */
8120 public Intent replaceExtras(Intent src) {
8121 mExtras = src.mExtras != null ? new Bundle(src.mExtras) : null;
8122 return this;
8123 }
The Android Open Source Project10592532009-03-18 17:39:46 -07008124
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08008125 /**
8126 * Completely replace the extras in the Intent with the given Bundle of
8127 * extras.
The Android Open Source Project10592532009-03-18 17:39:46 -07008128 *
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08008129 * @param extras The new set of extras in the Intent, or null to erase
8130 * all extras.
8131 */
8132 public Intent replaceExtras(Bundle extras) {
8133 mExtras = extras != null ? new Bundle(extras) : null;
8134 return this;
8135 }
The Android Open Source Project10592532009-03-18 17:39:46 -07008136
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08008137 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008138 * Remove extended data from the intent.
8139 *
8140 * @see #putExtra
8141 */
8142 public void removeExtra(String name) {
8143 if (mExtras != null) {
8144 mExtras.remove(name);
8145 if (mExtras.size() == 0) {
8146 mExtras = null;
8147 }
8148 }
8149 }
8150
8151 /**
8152 * Set special flags controlling how this intent is handled. Most values
8153 * here depend on the type of component being executed by the Intent,
8154 * specifically the FLAG_ACTIVITY_* flags are all for use with
8155 * {@link Context#startActivity Context.startActivity()} and the
8156 * FLAG_RECEIVER_* flags are all for use with
8157 * {@link Context#sendBroadcast(Intent) Context.sendBroadcast()}.
8158 *
Scott Main7aee61f2011-02-08 11:25:01 -08008159 * <p>See the
8160 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
8161 * Stack</a> documentation for important information on how some of these options impact
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008162 * the behavior of your application.
8163 *
8164 * @param flags The desired flags.
8165 *
8166 * @return Returns the same Intent object, for chaining multiple calls
8167 * into a single statement.
8168 *
8169 * @see #getFlags
8170 * @see #addFlags
Jeff Sharkey6a34e562016-12-21 09:56:00 -07008171 * @see #removeFlags
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008172 *
8173 * @see #FLAG_GRANT_READ_URI_PERMISSION
8174 * @see #FLAG_GRANT_WRITE_URI_PERMISSION
Jeff Sharkey846318a2014-04-04 12:12:41 -07008175 * @see #FLAG_GRANT_PERSISTABLE_URI_PERMISSION
8176 * @see #FLAG_GRANT_PREFIX_URI_PERMISSION
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008177 * @see #FLAG_DEBUG_LOG_RESOLUTION
8178 * @see #FLAG_FROM_BACKGROUND
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008179 * @see #FLAG_ACTIVITY_BROUGHT_TO_FRONT
Dianne Hackborn621e17d2010-11-22 15:59:56 -08008180 * @see #FLAG_ACTIVITY_CLEAR_TASK
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008181 * @see #FLAG_ACTIVITY_CLEAR_TOP
Dianne Hackborn621e17d2010-11-22 15:59:56 -08008182 * @see #FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008183 * @see #FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS
8184 * @see #FLAG_ACTIVITY_FORWARD_RESULT
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08008185 * @see #FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008186 * @see #FLAG_ACTIVITY_MULTIPLE_TASK
Craig Mautnerd00f4742014-03-12 14:17:26 -07008187 * @see #FLAG_ACTIVITY_NEW_DOCUMENT
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008188 * @see #FLAG_ACTIVITY_NEW_TASK
Dianne Hackborn621e17d2010-11-22 15:59:56 -08008189 * @see #FLAG_ACTIVITY_NO_ANIMATION
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008190 * @see #FLAG_ACTIVITY_NO_HISTORY
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08008191 * @see #FLAG_ACTIVITY_NO_USER_ACTION
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08008192 * @see #FLAG_ACTIVITY_PREVIOUS_IS_TOP
8193 * @see #FLAG_ACTIVITY_RESET_TASK_IF_NEEDED
Dianne Hackborn621e17d2010-11-22 15:59:56 -08008194 * @see #FLAG_ACTIVITY_REORDER_TO_FRONT
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008195 * @see #FLAG_ACTIVITY_SINGLE_TOP
Dianne Hackborn621e17d2010-11-22 15:59:56 -08008196 * @see #FLAG_ACTIVITY_TASK_ON_HOME
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008197 * @see #FLAG_RECEIVER_REGISTERED_ONLY
8198 */
8199 public Intent setFlags(int flags) {
8200 mFlags = flags;
8201 return this;
8202 }
8203
8204 /**
Jeff Sharkey6a34e562016-12-21 09:56:00 -07008205 * Add additional flags to the intent (or with existing flags value).
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008206 *
8207 * @param flags The new flags to set.
Jeff Sharkey6a34e562016-12-21 09:56:00 -07008208 * @return Returns the same Intent object, for chaining multiple calls into
8209 * a single statement.
8210 * @see #setFlags(int)
8211 * @see #removeFlags(int)
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008212 */
8213 public Intent addFlags(int flags) {
8214 mFlags |= flags;
8215 return this;
8216 }
8217
8218 /**
Jeff Sharkey6a34e562016-12-21 09:56:00 -07008219 * Remove these flags from the intent.
8220 *
8221 * @param flags The flags to remove.
8222 * @see #setFlags(int)
8223 * @see #addFlags(int)
8224 */
8225 public void removeFlags(int flags) {
8226 mFlags &= ~flags;
8227 }
8228
8229 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008230 * (Usually optional) Set an explicit application package name that limits
8231 * the components this Intent will resolve to. If left to the default
8232 * value of null, all components in all applications will considered.
8233 * If non-null, the Intent can only match the components in the given
8234 * application package.
8235 *
8236 * @param packageName The name of the application package to handle the
8237 * intent, or null to allow any application package.
8238 *
8239 * @return Returns the same Intent object, for chaining multiple calls
8240 * into a single statement.
8241 *
8242 * @see #getPackage
8243 * @see #resolveActivity
8244 */
8245 public Intent setPackage(String packageName) {
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008246 if (packageName != null && mSelector != null) {
8247 throw new IllegalArgumentException(
8248 "Can't set package name when selector is already set");
8249 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008250 mPackage = packageName;
8251 return this;
8252 }
8253
8254 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008255 * (Usually optional) Explicitly set the component to handle the intent.
8256 * If left with the default value of null, the system will determine the
8257 * appropriate class to use based on the other fields (action, data,
8258 * type, categories) in the Intent. If this class is defined, the
8259 * specified class will always be used regardless of the other fields. You
8260 * should only set this value when you know you absolutely want a specific
8261 * class to be used; otherwise it is better to let the system find the
8262 * appropriate class so that you will respect the installed applications
8263 * and user preferences.
8264 *
8265 * @param component The name of the application component to handle the
8266 * intent, or null to let the system find one for you.
8267 *
8268 * @return Returns the same Intent object, for chaining multiple calls
8269 * into a single statement.
8270 *
8271 * @see #setClass
8272 * @see #setClassName(Context, String)
8273 * @see #setClassName(String, String)
8274 * @see #getComponent
8275 * @see #resolveActivity
8276 */
8277 public Intent setComponent(ComponentName component) {
8278 mComponent = component;
8279 return this;
8280 }
8281
8282 /**
8283 * Convenience for calling {@link #setComponent} with an
8284 * explicit class name.
8285 *
8286 * @param packageContext A Context of the application package implementing
8287 * this class.
8288 * @param className The name of a class inside of the application package
8289 * that will be used as the component for this Intent.
8290 *
8291 * @return Returns the same Intent object, for chaining multiple calls
8292 * into a single statement.
8293 *
8294 * @see #setComponent
8295 * @see #setClass
8296 */
8297 public Intent setClassName(Context packageContext, String className) {
8298 mComponent = new ComponentName(packageContext, className);
8299 return this;
8300 }
8301
8302 /**
8303 * Convenience for calling {@link #setComponent} with an
8304 * explicit application package name and class name.
8305 *
8306 * @param packageName The name of the package implementing the desired
8307 * component.
8308 * @param className The name of a class inside of the application package
8309 * that will be used as the component for this Intent.
8310 *
8311 * @return Returns the same Intent object, for chaining multiple calls
8312 * into a single statement.
8313 *
8314 * @see #setComponent
8315 * @see #setClass
8316 */
8317 public Intent setClassName(String packageName, String className) {
8318 mComponent = new ComponentName(packageName, className);
8319 return this;
8320 }
8321
8322 /**
8323 * Convenience for calling {@link #setComponent(ComponentName)} with the
8324 * name returned by a {@link Class} object.
8325 *
8326 * @param packageContext A Context of the application package implementing
8327 * this class.
8328 * @param cls The class name to set, equivalent to
8329 * <code>setClassName(context, cls.getName())</code>.
8330 *
8331 * @return Returns the same Intent object, for chaining multiple calls
8332 * into a single statement.
8333 *
8334 * @see #setComponent
8335 */
8336 public Intent setClass(Context packageContext, Class<?> cls) {
8337 mComponent = new ComponentName(packageContext, cls);
8338 return this;
8339 }
8340
8341 /**
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08008342 * Set the bounds of the sender of this intent, in screen coordinates. This can be
8343 * used as a hint to the receiver for animations and the like. Null means that there
8344 * is no source bounds.
8345 */
8346 public void setSourceBounds(Rect r) {
8347 if (r != null) {
8348 mSourceBounds = new Rect(r);
8349 } else {
Daniel Lehmanna5b58df2011-10-12 16:24:22 -07008350 mSourceBounds = null;
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08008351 }
8352 }
8353
Tor Norbyed9273d62013-05-30 15:59:53 -07008354 /** @hide */
8355 @IntDef(flag = true,
8356 value = {
8357 FILL_IN_ACTION,
8358 FILL_IN_DATA,
8359 FILL_IN_CATEGORIES,
8360 FILL_IN_COMPONENT,
8361 FILL_IN_PACKAGE,
8362 FILL_IN_SOURCE_BOUNDS,
8363 FILL_IN_SELECTOR,
8364 FILL_IN_CLIP_DATA
8365 })
8366 @Retention(RetentionPolicy.SOURCE)
8367 public @interface FillInFlags {}
8368
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08008369 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008370 * Use with {@link #fillIn} to allow the current action value to be
8371 * overwritten, even if it is already set.
8372 */
8373 public static final int FILL_IN_ACTION = 1<<0;
8374
8375 /**
8376 * Use with {@link #fillIn} to allow the current data or type value
8377 * overwritten, even if it is already set.
8378 */
8379 public static final int FILL_IN_DATA = 1<<1;
8380
8381 /**
8382 * Use with {@link #fillIn} to allow the current categories to be
8383 * overwritten, even if they are already set.
8384 */
8385 public static final int FILL_IN_CATEGORIES = 1<<2;
8386
8387 /**
8388 * Use with {@link #fillIn} to allow the current component value to be
8389 * overwritten, even if it is already set.
8390 */
8391 public static final int FILL_IN_COMPONENT = 1<<3;
8392
8393 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008394 * Use with {@link #fillIn} to allow the current package value to be
8395 * overwritten, even if it is already set.
8396 */
8397 public static final int FILL_IN_PACKAGE = 1<<4;
8398
8399 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008400 * Use with {@link #fillIn} to allow the current bounds rectangle to be
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08008401 * overwritten, even if it is already set.
8402 */
8403 public static final int FILL_IN_SOURCE_BOUNDS = 1<<5;
8404
8405 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008406 * Use with {@link #fillIn} to allow the current selector to be
8407 * overwritten, even if it is already set.
8408 */
8409 public static final int FILL_IN_SELECTOR = 1<<6;
8410
8411 /**
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008412 * Use with {@link #fillIn} to allow the current ClipData to be
8413 * overwritten, even if it is already set.
8414 */
8415 public static final int FILL_IN_CLIP_DATA = 1<<7;
8416
8417 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008418 * Copy the contents of <var>other</var> in to this object, but only
8419 * where fields are not defined by this object. For purposes of a field
8420 * being defined, the following pieces of data in the Intent are
8421 * considered to be separate fields:
8422 *
8423 * <ul>
8424 * <li> action, as set by {@link #setAction}.
Nick Pellyccae4122012-01-09 14:12:58 -08008425 * <li> data Uri and MIME type, as set by {@link #setData(Uri)},
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008426 * {@link #setType(String)}, or {@link #setDataAndType(Uri, String)}.
8427 * <li> categories, as set by {@link #addCategory}.
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008428 * <li> package, as set by {@link #setPackage}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008429 * <li> component, as set by {@link #setComponent(ComponentName)} or
8430 * related methods.
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008431 * <li> source bounds, as set by {@link #setSourceBounds}.
8432 * <li> selector, as set by {@link #setSelector(Intent)}.
8433 * <li> clip data, as set by {@link #setClipData(ClipData)}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008434 * <li> each top-level name in the associated extras.
8435 * </ul>
8436 *
8437 * <p>In addition, you can use the {@link #FILL_IN_ACTION},
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008438 * {@link #FILL_IN_DATA}, {@link #FILL_IN_CATEGORIES}, {@link #FILL_IN_PACKAGE},
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008439 * {@link #FILL_IN_COMPONENT}, {@link #FILL_IN_SOURCE_BOUNDS},
8440 * {@link #FILL_IN_SELECTOR}, and {@link #FILL_IN_CLIP_DATA} to override
8441 * the restriction where the corresponding field will not be replaced if
8442 * it is already set.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008443 *
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008444 * <p>Note: The component field will only be copied if {@link #FILL_IN_COMPONENT}
8445 * is explicitly specified. The selector will only be copied if
8446 * {@link #FILL_IN_SELECTOR} is explicitly specified.
Brett Chabot3e391752009-07-21 16:07:23 -07008447 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008448 * <p>For example, consider Intent A with {data="foo", categories="bar"}
8449 * and Intent B with {action="gotit", data-type="some/thing",
8450 * categories="one","two"}.
8451 *
8452 * <p>Calling A.fillIn(B, Intent.FILL_IN_DATA) will result in A now
8453 * containing: {action="gotit", data-type="some/thing",
8454 * categories="bar"}.
8455 *
8456 * @param other Another Intent whose values are to be used to fill in
8457 * the current one.
8458 * @param flags Options to control which fields can be filled in.
8459 *
8460 * @return Returns a bit mask of {@link #FILL_IN_ACTION},
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008461 * {@link #FILL_IN_DATA}, {@link #FILL_IN_CATEGORIES}, {@link #FILL_IN_PACKAGE},
Tor Norbyed9273d62013-05-30 15:59:53 -07008462 * {@link #FILL_IN_COMPONENT}, {@link #FILL_IN_SOURCE_BOUNDS},
Elliot Waite54de7742017-01-11 15:30:35 -08008463 * {@link #FILL_IN_SELECTOR} and {@link #FILL_IN_CLIP_DATA} indicating which fields were
Tor Norbyed9273d62013-05-30 15:59:53 -07008464 * changed.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008465 */
Tor Norbyed9273d62013-05-30 15:59:53 -07008466 @FillInFlags
8467 public int fillIn(Intent other, @FillInFlags int flags) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008468 int changes = 0;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008469 boolean mayHaveCopiedUris = false;
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008470 if (other.mAction != null
8471 && (mAction == null || (flags&FILL_IN_ACTION) != 0)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008472 mAction = other.mAction;
8473 changes |= FILL_IN_ACTION;
8474 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008475 if ((other.mData != null || other.mType != null)
8476 && ((mData == null && mType == null)
8477 || (flags&FILL_IN_DATA) != 0)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008478 mData = other.mData;
8479 mType = other.mType;
8480 changes |= FILL_IN_DATA;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008481 mayHaveCopiedUris = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008482 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008483 if (other.mCategories != null
8484 && (mCategories == null || (flags&FILL_IN_CATEGORIES) != 0)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008485 if (other.mCategories != null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07008486 mCategories = new ArraySet<String>(other.mCategories);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008487 }
8488 changes |= FILL_IN_CATEGORIES;
8489 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008490 if (other.mPackage != null
8491 && (mPackage == null || (flags&FILL_IN_PACKAGE) != 0)) {
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008492 // Only do this if mSelector is not set.
8493 if (mSelector == null) {
8494 mPackage = other.mPackage;
8495 changes |= FILL_IN_PACKAGE;
8496 }
8497 }
8498 // Selector is special: it can only be set if explicitly allowed,
8499 // for the same reason as the component name.
8500 if (other.mSelector != null && (flags&FILL_IN_SELECTOR) != 0) {
8501 if (mPackage == null) {
8502 mSelector = new Intent(other.mSelector);
8503 mPackage = null;
8504 changes |= FILL_IN_SELECTOR;
8505 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008506 }
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008507 if (other.mClipData != null
8508 && (mClipData == null || (flags&FILL_IN_CLIP_DATA) != 0)) {
8509 mClipData = other.mClipData;
8510 changes |= FILL_IN_CLIP_DATA;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008511 mayHaveCopiedUris = true;
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008512 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008513 // Component is special: it can -only- be set if explicitly allowed,
8514 // since otherwise the sender could force the intent somewhere the
8515 // originator didn't intend.
8516 if (other.mComponent != null && (flags&FILL_IN_COMPONENT) != 0) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008517 mComponent = other.mComponent;
8518 changes |= FILL_IN_COMPONENT;
8519 }
8520 mFlags |= other.mFlags;
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08008521 if (other.mSourceBounds != null
8522 && (mSourceBounds == null || (flags&FILL_IN_SOURCE_BOUNDS) != 0)) {
8523 mSourceBounds = new Rect(other.mSourceBounds);
8524 changes |= FILL_IN_SOURCE_BOUNDS;
8525 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008526 if (mExtras == null) {
8527 if (other.mExtras != null) {
8528 mExtras = new Bundle(other.mExtras);
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008529 mayHaveCopiedUris = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008530 }
8531 } else if (other.mExtras != null) {
8532 try {
8533 Bundle newb = new Bundle(other.mExtras);
8534 newb.putAll(mExtras);
8535 mExtras = newb;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008536 mayHaveCopiedUris = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008537 } catch (RuntimeException e) {
8538 // Modifying the extras can cause us to unparcel the contents
8539 // of the bundle, and if we do this in the system process that
8540 // may fail. We really should handle this (i.e., the Bundle
8541 // impl shouldn't be on top of a plain map), but for now just
8542 // ignore it and keep the original contents. :(
8543 Log.w("Intent", "Failure filling in extras", e);
8544 }
8545 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008546 if (mayHaveCopiedUris && mContentUserHint == UserHandle.USER_CURRENT
8547 && other.mContentUserHint != UserHandle.USER_CURRENT) {
8548 mContentUserHint = other.mContentUserHint;
8549 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008550 return changes;
8551 }
8552
8553 /**
8554 * Wrapper class holding an Intent and implementing comparisons on it for
8555 * the purpose of filtering. The class implements its
8556 * {@link #equals equals()} and {@link #hashCode hashCode()} methods as
8557 * simple calls to {@link Intent#filterEquals(Intent)} filterEquals()} and
8558 * {@link android.content.Intent#filterHashCode()} filterHashCode()}
8559 * on the wrapped Intent.
8560 */
8561 public static final class FilterComparison {
8562 private final Intent mIntent;
8563 private final int mHashCode;
8564
8565 public FilterComparison(Intent intent) {
8566 mIntent = intent;
8567 mHashCode = intent.filterHashCode();
8568 }
8569
8570 /**
8571 * Return the Intent that this FilterComparison represents.
8572 * @return Returns the Intent held by the FilterComparison. Do
8573 * not modify!
8574 */
8575 public Intent getIntent() {
8576 return mIntent;
8577 }
8578
8579 @Override
8580 public boolean equals(Object obj) {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08008581 if (obj instanceof FilterComparison) {
8582 Intent other = ((FilterComparison)obj).mIntent;
8583 return mIntent.filterEquals(other);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008584 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08008585 return false;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008586 }
8587
8588 @Override
8589 public int hashCode() {
8590 return mHashCode;
8591 }
8592 }
8593
8594 /**
8595 * Determine if two intents are the same for the purposes of intent
8596 * resolution (filtering). That is, if their action, data, type,
8597 * class, and categories are the same. This does <em>not</em> compare
8598 * any extra data included in the intents.
8599 *
8600 * @param other The other Intent to compare against.
8601 *
8602 * @return Returns true if action, data, type, class, and categories
8603 * are the same.
8604 */
8605 public boolean filterEquals(Intent other) {
8606 if (other == null) {
8607 return false;
8608 }
Christopher Tate63d9ae12014-06-19 19:07:26 -07008609 if (!Objects.equals(this.mAction, other.mAction)) return false;
8610 if (!Objects.equals(this.mData, other.mData)) return false;
8611 if (!Objects.equals(this.mType, other.mType)) return false;
8612 if (!Objects.equals(this.mPackage, other.mPackage)) return false;
8613 if (!Objects.equals(this.mComponent, other.mComponent)) return false;
8614 if (!Objects.equals(this.mCategories, other.mCategories)) return false;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008615
8616 return true;
8617 }
8618
8619 /**
8620 * Generate hash code that matches semantics of filterEquals().
8621 *
8622 * @return Returns the hash value of the action, data, type, class, and
8623 * categories.
8624 *
8625 * @see #filterEquals
8626 */
8627 public int filterHashCode() {
8628 int code = 0;
8629 if (mAction != null) {
8630 code += mAction.hashCode();
8631 }
8632 if (mData != null) {
8633 code += mData.hashCode();
8634 }
8635 if (mType != null) {
8636 code += mType.hashCode();
8637 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008638 if (mPackage != null) {
8639 code += mPackage.hashCode();
8640 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008641 if (mComponent != null) {
8642 code += mComponent.hashCode();
8643 }
8644 if (mCategories != null) {
8645 code += mCategories.hashCode();
8646 }
8647 return code;
8648 }
8649
8650 @Override
8651 public String toString() {
Dianne Hackborn90c52de2011-09-23 12:57:44 -07008652 StringBuilder b = new StringBuilder(128);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008653
Dianne Hackborn1d442e02009-04-20 18:14:05 -07008654 b.append("Intent { ");
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008655 toShortString(b, true, true, true, false);
Dianne Hackborn1d442e02009-04-20 18:14:05 -07008656 b.append(" }");
8657
8658 return b.toString();
8659 }
8660
8661 /** @hide */
Dianne Hackborn90c52de2011-09-23 12:57:44 -07008662 public String toInsecureString() {
8663 StringBuilder b = new StringBuilder(128);
8664
8665 b.append("Intent { ");
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008666 toShortString(b, false, true, true, false);
Dianne Hackborn90c52de2011-09-23 12:57:44 -07008667 b.append(" }");
8668
Dianne Hackborn1d442e02009-04-20 18:14:05 -07008669 return b.toString();
8670 }
Romain Guy4969af72009-06-17 10:53:19 -07008671
Dianne Hackborn1d442e02009-04-20 18:14:05 -07008672 /** @hide */
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008673 public String toInsecureStringWithClip() {
Dianne Hackborn90c52de2011-09-23 12:57:44 -07008674 StringBuilder b = new StringBuilder(128);
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008675
8676 b.append("Intent { ");
8677 toShortString(b, false, true, true, true);
8678 b.append(" }");
8679
Dianne Hackborn90c52de2011-09-23 12:57:44 -07008680 return b.toString();
8681 }
8682
8683 /** @hide */
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008684 public String toShortString(boolean secure, boolean comp, boolean extras, boolean clip) {
8685 StringBuilder b = new StringBuilder(128);
8686 toShortString(b, secure, comp, extras, clip);
8687 return b.toString();
8688 }
8689
8690 /** @hide */
8691 public void toShortString(StringBuilder b, boolean secure, boolean comp, boolean extras,
8692 boolean clip) {
Dianne Hackborn1d442e02009-04-20 18:14:05 -07008693 boolean first = true;
8694 if (mAction != null) {
8695 b.append("act=").append(mAction);
8696 first = false;
8697 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008698 if (mCategories != null) {
Dianne Hackborn1d442e02009-04-20 18:14:05 -07008699 if (!first) {
8700 b.append(' ');
8701 }
8702 first = false;
8703 b.append("cat=[");
Dianne Hackbornadd005c2013-07-17 18:43:12 -07008704 for (int i=0; i<mCategories.size(); i++) {
8705 if (i > 0) b.append(',');
8706 b.append(mCategories.valueAt(i));
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008707 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07008708 b.append("]");
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008709 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07008710 if (mData != null) {
8711 if (!first) {
8712 b.append(' ');
8713 }
8714 first = false;
Wink Savillea4288072010-10-12 12:36:38 -07008715 b.append("dat=");
Dianne Hackborn90c52de2011-09-23 12:57:44 -07008716 if (secure) {
8717 b.append(mData.toSafeString());
Wink Savillea4288072010-10-12 12:36:38 -07008718 } else {
8719 b.append(mData);
8720 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07008721 }
8722 if (mType != null) {
8723 if (!first) {
8724 b.append(' ');
8725 }
8726 first = false;
8727 b.append("typ=").append(mType);
8728 }
8729 if (mFlags != 0) {
8730 if (!first) {
8731 b.append(' ');
8732 }
8733 first = false;
8734 b.append("flg=0x").append(Integer.toHexString(mFlags));
8735 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008736 if (mPackage != null) {
8737 if (!first) {
8738 b.append(' ');
8739 }
8740 first = false;
8741 b.append("pkg=").append(mPackage);
8742 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07008743 if (comp && mComponent != null) {
8744 if (!first) {
8745 b.append(' ');
8746 }
8747 first = false;
8748 b.append("cmp=").append(mComponent.flattenToShortString());
8749 }
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08008750 if (mSourceBounds != null) {
8751 if (!first) {
8752 b.append(' ');
8753 }
8754 first = false;
8755 b.append("bnds=").append(mSourceBounds.toShortString());
8756 }
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008757 if (mClipData != null) {
8758 if (!first) {
8759 b.append(' ');
8760 }
Dianne Hackbornae498722015-08-14 13:29:47 -07008761 b.append("clip={");
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008762 if (clip) {
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008763 mClipData.toShortString(b);
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008764 } else {
Dianne Hackbornae498722015-08-14 13:29:47 -07008765 if (mClipData.getDescription() != null) {
8766 first = !mClipData.getDescription().toShortStringTypesOnly(b);
8767 } else {
8768 first = true;
8769 }
8770 mClipData.toShortStringShortItems(b, first);
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008771 }
Dianne Hackbornae498722015-08-14 13:29:47 -07008772 first = false;
8773 b.append('}');
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008774 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07008775 if (extras && mExtras != null) {
8776 if (!first) {
8777 b.append(' ');
8778 }
8779 first = false;
8780 b.append("(has extras)");
8781 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008782 if (mContentUserHint != UserHandle.USER_CURRENT) {
8783 if (!first) {
8784 b.append(' ');
8785 }
8786 first = false;
8787 b.append("u=").append(mContentUserHint);
8788 }
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008789 if (mSelector != null) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008790 b.append(" sel=");
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008791 mSelector.toShortString(b, secure, comp, extras, clip);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008792 b.append("}");
8793 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008794 }
8795
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008796 /**
8797 * Call {@link #toUri} with 0 flags.
8798 * @deprecated Use {@link #toUri} instead.
8799 */
8800 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008801 public String toURI() {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008802 return toUri(0);
8803 }
8804
8805 /**
8806 * Convert this Intent into a String holding a URI representation of it.
8807 * The returned URI string has been properly URI encoded, so it can be
8808 * used with {@link Uri#parse Uri.parse(String)}. The URI contains the
8809 * Intent's data as the base URI, with an additional fragment describing
8810 * the action, categories, type, flags, package, component, and extras.
Tom Taylord4a47292009-12-21 13:59:18 -08008811 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008812 * <p>You can convert the returned string back to an Intent with
8813 * {@link #getIntent}.
Tom Taylord4a47292009-12-21 13:59:18 -08008814 *
Dianne Hackborn85d558c2014-11-04 10:31:54 -08008815 * @param flags Additional operating flags. Either 0,
8816 * {@link #URI_INTENT_SCHEME}, or {@link #URI_ANDROID_APP_SCHEME}.
Tom Taylord4a47292009-12-21 13:59:18 -08008817 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008818 * @return Returns a URI encoding URI string describing the entire contents
8819 * of the Intent.
8820 */
8821 public String toUri(int flags) {
Dianne Hackborn1d442e02009-04-20 18:14:05 -07008822 StringBuilder uri = new StringBuilder(128);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08008823 if ((flags&URI_ANDROID_APP_SCHEME) != 0) {
8824 if (mPackage == null) {
8825 throw new IllegalArgumentException(
8826 "Intent must include an explicit package name to build an android-app: "
8827 + this);
8828 }
8829 uri.append("android-app://");
8830 uri.append(mPackage);
8831 String scheme = null;
8832 if (mData != null) {
8833 scheme = mData.getScheme();
8834 if (scheme != null) {
8835 uri.append('/');
8836 uri.append(scheme);
8837 String authority = mData.getEncodedAuthority();
8838 if (authority != null) {
8839 uri.append('/');
8840 uri.append(authority);
8841 String path = mData.getEncodedPath();
8842 if (path != null) {
8843 uri.append(path);
8844 }
8845 String queryParams = mData.getEncodedQuery();
8846 if (queryParams != null) {
8847 uri.append('?');
8848 uri.append(queryParams);
8849 }
8850 String fragment = mData.getEncodedFragment();
8851 if (fragment != null) {
8852 uri.append('#');
8853 uri.append(fragment);
8854 }
8855 }
8856 }
8857 }
8858 toUriFragment(uri, null, scheme == null ? Intent.ACTION_MAIN : Intent.ACTION_VIEW,
8859 mPackage, flags);
8860 return uri.toString();
8861 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008862 String scheme = null;
8863 if (mData != null) {
8864 String data = mData.toString();
8865 if ((flags&URI_INTENT_SCHEME) != 0) {
8866 final int N = data.length();
8867 for (int i=0; i<N; i++) {
8868 char c = data.charAt(i);
8869 if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')
8870 || c == '.' || c == '-') {
8871 continue;
8872 }
8873 if (c == ':' && i > 0) {
8874 // Valid scheme.
8875 scheme = data.substring(0, i);
8876 uri.append("intent:");
8877 data = data.substring(i+1);
8878 break;
8879 }
Tom Taylord4a47292009-12-21 13:59:18 -08008880
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008881 // No scheme.
8882 break;
8883 }
8884 }
8885 uri.append(data);
Tom Taylord4a47292009-12-21 13:59:18 -08008886
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008887 } else if ((flags&URI_INTENT_SCHEME) != 0) {
8888 uri.append("intent:");
8889 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008890
Dianne Hackborn85d558c2014-11-04 10:31:54 -08008891 toUriFragment(uri, scheme, Intent.ACTION_VIEW, null, flags);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008892
Dianne Hackborn85d558c2014-11-04 10:31:54 -08008893 return uri.toString();
8894 }
8895
8896 private void toUriFragment(StringBuilder uri, String scheme, String defAction,
8897 String defPackage, int flags) {
8898 StringBuilder frag = new StringBuilder(128);
8899
8900 toUriInner(frag, scheme, defAction, defPackage, flags);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008901 if (mSelector != null) {
Dianne Hackborn80b1c562014-12-09 20:22:08 -08008902 frag.append("SEL;");
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008903 // Note that for now we are not going to try to handle the
8904 // data part; not clear how to represent this as a URI, and
8905 // not much utility in it.
Dianne Hackborn85d558c2014-11-04 10:31:54 -08008906 mSelector.toUriInner(frag, mSelector.mData != null ? mSelector.mData.getScheme() : null,
8907 null, null, flags);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008908 }
8909
Dianne Hackborn85d558c2014-11-04 10:31:54 -08008910 if (frag.length() > 0) {
8911 uri.append("#Intent;");
8912 uri.append(frag);
8913 uri.append("end");
8914 }
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008915 }
8916
Dianne Hackborn85d558c2014-11-04 10:31:54 -08008917 private void toUriInner(StringBuilder uri, String scheme, String defAction,
8918 String defPackage, int flags) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008919 if (scheme != null) {
8920 uri.append("scheme=").append(scheme).append(';');
8921 }
Dianne Hackborn85d558c2014-11-04 10:31:54 -08008922 if (mAction != null && !mAction.equals(defAction)) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008923 uri.append("action=").append(Uri.encode(mAction)).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008924 }
8925 if (mCategories != null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07008926 for (int i=0; i<mCategories.size(); i++) {
8927 uri.append("category=").append(Uri.encode(mCategories.valueAt(i))).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008928 }
8929 }
8930 if (mType != null) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008931 uri.append("type=").append(Uri.encode(mType, "/")).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008932 }
8933 if (mFlags != 0) {
8934 uri.append("launchFlags=0x").append(Integer.toHexString(mFlags)).append(';');
8935 }
Dianne Hackborn85d558c2014-11-04 10:31:54 -08008936 if (mPackage != null && !mPackage.equals(defPackage)) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008937 uri.append("package=").append(Uri.encode(mPackage)).append(';');
8938 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008939 if (mComponent != null) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008940 uri.append("component=").append(Uri.encode(
8941 mComponent.flattenToShortString(), "/")).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008942 }
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08008943 if (mSourceBounds != null) {
8944 uri.append("sourceBounds=")
8945 .append(Uri.encode(mSourceBounds.flattenToString()))
8946 .append(';');
8947 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008948 if (mExtras != null) {
8949 for (String key : mExtras.keySet()) {
8950 final Object value = mExtras.get(key);
8951 char entryType =
8952 value instanceof String ? 'S' :
8953 value instanceof Boolean ? 'B' :
8954 value instanceof Byte ? 'b' :
8955 value instanceof Character ? 'c' :
8956 value instanceof Double ? 'd' :
8957 value instanceof Float ? 'f' :
8958 value instanceof Integer ? 'i' :
8959 value instanceof Long ? 'l' :
8960 value instanceof Short ? 's' :
8961 '\0';
8962
8963 if (entryType != '\0') {
8964 uri.append(entryType);
8965 uri.append('.');
8966 uri.append(Uri.encode(key));
8967 uri.append('=');
8968 uri.append(Uri.encode(value.toString()));
8969 uri.append(';');
8970 }
8971 }
8972 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008973 }
The Android Open Source Project10592532009-03-18 17:39:46 -07008974
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008975 public int describeContents() {
8976 return (mExtras != null) ? mExtras.describeContents() : 0;
8977 }
8978
8979 public void writeToParcel(Parcel out, int flags) {
8980 out.writeString(mAction);
8981 Uri.writeToParcel(out, mData);
8982 out.writeString(mType);
8983 out.writeInt(mFlags);
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008984 out.writeString(mPackage);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008985 ComponentName.writeToParcel(mComponent, out);
8986
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08008987 if (mSourceBounds != null) {
8988 out.writeInt(1);
8989 mSourceBounds.writeToParcel(out, flags);
8990 } else {
8991 out.writeInt(0);
8992 }
8993
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008994 if (mCategories != null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07008995 final int N = mCategories.size();
8996 out.writeInt(N);
8997 for (int i=0; i<N; i++) {
8998 out.writeString(mCategories.valueAt(i));
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008999 }
9000 } else {
9001 out.writeInt(0);
9002 }
9003
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009004 if (mSelector != null) {
9005 out.writeInt(1);
9006 mSelector.writeToParcel(out, flags);
9007 } else {
9008 out.writeInt(0);
9009 }
9010
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009011 if (mClipData != null) {
9012 out.writeInt(1);
9013 mClipData.writeToParcel(out, flags);
9014 } else {
9015 out.writeInt(0);
9016 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009017 out.writeInt(mContentUserHint);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009018 out.writeBundle(mExtras);
9019 }
9020
9021 public static final Parcelable.Creator<Intent> CREATOR
9022 = new Parcelable.Creator<Intent>() {
9023 public Intent createFromParcel(Parcel in) {
9024 return new Intent(in);
9025 }
9026 public Intent[] newArray(int size) {
9027 return new Intent[size];
9028 }
9029 };
9030
Dianne Hackborneb034652009-09-07 00:49:58 -07009031 /** @hide */
9032 protected Intent(Parcel in) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009033 readFromParcel(in);
9034 }
9035
9036 public void readFromParcel(Parcel in) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08009037 setAction(in.readString());
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009038 mData = Uri.CREATOR.createFromParcel(in);
9039 mType = in.readString();
9040 mFlags = in.readInt();
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009041 mPackage = in.readString();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009042 mComponent = ComponentName.readFromParcel(in);
9043
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08009044 if (in.readInt() != 0) {
9045 mSourceBounds = Rect.CREATOR.createFromParcel(in);
9046 }
9047
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009048 int N = in.readInt();
9049 if (N > 0) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07009050 mCategories = new ArraySet<String>();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009051 int i;
9052 for (i=0; i<N; i++) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08009053 mCategories.add(in.readString().intern());
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009054 }
9055 } else {
9056 mCategories = null;
9057 }
9058
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009059 if (in.readInt() != 0) {
9060 mSelector = new Intent(in);
9061 }
9062
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009063 if (in.readInt() != 0) {
9064 mClipData = new ClipData(in);
9065 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009066 mContentUserHint = in.readInt();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009067 mExtras = in.readBundle();
9068 }
9069
9070 /**
9071 * Parses the "intent" element (and its children) from XML and instantiates
9072 * an Intent object. The given XML parser should be located at the tag
9073 * where parsing should start (often named "intent"), from which the
9074 * basic action, data, type, and package and class name will be
9075 * retrieved. The function will then parse in to any child elements,
9076 * looking for <category android:name="xxx"> tags to add categories and
9077 * <extra android:name="xxx" android:value="yyy"> to attach extra data
9078 * to the intent.
9079 *
9080 * @param resources The Resources to use when inflating resources.
9081 * @param parser The XML parser pointing at an "intent" tag.
9082 * @param attrs The AttributeSet interface for retrieving extended
9083 * attribute data at the current <var>parser</var> location.
9084 * @return An Intent object matching the XML data.
9085 * @throws XmlPullParserException If there was an XML parsing error.
9086 * @throws IOException If there was an I/O error.
9087 */
9088 public static Intent parseIntent(Resources resources, XmlPullParser parser, AttributeSet attrs)
9089 throws XmlPullParserException, IOException {
9090 Intent intent = new Intent();
9091
9092 TypedArray sa = resources.obtainAttributes(attrs,
9093 com.android.internal.R.styleable.Intent);
9094
9095 intent.setAction(sa.getString(com.android.internal.R.styleable.Intent_action));
9096
9097 String data = sa.getString(com.android.internal.R.styleable.Intent_data);
9098 String mimeType = sa.getString(com.android.internal.R.styleable.Intent_mimeType);
9099 intent.setDataAndType(data != null ? Uri.parse(data) : null, mimeType);
9100
9101 String packageName = sa.getString(com.android.internal.R.styleable.Intent_targetPackage);
9102 String className = sa.getString(com.android.internal.R.styleable.Intent_targetClass);
9103 if (packageName != null && className != null) {
9104 intent.setComponent(new ComponentName(packageName, className));
9105 }
9106
9107 sa.recycle();
9108
9109 int outerDepth = parser.getDepth();
9110 int type;
9111 while ((type=parser.next()) != XmlPullParser.END_DOCUMENT
9112 && (type != XmlPullParser.END_TAG || parser.getDepth() > outerDepth)) {
9113 if (type == XmlPullParser.END_TAG || type == XmlPullParser.TEXT) {
9114 continue;
9115 }
9116
9117 String nodeName = parser.getName();
Craig Mautner21d24a22014-04-23 11:45:37 -07009118 if (nodeName.equals(TAG_CATEGORIES)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009119 sa = resources.obtainAttributes(attrs,
9120 com.android.internal.R.styleable.IntentCategory);
9121 String cat = sa.getString(com.android.internal.R.styleable.IntentCategory_name);
9122 sa.recycle();
9123
9124 if (cat != null) {
9125 intent.addCategory(cat);
9126 }
9127 XmlUtils.skipCurrentTag(parser);
9128
Craig Mautner21d24a22014-04-23 11:45:37 -07009129 } else if (nodeName.equals(TAG_EXTRA)) {
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08009130 if (intent.mExtras == null) {
9131 intent.mExtras = new Bundle();
9132 }
Craig Mautner21d24a22014-04-23 11:45:37 -07009133 resources.parseBundleExtra(TAG_EXTRA, attrs, intent.mExtras);
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08009134 XmlUtils.skipCurrentTag(parser);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009135
9136 } else {
9137 XmlUtils.skipCurrentTag(parser);
9138 }
9139 }
9140
9141 return intent;
9142 }
Nick Pellyccae4122012-01-09 14:12:58 -08009143
Craig Mautner21d24a22014-04-23 11:45:37 -07009144 /** @hide */
9145 public void saveToXml(XmlSerializer out) throws IOException {
9146 if (mAction != null) {
9147 out.attribute(null, ATTR_ACTION, mAction);
9148 }
9149 if (mData != null) {
9150 out.attribute(null, ATTR_DATA, mData.toString());
9151 }
9152 if (mType != null) {
9153 out.attribute(null, ATTR_TYPE, mType);
9154 }
9155 if (mComponent != null) {
9156 out.attribute(null, ATTR_COMPONENT, mComponent.flattenToShortString());
9157 }
9158 out.attribute(null, ATTR_FLAGS, Integer.toHexString(getFlags()));
9159
9160 if (mCategories != null) {
9161 out.startTag(null, TAG_CATEGORIES);
9162 for (int categoryNdx = mCategories.size() - 1; categoryNdx >= 0; --categoryNdx) {
9163 out.attribute(null, ATTR_CATEGORY, mCategories.valueAt(categoryNdx));
9164 }
Craig Mautner43e52ed2014-06-16 17:18:52 -07009165 out.endTag(null, TAG_CATEGORIES);
Craig Mautner21d24a22014-04-23 11:45:37 -07009166 }
9167 }
9168
9169 /** @hide */
9170 public static Intent restoreFromXml(XmlPullParser in) throws IOException,
9171 XmlPullParserException {
9172 Intent intent = new Intent();
9173 final int outerDepth = in.getDepth();
9174
9175 int attrCount = in.getAttributeCount();
9176 for (int attrNdx = attrCount - 1; attrNdx >= 0; --attrNdx) {
9177 final String attrName = in.getAttributeName(attrNdx);
9178 final String attrValue = in.getAttributeValue(attrNdx);
9179 if (ATTR_ACTION.equals(attrName)) {
9180 intent.setAction(attrValue);
9181 } else if (ATTR_DATA.equals(attrName)) {
9182 intent.setData(Uri.parse(attrValue));
9183 } else if (ATTR_TYPE.equals(attrName)) {
9184 intent.setType(attrValue);
9185 } else if (ATTR_COMPONENT.equals(attrName)) {
9186 intent.setComponent(ComponentName.unflattenFromString(attrValue));
9187 } else if (ATTR_FLAGS.equals(attrName)) {
Narayan Kamatha09b4d22016-04-15 18:32:45 +01009188 intent.setFlags(Integer.parseInt(attrValue, 16));
Craig Mautner21d24a22014-04-23 11:45:37 -07009189 } else {
9190 Log.e("Intent", "restoreFromXml: unknown attribute=" + attrName);
9191 }
9192 }
9193
9194 int event;
9195 String name;
9196 while (((event = in.next()) != XmlPullParser.END_DOCUMENT) &&
9197 (event != XmlPullParser.END_TAG || in.getDepth() < outerDepth)) {
9198 if (event == XmlPullParser.START_TAG) {
9199 name = in.getName();
9200 if (TAG_CATEGORIES.equals(name)) {
9201 attrCount = in.getAttributeCount();
9202 for (int attrNdx = attrCount - 1; attrNdx >= 0; --attrNdx) {
9203 intent.addCategory(in.getAttributeValue(attrNdx));
9204 }
9205 } else {
9206 Log.w("Intent", "restoreFromXml: unknown name=" + name);
9207 XmlUtils.skipCurrentTag(in);
9208 }
9209 }
9210 }
9211
9212 return intent;
9213 }
9214
Nick Pellyccae4122012-01-09 14:12:58 -08009215 /**
9216 * Normalize a MIME data type.
9217 *
9218 * <p>A normalized MIME type has white-space trimmed,
9219 * content-type parameters removed, and is lower-case.
9220 * This aligns the type with Android best practices for
9221 * intent filtering.
9222 *
9223 * <p>For example, "text/plain; charset=utf-8" becomes "text/plain".
9224 * "text/x-vCard" becomes "text/x-vcard".
9225 *
9226 * <p>All MIME types received from outside Android (such as user input,
9227 * or external sources like Bluetooth, NFC, or the Internet) should
9228 * be normalized before they are used to create an Intent.
9229 *
9230 * @param type MIME data type to normalize
9231 * @return normalized MIME data type, or null if the input was null
John Spurlock125d1332013-11-25 11:58:37 -05009232 * @see #setType
9233 * @see #setTypeAndNormalize
Nick Pellyccae4122012-01-09 14:12:58 -08009234 */
9235 public static String normalizeMimeType(String type) {
9236 if (type == null) {
9237 return null;
9238 }
9239
Elliott Hughescb64d432013-08-02 10:00:44 -07009240 type = type.trim().toLowerCase(Locale.ROOT);
Nick Pellyccae4122012-01-09 14:12:58 -08009241
9242 final int semicolonIndex = type.indexOf(';');
9243 if (semicolonIndex != -1) {
9244 type = type.substring(0, semicolonIndex);
9245 }
9246 return type;
9247 }
Jeff Sharkey678d04f2012-03-23 15:41:58 -07009248
9249 /**
Jeff Sharkeya14acd22013-04-02 18:27:45 -07009250 * Prepare this {@link Intent} to leave an app process.
9251 *
9252 * @hide
9253 */
Jeff Sharkey344744b2016-01-28 19:03:30 -07009254 public void prepareToLeaveProcess(Context context) {
9255 final boolean leavingPackage = (mComponent == null)
9256 || !Objects.equals(mComponent.getPackageName(), context.getPackageName());
9257 prepareToLeaveProcess(leavingPackage);
9258 }
9259
9260 /**
9261 * Prepare this {@link Intent} to leave an app process.
9262 *
9263 * @hide
9264 */
9265 public void prepareToLeaveProcess(boolean leavingPackage) {
Jeff Sharkeya14acd22013-04-02 18:27:45 -07009266 setAllowFds(false);
9267
9268 if (mSelector != null) {
Jeff Sharkey344744b2016-01-28 19:03:30 -07009269 mSelector.prepareToLeaveProcess(leavingPackage);
Jeff Sharkeya14acd22013-04-02 18:27:45 -07009270 }
9271 if (mClipData != null) {
Jeff Sharkeyfb833f32016-12-01 14:59:59 -07009272 mClipData.prepareToLeaveProcess(leavingPackage, getFlags());
Jeff Sharkeya14acd22013-04-02 18:27:45 -07009273 }
9274
Jeff Sharkeyc6fe23d2017-02-24 09:39:58 -07009275 if (mExtras != null && !mExtras.isParcelled()) {
9276 final Object intent = mExtras.get(Intent.EXTRA_INTENT);
9277 if (intent instanceof Intent) {
9278 ((Intent) intent).prepareToLeaveProcess(leavingPackage);
9279 }
9280 }
9281
Jeff Sharkeya8b42782016-01-30 17:58:09 -07009282 if (mAction != null && mData != null && StrictMode.vmFileUriExposureEnabled()
9283 && leavingPackage) {
Jeff Sharkey344744b2016-01-28 19:03:30 -07009284 switch (mAction) {
9285 case ACTION_MEDIA_REMOVED:
9286 case ACTION_MEDIA_UNMOUNTED:
9287 case ACTION_MEDIA_CHECKING:
9288 case ACTION_MEDIA_NOFS:
9289 case ACTION_MEDIA_MOUNTED:
9290 case ACTION_MEDIA_SHARED:
9291 case ACTION_MEDIA_UNSHARED:
9292 case ACTION_MEDIA_BAD_REMOVAL:
9293 case ACTION_MEDIA_UNMOUNTABLE:
9294 case ACTION_MEDIA_EJECT:
9295 case ACTION_MEDIA_SCANNER_STARTED:
9296 case ACTION_MEDIA_SCANNER_FINISHED:
9297 case ACTION_MEDIA_SCANNER_SCAN_FILE:
Jeff Sharkey37355a92016-02-05 16:19:10 -07009298 case ACTION_PACKAGE_NEEDS_VERIFICATION:
9299 case ACTION_PACKAGE_VERIFIED:
Jeff Sharkey344744b2016-01-28 19:03:30 -07009300 // Ignore legacy actions
9301 break;
9302 default:
9303 mData.checkFileUriExposed("Intent.getData()");
Jeff Sharkeya14acd22013-04-02 18:27:45 -07009304 }
9305 }
Jeff Sharkeyfb833f32016-12-01 14:59:59 -07009306
9307 if (mAction != null && mData != null && StrictMode.vmContentUriWithoutPermissionEnabled()
9308 && leavingPackage) {
9309 switch (mAction) {
9310 case ACTION_PROVIDER_CHANGED:
9311 // Ignore actions that don't need to grant
9312 break;
9313 default:
9314 mData.checkContentUriWithoutPermission("Intent.getData()", getFlags());
9315 }
9316 }
Jeff Sharkeya14acd22013-04-02 18:27:45 -07009317 }
9318
9319 /**
Nicolas Prevotd85fc722014-04-16 19:52:08 +01009320 * @hide
9321 */
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009322 public void prepareToEnterProcess() {
Jeff Sharkeyd136e512016-03-09 22:30:56 -07009323 // We just entered destination process, so we should be able to read all
9324 // parcelables inside.
9325 setDefusable(true);
9326
9327 if (mSelector != null) {
9328 mSelector.prepareToEnterProcess();
9329 }
9330 if (mClipData != null) {
9331 mClipData.prepareToEnterProcess();
9332 }
9333
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009334 if (mContentUserHint != UserHandle.USER_CURRENT) {
Nicolas Prevotc4fc00a2014-10-31 12:01:32 +00009335 if (UserHandle.getAppId(Process.myUid()) != Process.SYSTEM_UID) {
9336 fixUris(mContentUserHint);
9337 mContentUserHint = UserHandle.USER_CURRENT;
9338 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009339 }
9340 }
9341
9342 /**
9343 * @hide
9344 */
9345 public void fixUris(int contentUserHint) {
Nicolas Prevotd85fc722014-04-16 19:52:08 +01009346 Uri data = getData();
9347 if (data != null) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009348 mData = maybeAddUserId(data, contentUserHint);
Nicolas Prevotd85fc722014-04-16 19:52:08 +01009349 }
9350 if (mClipData != null) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009351 mClipData.fixUris(contentUserHint);
Nicolas Prevotd85fc722014-04-16 19:52:08 +01009352 }
9353 String action = getAction();
9354 if (ACTION_SEND.equals(action)) {
9355 final Uri stream = getParcelableExtra(EXTRA_STREAM);
9356 if (stream != null) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009357 putExtra(EXTRA_STREAM, maybeAddUserId(stream, contentUserHint));
Nicolas Prevotd85fc722014-04-16 19:52:08 +01009358 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009359 } else if (ACTION_SEND_MULTIPLE.equals(action)) {
Nicolas Prevotd85fc722014-04-16 19:52:08 +01009360 final ArrayList<Uri> streams = getParcelableArrayListExtra(EXTRA_STREAM);
9361 if (streams != null) {
9362 ArrayList<Uri> newStreams = new ArrayList<Uri>();
9363 for (int i = 0; i < streams.size(); i++) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009364 newStreams.add(maybeAddUserId(streams.get(i), contentUserHint));
Nicolas Prevotd85fc722014-04-16 19:52:08 +01009365 }
9366 putParcelableArrayListExtra(EXTRA_STREAM, newStreams);
9367 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009368 } else if (MediaStore.ACTION_IMAGE_CAPTURE.equals(action)
9369 || MediaStore.ACTION_IMAGE_CAPTURE_SECURE.equals(action)
9370 || MediaStore.ACTION_VIDEO_CAPTURE.equals(action)) {
9371 final Uri output = getParcelableExtra(MediaStore.EXTRA_OUTPUT);
9372 if (output != null) {
9373 putExtra(MediaStore.EXTRA_OUTPUT, maybeAddUserId(output, contentUserHint));
9374 }
Nicolas Prevotd85fc722014-04-16 19:52:08 +01009375 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009376 }
Nicolas Prevotd85fc722014-04-16 19:52:08 +01009377
9378 /**
Jeff Sharkey678d04f2012-03-23 15:41:58 -07009379 * Migrate any {@link #EXTRA_STREAM} in {@link #ACTION_SEND} and
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009380 * {@link #ACTION_SEND_MULTIPLE} to {@link ClipData}. Also inspects nested
9381 * intents in {@link #ACTION_CHOOSER}.
Jeff Sharkey678d04f2012-03-23 15:41:58 -07009382 *
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009383 * @return Whether any contents were migrated.
Jeff Sharkey678d04f2012-03-23 15:41:58 -07009384 * @hide
9385 */
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009386 public boolean migrateExtraStreamToClipData() {
Jeff Sharkey678d04f2012-03-23 15:41:58 -07009387 // Refuse to touch if extras already parcelled
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009388 if (mExtras != null && mExtras.isParcelled()) return false;
Jeff Sharkey678d04f2012-03-23 15:41:58 -07009389
9390 // Bail when someone already gave us ClipData
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009391 if (getClipData() != null) return false;
Jeff Sharkey678d04f2012-03-23 15:41:58 -07009392
9393 final String action = getAction();
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009394 if (ACTION_CHOOSER.equals(action)) {
Jeff Sharkeyc004eef2014-09-23 16:40:50 -07009395 // Inspect contained intents to see if we need to migrate extras. We
9396 // don't promote ClipData to the parent, since ChooserActivity will
9397 // already start the picked item as the caller, and we can't combine
9398 // the flags in a safe way.
9399
9400 boolean migrated = false;
Jeff Sharkey1c297002012-05-18 13:55:47 -07009401 try {
Jeff Sharkeyc004eef2014-09-23 16:40:50 -07009402 final Intent intent = getParcelableExtra(EXTRA_INTENT);
9403 if (intent != null) {
9404 migrated |= intent.migrateExtraStreamToClipData();
Jeff Sharkey1c297002012-05-18 13:55:47 -07009405 }
9406 } catch (ClassCastException e) {
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009407 }
Jeff Sharkeyc004eef2014-09-23 16:40:50 -07009408 try {
9409 final Parcelable[] intents = getParcelableArrayExtra(EXTRA_INITIAL_INTENTS);
9410 if (intents != null) {
9411 for (int i = 0; i < intents.length; i++) {
9412 final Intent intent = (Intent) intents[i];
9413 if (intent != null) {
9414 migrated |= intent.migrateExtraStreamToClipData();
9415 }
9416 }
9417 }
9418 } catch (ClassCastException e) {
9419 }
9420 return migrated;
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009421
9422 } else if (ACTION_SEND.equals(action)) {
Jeff Sharkeyf27ea662012-03-27 10:34:24 -07009423 try {
Jeff Sharkeydd471e62012-05-01 13:07:01 -07009424 final Uri stream = getParcelableExtra(EXTRA_STREAM);
9425 final CharSequence text = getCharSequenceExtra(EXTRA_TEXT);
9426 final String htmlText = getStringExtra(EXTRA_HTML_TEXT);
9427 if (stream != null || text != null || htmlText != null) {
9428 final ClipData clipData = new ClipData(
9429 null, new String[] { getType() },
9430 new ClipData.Item(text, htmlText, null, stream));
9431 setClipData(clipData);
9432 addFlags(FLAG_GRANT_READ_URI_PERMISSION);
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009433 return true;
Jeff Sharkeydd471e62012-05-01 13:07:01 -07009434 }
Jeff Sharkeyf27ea662012-03-27 10:34:24 -07009435 } catch (ClassCastException e) {
Jeff Sharkeyf27ea662012-03-27 10:34:24 -07009436 }
Jeff Sharkey678d04f2012-03-23 15:41:58 -07009437
9438 } else if (ACTION_SEND_MULTIPLE.equals(action)) {
Jeff Sharkeyf27ea662012-03-27 10:34:24 -07009439 try {
Jeff Sharkeydd471e62012-05-01 13:07:01 -07009440 final ArrayList<Uri> streams = getParcelableArrayListExtra(EXTRA_STREAM);
9441 final ArrayList<CharSequence> texts = getCharSequenceArrayListExtra(EXTRA_TEXT);
9442 final ArrayList<String> htmlTexts = getStringArrayListExtra(EXTRA_HTML_TEXT);
9443 int num = -1;
9444 if (streams != null) {
9445 num = streams.size();
9446 }
9447 if (texts != null) {
9448 if (num >= 0 && num != texts.size()) {
9449 // Wha...! F- you.
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009450 return false;
Jeff Sharkeydd471e62012-05-01 13:07:01 -07009451 }
9452 num = texts.size();
9453 }
9454 if (htmlTexts != null) {
9455 if (num >= 0 && num != htmlTexts.size()) {
9456 // Wha...! F- you.
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009457 return false;
Jeff Sharkeydd471e62012-05-01 13:07:01 -07009458 }
9459 num = htmlTexts.size();
9460 }
9461 if (num > 0) {
9462 final ClipData clipData = new ClipData(
9463 null, new String[] { getType() },
9464 makeClipItem(streams, texts, htmlTexts, 0));
9465
9466 for (int i = 1; i < num; i++) {
9467 clipData.addItem(makeClipItem(streams, texts, htmlTexts, i));
9468 }
9469
9470 setClipData(clipData);
9471 addFlags(FLAG_GRANT_READ_URI_PERMISSION);
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009472 return true;
Jeff Sharkeydd471e62012-05-01 13:07:01 -07009473 }
Jeff Sharkeyf27ea662012-03-27 10:34:24 -07009474 } catch (ClassCastException e) {
Jeff Sharkeyf27ea662012-03-27 10:34:24 -07009475 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009476 } else if (MediaStore.ACTION_IMAGE_CAPTURE.equals(action)
9477 || MediaStore.ACTION_IMAGE_CAPTURE_SECURE.equals(action)
9478 || MediaStore.ACTION_VIDEO_CAPTURE.equals(action)) {
9479 final Uri output;
9480 try {
9481 output = getParcelableExtra(MediaStore.EXTRA_OUTPUT);
9482 } catch (ClassCastException e) {
9483 return false;
9484 }
9485 if (output != null) {
9486 setClipData(ClipData.newRawUri("", output));
9487 addFlags(FLAG_GRANT_WRITE_URI_PERMISSION|FLAG_GRANT_READ_URI_PERMISSION);
9488 return true;
9489 }
Jeff Sharkey678d04f2012-03-23 15:41:58 -07009490 }
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009491
9492 return false;
Jeff Sharkey678d04f2012-03-23 15:41:58 -07009493 }
Dianne Hackbornac4243f2012-04-13 17:32:18 -07009494
9495 private static ClipData.Item makeClipItem(ArrayList<Uri> streams, ArrayList<CharSequence> texts,
9496 ArrayList<String> htmlTexts, int which) {
9497 Uri uri = streams != null ? streams.get(which) : null;
9498 CharSequence text = texts != null ? texts.get(which) : null;
9499 String htmlText = htmlTexts != null ? htmlTexts.get(which) : null;
9500 return new ClipData.Item(text, htmlText, null, uri);
9501 }
Craig Mautnerd00f4742014-03-12 14:17:26 -07009502
9503 /** @hide */
9504 public boolean isDocument() {
9505 return (mFlags & FLAG_ACTIVITY_NEW_DOCUMENT) == FLAG_ACTIVITY_NEW_DOCUMENT;
9506 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009507}