blob: c7984b3d7f9d89ad802f1240514fabe4bbb1a245 [file] [log] [blame]
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001/*
2 * Copyright (C) 2006 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package android.content;
18
Tor Norbye7b9c9122013-05-30 16:48:33 -070019import android.annotation.AnyRes;
Tor Norbyed9273d62013-05-30 15:59:53 -070020import android.annotation.IntDef;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070021import android.annotation.SdkConstant;
22import android.annotation.SdkConstant.SdkConstantType;
Jason Monk2f68e8a2016-02-23 17:57:28 -050023import android.annotation.SystemApi;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070024import android.content.pm.ActivityInfo;
Jason Monk2f68e8a2016-02-23 17:57:28 -050025import android.content.pm.ApplicationInfo;
Jeff Sharkeycf3f0a12016-03-17 19:57:58 -060026import android.content.pm.ComponentInfo;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070027import android.content.pm.PackageManager;
28import android.content.pm.ResolveInfo;
29import android.content.res.Resources;
30import android.content.res.TypedArray;
Joe Onoratoc7a63ee2009-12-02 21:13:17 -080031import android.graphics.Rect;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070032import android.net.Uri;
Jeff Sharkeycf3f0a12016-03-17 19:57:58 -060033import android.os.Build;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070034import android.os.Bundle;
35import android.os.IBinder;
36import android.os.Parcel;
37import android.os.Parcelable;
Nicolas Prevotc4fc00a2014-10-31 12:01:32 +000038import android.os.Process;
Jason Monk2f68e8a2016-02-23 17:57:28 -050039import android.os.ResultReceiver;
40import android.os.ShellCommand;
Jeff Sharkeya14acd22013-04-02 18:27:45 -070041import android.os.StrictMode;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +010042import android.os.UserHandle;
Jeff Sharkeybd3b9022013-08-20 15:20:04 -070043import android.provider.DocumentsContract;
Jeff Sharkeyadef88a2013-10-15 13:54:44 -070044import android.provider.DocumentsProvider;
Jason Monk2f68e8a2016-02-23 17:57:28 -050045import android.provider.MediaStore;
Jeff Sharkeyadef88a2013-10-15 13:54:44 -070046import android.provider.OpenableColumns;
Jason Monk2f68e8a2016-02-23 17:57:28 -050047import android.util.ArraySet;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070048import android.util.AttributeSet;
49import android.util.Log;
Dianne Hackborn2269d1572010-02-24 19:54:22 -080050import com.android.internal.util.XmlUtils;
Jason Monk2f68e8a2016-02-23 17:57:28 -050051import org.xmlpull.v1.XmlPullParser;
52import org.xmlpull.v1.XmlPullParserException;
Craig Mautner21d24a22014-04-23 11:45:37 -070053import org.xmlpull.v1.XmlSerializer;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070054
55import java.io.IOException;
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -080056import java.io.PrintWriter;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070057import java.io.Serializable;
Tor Norbyed9273d62013-05-30 15:59:53 -070058import java.lang.annotation.Retention;
59import java.lang.annotation.RetentionPolicy;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070060import java.net.URISyntaxException;
61import java.util.ArrayList;
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -080062import java.util.HashSet;
Dianne Hackborn221ea892013-08-04 16:50:16 -070063import java.util.List;
Nick Pellyccae4122012-01-09 14:12:58 -080064import java.util.Locale;
Christopher Tate63d9ae12014-06-19 19:07:26 -070065import java.util.Objects;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070066import java.util.Set;
67
Jason Monk2f68e8a2016-02-23 17:57:28 -050068import static android.content.ContentProvider.maybeAddUserId;
69
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070070/**
71 * An intent is an abstract description of an operation to be performed. It
72 * can be used with {@link Context#startActivity(Intent) startActivity} to
73 * launch an {@link android.app.Activity},
74 * {@link android.content.Context#sendBroadcast(Intent) broadcastIntent} to
75 * send it to any interested {@link BroadcastReceiver BroadcastReceiver} components,
76 * and {@link android.content.Context#startService} or
77 * {@link android.content.Context#bindService} to communicate with a
78 * background {@link android.app.Service}.
79 *
Joe Fernandezb54e7a32011-10-03 15:09:50 -070080 * <p>An Intent provides a facility for performing late runtime binding between the code in
81 * different applications. Its most significant use is in the launching of activities, where it
Daniel Lehmanna5b58df2011-10-12 16:24:22 -070082 * can be thought of as the glue between activities. It is basically a passive data structure
83 * holding an abstract description of an action to be performed.</p>
Joe Fernandezb54e7a32011-10-03 15:09:50 -070084 *
85 * <div class="special reference">
86 * <h3>Developer Guides</h3>
87 * <p>For information about how to create and resolve intents, read the
88 * <a href="{@docRoot}guide/topics/intents/intents-filters.html">Intents and Intent Filters</a>
89 * developer guide.</p>
90 * </div>
91 *
92 * <a name="IntentStructure"></a>
93 * <h3>Intent Structure</h3>
94 * <p>The primary pieces of information in an intent are:</p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070095 *
96 * <ul>
97 * <li> <p><b>action</b> -- The general action to be performed, such as
98 * {@link #ACTION_VIEW}, {@link #ACTION_EDIT}, {@link #ACTION_MAIN},
99 * etc.</p>
100 * </li>
101 * <li> <p><b>data</b> -- The data to operate on, such as a person record
102 * in the contacts database, expressed as a {@link android.net.Uri}.</p>
103 * </li>
104 * </ul>
105 *
106 *
107 * <p>Some examples of action/data pairs are:</p>
108 *
109 * <ul>
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700110 * <li> <p><b>{@link #ACTION_VIEW} <i>content://contacts/people/1</i></b> -- Display
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700111 * information about the person whose identifier is "1".</p>
112 * </li>
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700113 * <li> <p><b>{@link #ACTION_DIAL} <i>content://contacts/people/1</i></b> -- Display
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700114 * the phone dialer with the person filled in.</p>
115 * </li>
116 * <li> <p><b>{@link #ACTION_VIEW} <i>tel:123</i></b> -- Display
117 * the phone dialer with the given number filled in. Note how the
Trevor Johns682c24e2016-04-12 10:13:47 -0700118 * VIEW action does what is considered the most reasonable thing for
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700119 * a particular URI.</p>
120 * </li>
121 * <li> <p><b>{@link #ACTION_DIAL} <i>tel:123</i></b> -- Display
122 * the phone dialer with the given number filled in.</p>
123 * </li>
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700124 * <li> <p><b>{@link #ACTION_EDIT} <i>content://contacts/people/1</i></b> -- Edit
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700125 * information about the person whose identifier is "1".</p>
126 * </li>
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700127 * <li> <p><b>{@link #ACTION_VIEW} <i>content://contacts/people/</i></b> -- Display
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700128 * a list of people, which the user can browse through. This example is a
129 * typical top-level entry into the Contacts application, showing you the
130 * list of people. Selecting a particular person to view would result in a
Kevin Hufnagleaedfd752016-09-08 21:56:25 -0700131 * new intent { <b>{@link #ACTION_VIEW} <i>content://contacts/people/N</i></b> }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700132 * being used to start an activity to display that person.</p>
133 * </li>
134 * </ul>
135 *
136 * <p>In addition to these primary attributes, there are a number of secondary
137 * attributes that you can also include with an intent:</p>
138 *
139 * <ul>
140 * <li> <p><b>category</b> -- Gives additional information about the action
141 * to execute. For example, {@link #CATEGORY_LAUNCHER} means it should
142 * appear in the Launcher as a top-level application, while
143 * {@link #CATEGORY_ALTERNATIVE} means it should be included in a list
144 * of alternative actions the user can perform on a piece of data.</p>
145 * <li> <p><b>type</b> -- Specifies an explicit type (a MIME type) of the
146 * intent data. Normally the type is inferred from the data itself.
147 * By setting this attribute, you disable that evaluation and force
148 * an explicit type.</p>
149 * <li> <p><b>component</b> -- Specifies an explicit name of a component
150 * class to use for the intent. Normally this is determined by looking
151 * at the other information in the intent (the action, data/type, and
152 * categories) and matching that with a component that can handle it.
153 * If this attribute is set then none of the evaluation is performed,
154 * and this component is used exactly as is. By specifying this attribute,
155 * all of the other Intent attributes become optional.</p>
156 * <li> <p><b>extras</b> -- This is a {@link Bundle} of any additional information.
157 * This can be used to provide extended information to the component.
158 * For example, if we have a action to send an e-mail message, we could
159 * also include extra pieces of data here to supply a subject, body,
160 * etc.</p>
161 * </ul>
162 *
163 * <p>Here are some examples of other operations you can specify as intents
164 * using these additional parameters:</p>
165 *
166 * <ul>
167 * <li> <p><b>{@link #ACTION_MAIN} with category {@link #CATEGORY_HOME}</b> --
168 * Launch the home screen.</p>
169 * </li>
170 * <li> <p><b>{@link #ACTION_GET_CONTENT} with MIME type
171 * <i>{@link android.provider.Contacts.Phones#CONTENT_URI
172 * vnd.android.cursor.item/phone}</i></b>
173 * -- Display the list of people's phone numbers, allowing the user to
174 * browse through them and pick one and return it to the parent activity.</p>
175 * </li>
176 * <li> <p><b>{@link #ACTION_GET_CONTENT} with MIME type
177 * <i>*{@literal /}*</i> and category {@link #CATEGORY_OPENABLE}</b>
178 * -- Display all pickers for data that can be opened with
179 * {@link ContentResolver#openInputStream(Uri) ContentResolver.openInputStream()},
180 * allowing the user to pick one of them and then some data inside of it
181 * and returning the resulting URI to the caller. This can be used,
182 * for example, in an e-mail application to allow the user to pick some
183 * data to include as an attachment.</p>
184 * </li>
185 * </ul>
186 *
187 * <p>There are a variety of standard Intent action and category constants
188 * defined in the Intent class, but applications can also define their own.
Trevor Johns682c24e2016-04-12 10:13:47 -0700189 * These strings use Java-style scoping, to ensure they are unique -- for
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700190 * example, the standard {@link #ACTION_VIEW} is called
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700191 * "android.intent.action.VIEW".</p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700192 *
193 * <p>Put together, the set of actions, data types, categories, and extra data
194 * defines a language for the system allowing for the expression of phrases
195 * such as "call john smith's cell". As applications are added to the system,
196 * they can extend this language by adding new actions, types, and categories, or
197 * they can modify the behavior of existing phrases by supplying their own
198 * activities that handle them.</p>
199 *
200 * <a name="IntentResolution"></a>
201 * <h3>Intent Resolution</h3>
202 *
203 * <p>There are two primary forms of intents you will use.
204 *
205 * <ul>
206 * <li> <p><b>Explicit Intents</b> have specified a component (via
207 * {@link #setComponent} or {@link #setClass}), which provides the exact
208 * class to be run. Often these will not include any other information,
209 * simply being a way for an application to launch various internal
210 * activities it has as the user interacts with the application.
211 *
212 * <li> <p><b>Implicit Intents</b> have not specified a component;
213 * instead, they must include enough information for the system to
214 * determine which of the available components is best to run for that
215 * intent.
216 * </ul>
217 *
218 * <p>When using implicit intents, given such an arbitrary intent we need to
219 * know what to do with it. This is handled by the process of <em>Intent
220 * resolution</em>, which maps an Intent to an {@link android.app.Activity},
221 * {@link BroadcastReceiver}, or {@link android.app.Service} (or sometimes two or
222 * more activities/receivers) that can handle it.</p>
223 *
224 * <p>The intent resolution mechanism basically revolves around matching an
225 * Intent against all of the &lt;intent-filter&gt; descriptions in the
226 * installed application packages. (Plus, in the case of broadcasts, any {@link BroadcastReceiver}
227 * objects explicitly registered with {@link Context#registerReceiver}.) More
228 * details on this can be found in the documentation on the {@link
229 * IntentFilter} class.</p>
230 *
231 * <p>There are three pieces of information in the Intent that are used for
232 * resolution: the action, type, and category. Using this information, a query
233 * is done on the {@link PackageManager} for a component that can handle the
234 * intent. The appropriate component is determined based on the intent
235 * information supplied in the <code>AndroidManifest.xml</code> file as
236 * follows:</p>
237 *
238 * <ul>
239 * <li> <p>The <b>action</b>, if given, must be listed by the component as
240 * one it handles.</p>
241 * <li> <p>The <b>type</b> is retrieved from the Intent's data, if not
242 * already supplied in the Intent. Like the action, if a type is
243 * included in the intent (either explicitly or implicitly in its
244 * data), then this must be listed by the component as one it handles.</p>
245 * <li> For data that is not a <code>content:</code> URI and where no explicit
246 * type is included in the Intent, instead the <b>scheme</b> of the
247 * intent data (such as <code>http:</code> or <code>mailto:</code>) is
248 * considered. Again like the action, if we are matching a scheme it
249 * must be listed by the component as one it can handle.
250 * <li> <p>The <b>categories</b>, if supplied, must <em>all</em> be listed
251 * by the activity as categories it handles. That is, if you include
252 * the categories {@link #CATEGORY_LAUNCHER} and
253 * {@link #CATEGORY_ALTERNATIVE}, then you will only resolve to components
254 * with an intent that lists <em>both</em> of those categories.
255 * Activities will very often need to support the
256 * {@link #CATEGORY_DEFAULT} so that they can be found by
257 * {@link Context#startActivity Context.startActivity()}.</p>
258 * </ul>
259 *
260 * <p>For example, consider the Note Pad sample application that
261 * allows user to browse through a list of notes data and view details about
262 * individual items. Text in italics indicate places were you would replace a
263 * name with one specific to your own package.</p>
264 *
265 * <pre> &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
266 * package="<i>com.android.notepad</i>"&gt;
267 * &lt;application android:icon="@drawable/app_notes"
268 * android:label="@string/app_name"&gt;
269 *
270 * &lt;provider class=".NotePadProvider"
271 * android:authorities="<i>com.google.provider.NotePad</i>" /&gt;
272 *
273 * &lt;activity class=".NotesList" android:label="@string/title_notes_list"&gt;
274 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700275 * &lt;action android:name="android.intent.action.MAIN" /&gt;
276 * &lt;category android:name="android.intent.category.LAUNCHER" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700277 * &lt;/intent-filter&gt;
278 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700279 * &lt;action android:name="android.intent.action.VIEW" /&gt;
280 * &lt;action android:name="android.intent.action.EDIT" /&gt;
281 * &lt;action android:name="android.intent.action.PICK" /&gt;
282 * &lt;category android:name="android.intent.category.DEFAULT" /&gt;
283 * &lt;data android:mimeType="vnd.android.cursor.dir/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700284 * &lt;/intent-filter&gt;
285 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700286 * &lt;action android:name="android.intent.action.GET_CONTENT" /&gt;
287 * &lt;category android:name="android.intent.category.DEFAULT" /&gt;
288 * &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700289 * &lt;/intent-filter&gt;
290 * &lt;/activity&gt;
291 *
292 * &lt;activity class=".NoteEditor" android:label="@string/title_note"&gt;
293 * &lt;intent-filter android:label="@string/resolve_edit"&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700294 * &lt;action android:name="android.intent.action.VIEW" /&gt;
295 * &lt;action android:name="android.intent.action.EDIT" /&gt;
296 * &lt;category android:name="android.intent.category.DEFAULT" /&gt;
297 * &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700298 * &lt;/intent-filter&gt;
299 *
300 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700301 * &lt;action android:name="android.intent.action.INSERT" /&gt;
302 * &lt;category android:name="android.intent.category.DEFAULT" /&gt;
303 * &lt;data android:mimeType="vnd.android.cursor.dir/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700304 * &lt;/intent-filter&gt;
305 *
306 * &lt;/activity&gt;
307 *
308 * &lt;activity class=".TitleEditor" android:label="@string/title_edit_title"
309 * android:theme="@android:style/Theme.Dialog"&gt;
310 * &lt;intent-filter android:label="@string/resolve_title"&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700311 * &lt;action android:name="<i>com.android.notepad.action.EDIT_TITLE</i>" /&gt;
312 * &lt;category android:name="android.intent.category.DEFAULT" /&gt;
313 * &lt;category android:name="android.intent.category.ALTERNATIVE" /&gt;
314 * &lt;category android:name="android.intent.category.SELECTED_ALTERNATIVE" /&gt;
315 * &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700316 * &lt;/intent-filter&gt;
317 * &lt;/activity&gt;
318 *
319 * &lt;/application&gt;
320 * &lt;/manifest&gt;</pre>
321 *
322 * <p>The first activity,
323 * <code>com.android.notepad.NotesList</code>, serves as our main
324 * entry into the app. It can do three things as described by its three intent
325 * templates:
326 * <ol>
327 * <li><pre>
328 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700329 * &lt;action android:name="{@link #ACTION_MAIN android.intent.action.MAIN}" /&gt;
330 * &lt;category android:name="{@link #CATEGORY_LAUNCHER android.intent.category.LAUNCHER}" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700331 * &lt;/intent-filter&gt;</pre>
332 * <p>This provides a top-level entry into the NotePad application: the standard
333 * MAIN action is a main entry point (not requiring any other information in
334 * the Intent), and the LAUNCHER category says that this entry point should be
335 * listed in the application launcher.</p>
336 * <li><pre>
337 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700338 * &lt;action android:name="{@link #ACTION_VIEW android.intent.action.VIEW}" /&gt;
339 * &lt;action android:name="{@link #ACTION_EDIT android.intent.action.EDIT}" /&gt;
340 * &lt;action android:name="{@link #ACTION_PICK android.intent.action.PICK}" /&gt;
341 * &lt;category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /&gt;
Trevor Johns682c24e2016-04-12 10:13:47 -0700342 * &lt;data android:mimeType="vnd.android.cursor.dir/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700343 * &lt;/intent-filter&gt;</pre>
344 * <p>This declares the things that the activity can do on a directory of
345 * notes. The type being supported is given with the &lt;type&gt; tag, where
346 * <code>vnd.android.cursor.dir/vnd.google.note</code> is a URI from which
347 * a Cursor of zero or more items (<code>vnd.android.cursor.dir</code>) can
348 * be retrieved which holds our note pad data (<code>vnd.google.note</code>).
349 * The activity allows the user to view or edit the directory of data (via
350 * the VIEW and EDIT actions), or to pick a particular note and return it
351 * to the caller (via the PICK action). Note also the DEFAULT category
352 * supplied here: this is <em>required</em> for the
353 * {@link Context#startActivity Context.startActivity} method to resolve your
354 * activity when its component name is not explicitly specified.</p>
355 * <li><pre>
356 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700357 * &lt;action android:name="{@link #ACTION_GET_CONTENT android.intent.action.GET_CONTENT}" /&gt;
358 * &lt;category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /&gt;
359 * &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700360 * &lt;/intent-filter&gt;</pre>
Trevor Johns682c24e2016-04-12 10:13:47 -0700361 * <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 -0700362 * the user without needing to know where it came from. The data type
363 * <code>vnd.android.cursor.item/vnd.google.note</code> is a URI from which
364 * a Cursor of exactly one (<code>vnd.android.cursor.item</code>) item can
365 * be retrieved which contains our note pad data (<code>vnd.google.note</code>).
366 * The GET_CONTENT action is similar to the PICK action, where the activity
367 * will return to its caller a piece of data selected by the user. Here,
368 * however, the caller specifies the type of data they desire instead of
369 * the type of data the user will be picking from.</p>
370 * </ol>
371 *
372 * <p>Given these capabilities, the following intents will resolve to the
373 * NotesList activity:</p>
374 *
375 * <ul>
376 * <li> <p><b>{ action=android.app.action.MAIN }</b> matches all of the
377 * activities that can be used as top-level entry points into an
378 * application.</p>
379 * <li> <p><b>{ action=android.app.action.MAIN,
380 * category=android.app.category.LAUNCHER }</b> is the actual intent
381 * used by the Launcher to populate its top-level list.</p>
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700382 * <li> <p><b>{ action=android.intent.action.VIEW
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700383 * data=content://com.google.provider.NotePad/notes }</b>
384 * displays a list of all the notes under
385 * "content://com.google.provider.NotePad/notes", which
386 * the user can browse through and see the details on.</p>
387 * <li> <p><b>{ action=android.app.action.PICK
388 * data=content://com.google.provider.NotePad/notes }</b>
389 * provides a list of the notes under
390 * "content://com.google.provider.NotePad/notes", from which
391 * the user can pick a note whose data URL is returned back to the caller.</p>
392 * <li> <p><b>{ action=android.app.action.GET_CONTENT
393 * type=vnd.android.cursor.item/vnd.google.note }</b>
394 * is similar to the pick action, but allows the caller to specify the
395 * kind of data they want back so that the system can find the appropriate
396 * activity to pick something of that data type.</p>
397 * </ul>
398 *
399 * <p>The second activity,
400 * <code>com.android.notepad.NoteEditor</code>, shows the user a single
401 * note entry and allows them to edit it. It can do two things as described
402 * by its two intent templates:
403 * <ol>
404 * <li><pre>
405 * &lt;intent-filter android:label="@string/resolve_edit"&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700406 * &lt;action android:name="{@link #ACTION_VIEW android.intent.action.VIEW}" /&gt;
407 * &lt;action android:name="{@link #ACTION_EDIT android.intent.action.EDIT}" /&gt;
408 * &lt;category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /&gt;
409 * &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700410 * &lt;/intent-filter&gt;</pre>
411 * <p>The first, primary, purpose of this activity is to let the user interact
412 * with a single note, as decribed by the MIME type
413 * <code>vnd.android.cursor.item/vnd.google.note</code>. The activity can
414 * either VIEW a note or allow the user to EDIT it. Again we support the
415 * DEFAULT category to allow the activity to be launched without explicitly
416 * specifying its component.</p>
417 * <li><pre>
418 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700419 * &lt;action android:name="{@link #ACTION_INSERT android.intent.action.INSERT}" /&gt;
420 * &lt;category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /&gt;
421 * &lt;data android:mimeType="vnd.android.cursor.dir/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700422 * &lt;/intent-filter&gt;</pre>
423 * <p>The secondary use of this activity is to insert a new note entry into
424 * an existing directory of notes. This is used when the user creates a new
425 * note: the INSERT action is executed on the directory of notes, causing
426 * this activity to run and have the user create the new note data which
427 * it then adds to the content provider.</p>
428 * </ol>
429 *
430 * <p>Given these capabilities, the following intents will resolve to the
431 * NoteEditor activity:</p>
432 *
433 * <ul>
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700434 * <li> <p><b>{ action=android.intent.action.VIEW
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700435 * data=content://com.google.provider.NotePad/notes/<var>{ID}</var> }</b>
436 * shows the user the content of note <var>{ID}</var>.</p>
437 * <li> <p><b>{ action=android.app.action.EDIT
438 * data=content://com.google.provider.NotePad/notes/<var>{ID}</var> }</b>
439 * allows the user to edit the content of note <var>{ID}</var>.</p>
440 * <li> <p><b>{ action=android.app.action.INSERT
441 * data=content://com.google.provider.NotePad/notes }</b>
442 * creates a new, empty note in the notes list at
443 * "content://com.google.provider.NotePad/notes"
444 * and allows the user to edit it. If they keep their changes, the URI
445 * of the newly created note is returned to the caller.</p>
446 * </ul>
447 *
448 * <p>The last activity,
449 * <code>com.android.notepad.TitleEditor</code>, allows the user to
450 * edit the title of a note. This could be implemented as a class that the
451 * application directly invokes (by explicitly setting its component in
452 * the Intent), but here we show a way you can publish alternative
453 * operations on existing data:</p>
454 *
455 * <pre>
456 * &lt;intent-filter android:label="@string/resolve_title"&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700457 * &lt;action android:name="<i>com.android.notepad.action.EDIT_TITLE</i>" /&gt;
458 * &lt;category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /&gt;
459 * &lt;category android:name="{@link #CATEGORY_ALTERNATIVE android.intent.category.ALTERNATIVE}" /&gt;
460 * &lt;category android:name="{@link #CATEGORY_SELECTED_ALTERNATIVE android.intent.category.SELECTED_ALTERNATIVE}" /&gt;
461 * &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700462 * &lt;/intent-filter&gt;</pre>
463 *
464 * <p>In the single intent template here, we
465 * have created our own private action called
466 * <code>com.android.notepad.action.EDIT_TITLE</code> which means to
467 * edit the title of a note. It must be invoked on a specific note
468 * (data type <code>vnd.android.cursor.item/vnd.google.note</code>) like the previous
469 * view and edit actions, but here displays and edits the title contained
470 * in the note data.
471 *
472 * <p>In addition to supporting the default category as usual, our title editor
473 * also supports two other standard categories: ALTERNATIVE and
474 * SELECTED_ALTERNATIVE. Implementing
475 * these categories allows others to find the special action it provides
476 * without directly knowing about it, through the
477 * {@link android.content.pm.PackageManager#queryIntentActivityOptions} method, or
478 * more often to build dynamic menu items with
479 * {@link android.view.Menu#addIntentOptions}. Note that in the intent
480 * template here was also supply an explicit name for the template
481 * (via <code>android:label="@string/resolve_title"</code>) to better control
482 * what the user sees when presented with this activity as an alternative
483 * action to the data they are viewing.
484 *
485 * <p>Given these capabilities, the following intent will resolve to the
486 * TitleEditor activity:</p>
487 *
488 * <ul>
489 * <li> <p><b>{ action=com.android.notepad.action.EDIT_TITLE
490 * data=content://com.google.provider.NotePad/notes/<var>{ID}</var> }</b>
491 * displays and allows the user to edit the title associated
492 * with note <var>{ID}</var>.</p>
493 * </ul>
494 *
495 * <h3>Standard Activity Actions</h3>
496 *
497 * <p>These are the current standard actions that Intent defines for launching
498 * activities (usually through {@link Context#startActivity}. The most
499 * important, and by far most frequently used, are {@link #ACTION_MAIN} and
500 * {@link #ACTION_EDIT}.
501 *
502 * <ul>
503 * <li> {@link #ACTION_MAIN}
504 * <li> {@link #ACTION_VIEW}
505 * <li> {@link #ACTION_ATTACH_DATA}
506 * <li> {@link #ACTION_EDIT}
507 * <li> {@link #ACTION_PICK}
508 * <li> {@link #ACTION_CHOOSER}
509 * <li> {@link #ACTION_GET_CONTENT}
510 * <li> {@link #ACTION_DIAL}
511 * <li> {@link #ACTION_CALL}
512 * <li> {@link #ACTION_SEND}
513 * <li> {@link #ACTION_SENDTO}
514 * <li> {@link #ACTION_ANSWER}
515 * <li> {@link #ACTION_INSERT}
516 * <li> {@link #ACTION_DELETE}
517 * <li> {@link #ACTION_RUN}
518 * <li> {@link #ACTION_SYNC}
519 * <li> {@link #ACTION_PICK_ACTIVITY}
520 * <li> {@link #ACTION_SEARCH}
521 * <li> {@link #ACTION_WEB_SEARCH}
522 * <li> {@link #ACTION_FACTORY_TEST}
523 * </ul>
524 *
525 * <h3>Standard Broadcast Actions</h3>
526 *
527 * <p>These are the current standard actions that Intent defines for receiving
528 * broadcasts (usually through {@link Context#registerReceiver} or a
529 * &lt;receiver&gt; tag in a manifest).
530 *
531 * <ul>
532 * <li> {@link #ACTION_TIME_TICK}
533 * <li> {@link #ACTION_TIME_CHANGED}
534 * <li> {@link #ACTION_TIMEZONE_CHANGED}
535 * <li> {@link #ACTION_BOOT_COMPLETED}
536 * <li> {@link #ACTION_PACKAGE_ADDED}
537 * <li> {@link #ACTION_PACKAGE_CHANGED}
538 * <li> {@link #ACTION_PACKAGE_REMOVED}
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800539 * <li> {@link #ACTION_PACKAGE_RESTARTED}
540 * <li> {@link #ACTION_PACKAGE_DATA_CLEARED}
Andrei Stingaceanu69d5ebc2016-01-14 12:59:03 +0000541 * <li> {@link #ACTION_PACKAGES_SUSPENDED}
542 * <li> {@link #ACTION_PACKAGES_UNSUSPENDED}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700543 * <li> {@link #ACTION_UID_REMOVED}
544 * <li> {@link #ACTION_BATTERY_CHANGED}
Cliff Spradlinfda6fae2008-10-22 20:29:16 -0700545 * <li> {@link #ACTION_POWER_CONNECTED}
Romain Guy4969af72009-06-17 10:53:19 -0700546 * <li> {@link #ACTION_POWER_DISCONNECTED}
547 * <li> {@link #ACTION_SHUTDOWN}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700548 * </ul>
549 *
550 * <h3>Standard Categories</h3>
551 *
552 * <p>These are the current standard categories that can be used to further
553 * clarify an Intent via {@link #addCategory}.
554 *
555 * <ul>
556 * <li> {@link #CATEGORY_DEFAULT}
557 * <li> {@link #CATEGORY_BROWSABLE}
558 * <li> {@link #CATEGORY_TAB}
559 * <li> {@link #CATEGORY_ALTERNATIVE}
560 * <li> {@link #CATEGORY_SELECTED_ALTERNATIVE}
561 * <li> {@link #CATEGORY_LAUNCHER}
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800562 * <li> {@link #CATEGORY_INFO}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700563 * <li> {@link #CATEGORY_HOME}
564 * <li> {@link #CATEGORY_PREFERENCE}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700565 * <li> {@link #CATEGORY_TEST}
Mike Lockwood9092ab42009-09-16 13:01:32 -0400566 * <li> {@link #CATEGORY_CAR_DOCK}
567 * <li> {@link #CATEGORY_DESK_DOCK}
Praveen Bharathi21e941b2010-10-06 15:23:14 -0500568 * <li> {@link #CATEGORY_LE_DESK_DOCK}
569 * <li> {@link #CATEGORY_HE_DESK_DOCK}
Bernd Holzheyaea4b672010-03-31 09:46:13 +0200570 * <li> {@link #CATEGORY_CAR_MODE}
Patrick Dubroy6dabe242010-08-30 10:43:47 -0700571 * <li> {@link #CATEGORY_APP_MARKET}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700572 * </ul>
573 *
574 * <h3>Standard Extra Data</h3>
575 *
576 * <p>These are the current standard fields that can be used as extra data via
577 * {@link #putExtra}.
578 *
579 * <ul>
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800580 * <li> {@link #EXTRA_ALARM_COUNT}
581 * <li> {@link #EXTRA_BCC}
582 * <li> {@link #EXTRA_CC}
583 * <li> {@link #EXTRA_CHANGED_COMPONENT_NAME}
584 * <li> {@link #EXTRA_DATA_REMOVED}
585 * <li> {@link #EXTRA_DOCK_STATE}
Praveen Bharathi21e941b2010-10-06 15:23:14 -0500586 * <li> {@link #EXTRA_DOCK_STATE_HE_DESK}
587 * <li> {@link #EXTRA_DOCK_STATE_LE_DESK}
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800588 * <li> {@link #EXTRA_DOCK_STATE_CAR}
589 * <li> {@link #EXTRA_DOCK_STATE_DESK}
590 * <li> {@link #EXTRA_DOCK_STATE_UNDOCKED}
591 * <li> {@link #EXTRA_DONT_KILL_APP}
592 * <li> {@link #EXTRA_EMAIL}
593 * <li> {@link #EXTRA_INITIAL_INTENTS}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700594 * <li> {@link #EXTRA_INTENT}
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800595 * <li> {@link #EXTRA_KEY_EVENT}
rich cannings706e8ba2012-08-20 13:20:14 -0700596 * <li> {@link #EXTRA_ORIGINATING_URI}
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800597 * <li> {@link #EXTRA_PHONE_NUMBER}
rich cannings368ed012012-06-07 15:37:57 -0700598 * <li> {@link #EXTRA_REFERRER}
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800599 * <li> {@link #EXTRA_REMOTE_INTENT_TOKEN}
600 * <li> {@link #EXTRA_REPLACING}
601 * <li> {@link #EXTRA_SHORTCUT_ICON}
602 * <li> {@link #EXTRA_SHORTCUT_ICON_RESOURCE}
603 * <li> {@link #EXTRA_SHORTCUT_INTENT}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700604 * <li> {@link #EXTRA_STREAM}
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800605 * <li> {@link #EXTRA_SHORTCUT_NAME}
606 * <li> {@link #EXTRA_SUBJECT}
607 * <li> {@link #EXTRA_TEMPLATE}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700608 * <li> {@link #EXTRA_TEXT}
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800609 * <li> {@link #EXTRA_TITLE}
610 * <li> {@link #EXTRA_UID}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700611 * </ul>
612 *
613 * <h3>Flags</h3>
614 *
615 * <p>These are the possible flags that can be used in the Intent via
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800616 * {@link #setFlags} and {@link #addFlags}. See {@link #setFlags} for a list
617 * of all possible flags.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700618 */
Dianne Hackbornee0511d2009-12-21 18:08:13 -0800619public class Intent implements Parcelable, Cloneable {
Craig Mautner21d24a22014-04-23 11:45:37 -0700620 private static final String ATTR_ACTION = "action";
621 private static final String TAG_CATEGORIES = "categories";
622 private static final String ATTR_CATEGORY = "category";
623 private static final String TAG_EXTRA = "extra";
624 private static final String ATTR_TYPE = "type";
625 private static final String ATTR_COMPONENT = "component";
626 private static final String ATTR_DATA = "data";
627 private static final String ATTR_FLAGS = "flags";
628
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700629 // ---------------------------------------------------------------------
630 // ---------------------------------------------------------------------
631 // Standard intent activity actions (see action variable).
632
633 /**
634 * Activity Action: Start as a main entry point, does not expect to
635 * receive data.
636 * <p>Input: nothing
637 * <p>Output: nothing
638 */
639 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
640 public static final String ACTION_MAIN = "android.intent.action.MAIN";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800641
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700642 /**
643 * Activity Action: Display the data to the user. This is the most common
644 * action performed on data -- it is the generic action you can use on
645 * a piece of data to get the most reasonable thing to occur. For example,
646 * when used on a contacts entry it will view the entry; when used on a
647 * mailto: URI it will bring up a compose window filled with the information
648 * supplied by the URI; when used with a tel: URI it will invoke the
649 * dialer.
650 * <p>Input: {@link #getData} is URI from which to retrieve data.
651 * <p>Output: nothing.
652 */
653 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
654 public static final String ACTION_VIEW = "android.intent.action.VIEW";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800655
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700656 /**
657 * A synonym for {@link #ACTION_VIEW}, the "standard" action that is
658 * performed on a piece of data.
659 */
660 public static final String ACTION_DEFAULT = ACTION_VIEW;
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800661
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700662 /**
Tomasz Mikolajewski319fb492016-01-20 12:24:01 +0900663 * Activity Action: Quick view the data. Launches a quick viewer for
664 * a URI or a list of URIs.
Tomasz Mikolajewskife023132016-03-10 17:42:35 +0900665 * <p>Activities handling this intent action should handle the vast majority of
666 * MIME types rather than only specific ones.
Tomasz Mikolajewski319fb492016-01-20 12:24:01 +0900667 * <p>Input: {@link #getData} is a mandatory content URI of the item to
668 * preview. {@link #getClipData} contains an optional list of content URIs
669 * if there is more than one item to preview. {@link #EXTRA_INDEX} is an
670 * optional index of the URI in the clip data to show first.
Steve McKayc78bcb82015-07-31 14:35:22 -0700671 * <p>Output: nothing.
Steve McKayc78bcb82015-07-31 14:35:22 -0700672 */
673 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
674 public static final String ACTION_QUICK_VIEW = "android.intent.action.QUICK_VIEW";
675
676 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700677 * Used to indicate that some piece of data should be attached to some other
678 * place. For example, image data could be attached to a contact. It is up
679 * to the recipient to decide where the data should be attached; the intent
680 * does not specify the ultimate destination.
681 * <p>Input: {@link #getData} is URI of data to be attached.
682 * <p>Output: nothing.
683 */
684 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
685 public static final String ACTION_ATTACH_DATA = "android.intent.action.ATTACH_DATA";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800686
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700687 /**
688 * Activity Action: Provide explicit editable access to the given data.
689 * <p>Input: {@link #getData} is URI of data to be edited.
690 * <p>Output: nothing.
691 */
692 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
693 public static final String ACTION_EDIT = "android.intent.action.EDIT";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800694
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700695 /**
696 * Activity Action: Pick an existing item, or insert a new item, and then edit it.
697 * <p>Input: {@link #getType} is the desired MIME type of the item to create or edit.
698 * The extras can contain type specific data to pass through to the editing/creating
699 * activity.
700 * <p>Output: The URI of the item that was picked. This must be a content:
701 * URI so that any receiver can access it.
702 */
703 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
704 public static final String ACTION_INSERT_OR_EDIT = "android.intent.action.INSERT_OR_EDIT";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800705
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700706 /**
707 * Activity Action: Pick an item from the data, returning what was selected.
708 * <p>Input: {@link #getData} is URI containing a directory of data
709 * (vnd.android.cursor.dir/*) from which to pick an item.
710 * <p>Output: The URI of the item that was picked.
711 */
712 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
713 public static final String ACTION_PICK = "android.intent.action.PICK";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800714
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700715 /**
716 * Activity Action: Creates a shortcut.
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800717 * <p>Input: Nothing.</p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700718 * <p>Output: An Intent representing the shortcut. The intent must contain three
719 * extras: SHORTCUT_INTENT (value: Intent), SHORTCUT_NAME (value: String),
720 * and SHORTCUT_ICON (value: Bitmap) or SHORTCUT_ICON_RESOURCE
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800721 * (value: ShortcutIconResource).</p>
722 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700723 * @see #EXTRA_SHORTCUT_INTENT
724 * @see #EXTRA_SHORTCUT_NAME
725 * @see #EXTRA_SHORTCUT_ICON
726 * @see #EXTRA_SHORTCUT_ICON_RESOURCE
727 * @see android.content.Intent.ShortcutIconResource
728 */
729 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
730 public static final String ACTION_CREATE_SHORTCUT = "android.intent.action.CREATE_SHORTCUT";
731
732 /**
733 * The name of the extra used to define the Intent of a shortcut.
734 *
735 * @see #ACTION_CREATE_SHORTCUT
736 */
737 public static final String EXTRA_SHORTCUT_INTENT = "android.intent.extra.shortcut.INTENT";
738 /**
739 * The name of the extra used to define the name of a shortcut.
740 *
741 * @see #ACTION_CREATE_SHORTCUT
742 */
743 public static final String EXTRA_SHORTCUT_NAME = "android.intent.extra.shortcut.NAME";
744 /**
745 * The name of the extra used to define the icon, as a Bitmap, of a shortcut.
746 *
747 * @see #ACTION_CREATE_SHORTCUT
748 */
749 public static final String EXTRA_SHORTCUT_ICON = "android.intent.extra.shortcut.ICON";
750 /**
751 * The name of the extra used to define the icon, as a ShortcutIconResource, of a shortcut.
752 *
753 * @see #ACTION_CREATE_SHORTCUT
754 * @see android.content.Intent.ShortcutIconResource
755 */
756 public static final String EXTRA_SHORTCUT_ICON_RESOURCE =
757 "android.intent.extra.shortcut.ICON_RESOURCE";
758
759 /**
Jason Monk2f68e8a2016-02-23 17:57:28 -0500760 * An activity that provides a user interface for adjusting application preferences.
761 * Optional but recommended settings for all applications which have settings.
762 */
763 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
764 public static final String ACTION_APPLICATION_PREFERENCES
765 = "android.intent.action.APPLICATION_PREFERENCES";
766
767 /**
Sudheer Shanka80b66412016-04-06 18:31:10 -0700768 * Activity Action: Launch an activity showing the app information.
769 * For applications which install other applications (such as app stores), it is recommended
770 * to handle this action for providing the app information to the user.
771 *
772 * <p>Input: {@link #EXTRA_PACKAGE_NAME} specifies the package whose information needs
773 * to be displayed.
774 * <p>Output: Nothing.
775 */
776 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
777 public static final String ACTION_SHOW_APP_INFO
778 = "android.intent.action.SHOW_APP_INFO";
779
780 /**
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800781 * Represents a shortcut/live folder icon resource.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700782 *
783 * @see Intent#ACTION_CREATE_SHORTCUT
784 * @see Intent#EXTRA_SHORTCUT_ICON_RESOURCE
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800785 * @see android.provider.LiveFolders#ACTION_CREATE_LIVE_FOLDER
786 * @see android.provider.LiveFolders#EXTRA_LIVE_FOLDER_ICON
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700787 */
788 public static class ShortcutIconResource implements Parcelable {
789 /**
790 * The package name of the application containing the icon.
791 */
792 public String packageName;
793
794 /**
795 * The resource name of the icon, including package, name and type.
796 */
797 public String resourceName;
798
799 /**
800 * Creates a new ShortcutIconResource for the specified context and resource
801 * identifier.
802 *
803 * @param context The context of the application.
Tor Norbye7b9c9122013-05-30 16:48:33 -0700804 * @param resourceId The resource identifier for the icon.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700805 * @return A new ShortcutIconResource with the specified's context package name
Tor Norbye7b9c9122013-05-30 16:48:33 -0700806 * and icon resource identifier.``
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700807 */
Tor Norbye7b9c9122013-05-30 16:48:33 -0700808 public static ShortcutIconResource fromContext(Context context, @AnyRes int resourceId) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700809 ShortcutIconResource icon = new ShortcutIconResource();
810 icon.packageName = context.getPackageName();
811 icon.resourceName = context.getResources().getResourceName(resourceId);
812 return icon;
813 }
814
815 /**
816 * Used to read a ShortcutIconResource from a Parcel.
817 */
818 public static final Parcelable.Creator<ShortcutIconResource> CREATOR =
819 new Parcelable.Creator<ShortcutIconResource>() {
820
821 public ShortcutIconResource createFromParcel(Parcel source) {
822 ShortcutIconResource icon = new ShortcutIconResource();
823 icon.packageName = source.readString();
824 icon.resourceName = source.readString();
825 return icon;
826 }
827
828 public ShortcutIconResource[] newArray(int size) {
829 return new ShortcutIconResource[size];
830 }
831 };
832
833 /**
834 * No special parcel contents.
835 */
836 public int describeContents() {
837 return 0;
838 }
839
840 public void writeToParcel(Parcel dest, int flags) {
841 dest.writeString(packageName);
842 dest.writeString(resourceName);
843 }
844
845 @Override
846 public String toString() {
847 return resourceName;
848 }
849 }
850
851 /**
852 * Activity Action: Display an activity chooser, allowing the user to pick
853 * what they want to before proceeding. This can be used as an alternative
854 * to the standard activity picker that is displayed by the system when
855 * you try to start an activity with multiple possible matches, with these
856 * differences in behavior:
857 * <ul>
858 * <li>You can specify the title that will appear in the activity chooser.
859 * <li>The user does not have the option to make one of the matching
860 * activities a preferred activity, and all possible activities will
861 * always be shown even if one of them is currently marked as the
862 * preferred activity.
863 * </ul>
864 * <p>
865 * This action should be used when the user will naturally expect to
866 * select an activity in order to proceed. An example if when not to use
867 * it is when the user clicks on a "mailto:" link. They would naturally
868 * expect to go directly to their mail app, so startActivity() should be
869 * called directly: it will
870 * either launch the current preferred app, or put up a dialog allowing the
871 * user to pick an app to use and optionally marking that as preferred.
872 * <p>
873 * In contrast, if the user is selecting a menu item to send a picture
874 * they are viewing to someone else, there are many different things they
875 * may want to do at this point: send it through e-mail, upload it to a
876 * web service, etc. In this case the CHOOSER action should be used, to
877 * always present to the user a list of the things they can do, with a
878 * nice title given by the caller such as "Send this photo with:".
879 * <p>
Dianne Hackborne302a162012-05-15 14:58:32 -0700880 * If you need to grant URI permissions through a chooser, you must specify
881 * the permissions to be granted on the ACTION_CHOOSER Intent
882 * <em>in addition</em> to the EXTRA_INTENT inside. This means using
883 * {@link #setClipData} to specify the URIs to be granted as well as
884 * {@link #FLAG_GRANT_READ_URI_PERMISSION} and/or
885 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION} as appropriate.
886 * <p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700887 * As a convenience, an Intent of this form can be created with the
888 * {@link #createChooser} function.
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -0700889 * <p>
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -0700890 * Input: No data should be specified. get*Extra must have
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700891 * a {@link #EXTRA_INTENT} field containing the Intent being executed,
892 * and can optionally have a {@link #EXTRA_TITLE} field containing the
893 * title text to display in the chooser.
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -0700894 * <p>
895 * Output: Depends on the protocol of {@link #EXTRA_INTENT}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700896 */
897 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
898 public static final String ACTION_CHOOSER = "android.intent.action.CHOOSER";
899
900 /**
901 * Convenience function for creating a {@link #ACTION_CHOOSER} Intent.
902 *
Dianne Hackborne302a162012-05-15 14:58:32 -0700903 * <p>Builds a new {@link #ACTION_CHOOSER} Intent that wraps the given
904 * target intent, also optionally supplying a title. If the target
905 * intent has specified {@link #FLAG_GRANT_READ_URI_PERMISSION} or
906 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, then these flags will also be
907 * set in the returned chooser intent, with its ClipData set appropriately:
908 * either a direct reflection of {@link #getClipData()} if that is non-null,
John Spurlock33900182014-01-02 11:04:18 -0500909 * or a new ClipData built from {@link #getData()}.
Dianne Hackborne302a162012-05-15 14:58:32 -0700910 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700911 * @param target The Intent that the user will be selecting an activity
912 * to perform.
913 * @param title Optional title that will be displayed in the chooser.
914 * @return Return a new Intent object that you can hand to
915 * {@link Context#startActivity(Intent) Context.startActivity()} and
916 * related methods.
917 */
918 public static Intent createChooser(Intent target, CharSequence title) {
Adam Powell0b3c1122014-10-09 12:50:14 -0700919 return createChooser(target, title, null);
920 }
921
922 /**
923 * Convenience function for creating a {@link #ACTION_CHOOSER} Intent.
924 *
925 * <p>Builds a new {@link #ACTION_CHOOSER} Intent that wraps the given
926 * target intent, also optionally supplying a title. If the target
927 * intent has specified {@link #FLAG_GRANT_READ_URI_PERMISSION} or
928 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, then these flags will also be
929 * set in the returned chooser intent, with its ClipData set appropriately:
930 * either a direct reflection of {@link #getClipData()} if that is non-null,
931 * or a new ClipData built from {@link #getData()}.</p>
932 *
933 * <p>The caller may optionally supply an {@link IntentSender} to receive a callback
934 * when the user makes a choice. This can be useful if the calling application wants
935 * to remember the last chosen target and surface it as a more prominent or one-touch
936 * affordance elsewhere in the UI for next time.</p>
937 *
938 * @param target The Intent that the user will be selecting an activity
939 * to perform.
940 * @param title Optional title that will be displayed in the chooser.
941 * @param sender Optional IntentSender to be called when a choice is made.
942 * @return Return a new Intent object that you can hand to
943 * {@link Context#startActivity(Intent) Context.startActivity()} and
944 * related methods.
945 */
946 public static Intent createChooser(Intent target, CharSequence title, IntentSender sender) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700947 Intent intent = new Intent(ACTION_CHOOSER);
948 intent.putExtra(EXTRA_INTENT, target);
949 if (title != null) {
950 intent.putExtra(EXTRA_TITLE, title);
951 }
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -0700952
Adam Powell0b3c1122014-10-09 12:50:14 -0700953 if (sender != null) {
954 intent.putExtra(EXTRA_CHOSEN_COMPONENT_INTENT_SENDER, sender);
955 }
956
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -0700957 // Migrate any clip data and flags from target.
Jeff Sharkey846318a2014-04-04 12:12:41 -0700958 int permFlags = target.getFlags() & (FLAG_GRANT_READ_URI_PERMISSION
959 | FLAG_GRANT_WRITE_URI_PERMISSION | FLAG_GRANT_PERSISTABLE_URI_PERMISSION
960 | FLAG_GRANT_PREFIX_URI_PERMISSION);
Dianne Hackborne302a162012-05-15 14:58:32 -0700961 if (permFlags != 0) {
962 ClipData targetClipData = target.getClipData();
963 if (targetClipData == null && target.getData() != null) {
964 ClipData.Item item = new ClipData.Item(target.getData());
965 String[] mimeTypes;
966 if (target.getType() != null) {
967 mimeTypes = new String[] { target.getType() };
968 } else {
969 mimeTypes = new String[] { };
970 }
971 targetClipData = new ClipData(null, mimeTypes, item);
972 }
973 if (targetClipData != null) {
974 intent.setClipData(targetClipData);
975 intent.addFlags(permFlags);
976 }
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -0700977 }
Dianne Hackborne302a162012-05-15 14:58:32 -0700978
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700979 return intent;
980 }
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -0700981
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700982 /**
983 * Activity Action: Allow the user to select a particular kind of data and
984 * return it. This is different than {@link #ACTION_PICK} in that here we
985 * just say what kind of data is desired, not a URI of existing data from
Dianne Hackbornfdb3f092013-01-28 15:10:48 -0800986 * which the user can pick. An ACTION_GET_CONTENT could allow the user to
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700987 * create the data as it runs (for example taking a picture or recording a
Ken Wakasaf76a50c2012-03-09 19:56:35 +0900988 * sound), let them browse over the web and download the desired data,
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700989 * etc.
990 * <p>
Ken Wakasaf76a50c2012-03-09 19:56:35 +0900991 * 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 -0700992 * of data, such as a person contact, you set the MIME type to the kind of
993 * data you want and launch it with {@link Context#startActivity(Intent)}.
994 * The system will then launch the best application to select that kind
995 * of data for you.
996 * <p>
997 * You may also be interested in any of a set of types of content the user
998 * can pick. For example, an e-mail application that wants to allow the
999 * user to add an attachment to an e-mail message can use this action to
1000 * bring up a list of all of the types of content the user can attach.
1001 * <p>
1002 * In this case, you should wrap the GET_CONTENT intent with a chooser
1003 * (through {@link #createChooser}), which will give the proper interface
1004 * for the user to pick how to send your data and allow you to specify
1005 * a prompt indicating what they are doing. You will usually specify a
1006 * broad MIME type (such as image/* or {@literal *}/*), resulting in a
1007 * broad range of content types the user can select from.
1008 * <p>
Ken Wakasaf76a50c2012-03-09 19:56:35 +09001009 * When using such a broad GET_CONTENT action, it is often desirable to
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001010 * only pick from data that can be represented as a stream. This is
1011 * accomplished by requiring the {@link #CATEGORY_OPENABLE} in the Intent.
1012 * <p>
Dianne Hackbornc4d0e6f2011-01-25 14:55:06 -08001013 * Callers can optionally specify {@link #EXTRA_LOCAL_ONLY} to request that
Ken Wakasaf76a50c2012-03-09 19:56:35 +09001014 * the launched content chooser only returns results representing data that
Dianne Hackbornc4d0e6f2011-01-25 14:55:06 -08001015 * is locally available on the device. For example, if this extra is set
1016 * to true then an image picker should not show any pictures that are available
1017 * from a remote server but not already on the local device (thus requiring
1018 * they be downloaded when opened).
1019 * <p>
Dianne Hackbornfdb3f092013-01-28 15:10:48 -08001020 * If the caller can handle multiple returned items (the user performing
1021 * multiple selection), then it can specify {@link #EXTRA_ALLOW_MULTIPLE}
1022 * to indicate this.
1023 * <p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001024 * Input: {@link #getType} is the desired MIME type to retrieve. Note
1025 * that no URI is supplied in the intent, as there are no constraints on
1026 * where the returned data originally comes from. You may also include the
1027 * {@link #CATEGORY_OPENABLE} if you can only accept data that can be
Dianne Hackbornc4d0e6f2011-01-25 14:55:06 -08001028 * opened as a stream. You may use {@link #EXTRA_LOCAL_ONLY} to limit content
Dianne Hackbornfdb3f092013-01-28 15:10:48 -08001029 * selection to local data. You may use {@link #EXTRA_ALLOW_MULTIPLE} to
1030 * allow the user to select multiple items.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001031 * <p>
1032 * Output: The URI of the item that was picked. This must be a content:
1033 * URI so that any receiver can access it.
1034 */
1035 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1036 public static final String ACTION_GET_CONTENT = "android.intent.action.GET_CONTENT";
1037 /**
1038 * Activity Action: Dial a number as specified by the data. This shows a
1039 * UI with the number being dialed, allowing the user to explicitly
1040 * initiate the call.
1041 * <p>Input: If nothing, an empty dialer is started; else {@link #getData}
1042 * is URI of a phone number to be dialed or a tel: URI of an explicit phone
1043 * number.
1044 * <p>Output: nothing.
1045 */
1046 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1047 public static final String ACTION_DIAL = "android.intent.action.DIAL";
1048 /**
1049 * Activity Action: Perform a call to someone specified by the data.
1050 * <p>Input: If nothing, an empty dialer is started; else {@link #getData}
1051 * is URI of a phone number to be dialed or a tel: URI of an explicit phone
1052 * number.
1053 * <p>Output: nothing.
1054 *
1055 * <p>Note: there will be restrictions on which applications can initiate a
1056 * call; most applications should use the {@link #ACTION_DIAL}.
1057 * <p>Note: this Intent <strong>cannot</strong> be used to call emergency
1058 * numbers. Applications can <strong>dial</strong> emergency numbers using
1059 * {@link #ACTION_DIAL}, however.
Svetoslav7008b512015-06-24 18:47:07 -07001060 *
Dianne Hackborn0e3de6c2015-07-29 15:20:21 -07001061 * <p>Note: if you app targets {@link android.os.Build.VERSION_CODES#M M}
Svetoslav7008b512015-06-24 18:47:07 -07001062 * and above and declares as using the {@link android.Manifest.permission#CALL_PHONE}
Svet Ganov7121e182015-07-13 22:38:12 -07001063 * permission which is not granted, then attempting to use this action will
Svetoslav7008b512015-06-24 18:47:07 -07001064 * result in a {@link java.lang.SecurityException}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001065 */
1066 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1067 public static final String ACTION_CALL = "android.intent.action.CALL";
1068 /**
1069 * Activity Action: Perform a call to an emergency number specified by the
1070 * data.
1071 * <p>Input: {@link #getData} is URI of a phone number to be dialed or a
1072 * tel: URI of an explicit phone number.
1073 * <p>Output: nothing.
1074 * @hide
1075 */
1076 public static final String ACTION_CALL_EMERGENCY = "android.intent.action.CALL_EMERGENCY";
1077 /**
1078 * Activity action: Perform a call to any number (emergency or not)
1079 * specified by the data.
1080 * <p>Input: {@link #getData} is URI of a phone number to be dialed or a
1081 * tel: URI of an explicit phone number.
1082 * <p>Output: nothing.
1083 * @hide
1084 */
1085 public static final String ACTION_CALL_PRIVILEGED = "android.intent.action.CALL_PRIVILEGED";
1086 /**
Santos Cordon15a13782015-03-31 18:32:31 -07001087 * Activity action: Activate the current SIM card. If SIM cards do not require activation,
1088 * sending this intent is a no-op.
1089 * <p>Input: No data should be specified. get*Extra may have an optional
1090 * {@link #EXTRA_SIM_ACTIVATION_RESPONSE} field containing a PendingIntent through which to
1091 * send the activation result.
1092 * <p>Output: nothing.
1093 * @hide
1094 */
1095 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1096 public static final String ACTION_SIM_ACTIVATION_REQUEST =
1097 "android.intent.action.SIM_ACTIVATION_REQUEST";
1098 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001099 * Activity Action: Send a message to someone specified by the data.
1100 * <p>Input: {@link #getData} is URI describing the target.
1101 * <p>Output: nothing.
1102 */
1103 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1104 public static final String ACTION_SENDTO = "android.intent.action.SENDTO";
1105 /**
1106 * Activity Action: Deliver some data to someone else. Who the data is
1107 * being delivered to is not specified; it is up to the receiver of this
1108 * action to ask the user where the data should be sent.
1109 * <p>
1110 * When launching a SEND intent, you should usually wrap it in a chooser
1111 * (through {@link #createChooser}), which will give the proper interface
1112 * for the user to pick how to send your data and allow you to specify
1113 * a prompt indicating what they are doing.
1114 * <p>
1115 * Input: {@link #getType} is the MIME type of the data being sent.
1116 * get*Extra can have either a {@link #EXTRA_TEXT}
1117 * or {@link #EXTRA_STREAM} field, containing the data to be sent. If
1118 * using EXTRA_TEXT, the MIME type should be "text/plain"; otherwise it
1119 * should be the MIME type of the data in EXTRA_STREAM. Use {@literal *}/*
1120 * if the MIME type is unknown (this will only allow senders that can
Dianne Hackbornacb69bb2012-04-13 15:36:06 -07001121 * handle generic data streams). If using {@link #EXTRA_TEXT}, you can
1122 * also optionally supply {@link #EXTRA_HTML_TEXT} for clients to retrieve
1123 * your text with HTML formatting.
1124 * <p>
1125 * As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN}, the data
1126 * being sent can be supplied through {@link #setClipData(ClipData)}. This
1127 * allows you to use {@link #FLAG_GRANT_READ_URI_PERMISSION} when sharing
1128 * content: URIs and other advanced features of {@link ClipData}. If
1129 * using this approach, you still must supply the same data through the
1130 * {@link #EXTRA_TEXT} or {@link #EXTRA_STREAM} fields described below
1131 * for compatibility with old applications. If you don't set a ClipData,
1132 * it will be copied there for you when calling {@link Context#startActivity(Intent)}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001133 * <p>
Tomasz Mikolajewskid8a2e192016-12-15 16:10:46 +09001134 * Starting from {@link android.os.Build.VERSION_CODES#O}, if
1135 * {@link #CATEGORY_TYPED_OPENABLE} is passed, then the Uris passed in
1136 * either {@link #EXTRA_STREAM} or via {@link #setClipData(ClipData)} may
1137 * be openable only as asset typed files using
1138 * {@link ContentResolver#openTypedAssetFileDescriptor(Uri, String, Bundle)}.
1139 * <p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001140 * Optional standard extras, which may be interpreted by some recipients as
1141 * appropriate, are: {@link #EXTRA_EMAIL}, {@link #EXTRA_CC},
1142 * {@link #EXTRA_BCC}, {@link #EXTRA_SUBJECT}.
1143 * <p>
1144 * Output: nothing.
1145 */
1146 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1147 public static final String ACTION_SEND = "android.intent.action.SEND";
1148 /**
Wu-cheng Li649f99e2009-06-17 14:29:57 +08001149 * Activity Action: Deliver multiple data to someone else.
1150 * <p>
Dianne Hackbornacb69bb2012-04-13 15:36:06 -07001151 * Like {@link #ACTION_SEND}, except the data is multiple.
Wu-cheng Li649f99e2009-06-17 14:29:57 +08001152 * <p>
1153 * Input: {@link #getType} is the MIME type of the data being sent.
1154 * get*ArrayListExtra can have either a {@link #EXTRA_TEXT} or {@link
Dianne Hackbornacb69bb2012-04-13 15:36:06 -07001155 * #EXTRA_STREAM} field, containing the data to be sent. If using
1156 * {@link #EXTRA_TEXT}, you can also optionally supply {@link #EXTRA_HTML_TEXT}
1157 * for clients to retrieve your text with HTML formatting.
Wu-cheng Li649f99e2009-06-17 14:29:57 +08001158 * <p>
Chih-Chung Chang5962d272009-09-04 14:36:01 +08001159 * Multiple types are supported, and receivers should handle mixed types
1160 * whenever possible. The right way for the receiver to check them is to
1161 * use the content resolver on each URI. The intent sender should try to
1162 * put the most concrete mime type in the intent type, but it can fall
1163 * back to {@literal <type>/*} or {@literal *}/* as needed.
1164 * <p>
1165 * e.g. if you are sending image/jpg and image/jpg, the intent's type can
1166 * be image/jpg, but if you are sending image/jpg and image/png, then the
1167 * intent's type should be image/*.
1168 * <p>
Dianne Hackbornacb69bb2012-04-13 15:36:06 -07001169 * As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN}, the data
1170 * being sent can be supplied through {@link #setClipData(ClipData)}. This
1171 * allows you to use {@link #FLAG_GRANT_READ_URI_PERMISSION} when sharing
1172 * content: URIs and other advanced features of {@link ClipData}. If
1173 * using this approach, you still must supply the same data through the
1174 * {@link #EXTRA_TEXT} or {@link #EXTRA_STREAM} fields described below
1175 * for compatibility with old applications. If you don't set a ClipData,
1176 * it will be copied there for you when calling {@link Context#startActivity(Intent)}.
1177 * <p>
Tomasz Mikolajewskid8a2e192016-12-15 16:10:46 +09001178 * Starting from {@link android.os.Build.VERSION_CODES#O}, if
1179 * {@link #CATEGORY_TYPED_OPENABLE} is passed, then the Uris passed in
1180 * either {@link #EXTRA_STREAM} or via {@link #setClipData(ClipData)} may
1181 * be openable only as asset typed files using
1182 * {@link ContentResolver#openTypedAssetFileDescriptor(Uri, String, Bundle)}.
1183 * <p>
Wu-cheng Li649f99e2009-06-17 14:29:57 +08001184 * Optional standard extras, which may be interpreted by some recipients as
1185 * appropriate, are: {@link #EXTRA_EMAIL}, {@link #EXTRA_CC},
1186 * {@link #EXTRA_BCC}, {@link #EXTRA_SUBJECT}.
1187 * <p>
1188 * Output: nothing.
1189 */
1190 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1191 public static final String ACTION_SEND_MULTIPLE = "android.intent.action.SEND_MULTIPLE";
1192 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001193 * Activity Action: Handle an incoming phone call.
1194 * <p>Input: nothing.
1195 * <p>Output: nothing.
1196 */
1197 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1198 public static final String ACTION_ANSWER = "android.intent.action.ANSWER";
1199 /**
1200 * Activity Action: Insert an empty item into the given container.
1201 * <p>Input: {@link #getData} is URI of the directory (vnd.android.cursor.dir/*)
1202 * in which to place the data.
1203 * <p>Output: URI of the new data that was created.
1204 */
1205 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1206 public static final String ACTION_INSERT = "android.intent.action.INSERT";
1207 /**
Dianne Hackborn23fdaf62010-08-06 12:16:55 -07001208 * Activity Action: Create a new item in the given container, initializing it
1209 * from the current contents of the clipboard.
1210 * <p>Input: {@link #getData} is URI of the directory (vnd.android.cursor.dir/*)
1211 * in which to place the data.
1212 * <p>Output: URI of the new data that was created.
1213 */
1214 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1215 public static final String ACTION_PASTE = "android.intent.action.PASTE";
1216 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001217 * Activity Action: Delete the given data from its container.
1218 * <p>Input: {@link #getData} is URI of data to be deleted.
1219 * <p>Output: nothing.
1220 */
1221 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1222 public static final String ACTION_DELETE = "android.intent.action.DELETE";
1223 /**
1224 * Activity Action: Run the data, whatever that means.
1225 * <p>Input: ? (Note: this is currently specific to the test harness.)
1226 * <p>Output: nothing.
1227 */
1228 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1229 public static final String ACTION_RUN = "android.intent.action.RUN";
1230 /**
1231 * Activity Action: Perform a data synchronization.
1232 * <p>Input: ?
1233 * <p>Output: ?
1234 */
1235 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1236 public static final String ACTION_SYNC = "android.intent.action.SYNC";
1237 /**
1238 * Activity Action: Pick an activity given an intent, returning the class
1239 * selected.
1240 * <p>Input: get*Extra field {@link #EXTRA_INTENT} is an Intent
1241 * used with {@link PackageManager#queryIntentActivities} to determine the
1242 * set of activities from which to pick.
1243 * <p>Output: Class name of the activity that was selected.
1244 */
1245 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1246 public static final String ACTION_PICK_ACTIVITY = "android.intent.action.PICK_ACTIVITY";
1247 /**
1248 * Activity Action: Perform a search.
1249 * <p>Input: {@link android.app.SearchManager#QUERY getStringExtra(SearchManager.QUERY)}
1250 * is the text to search for. If empty, simply
1251 * enter your search results Activity with the search UI activated.
1252 * <p>Output: nothing.
1253 */
1254 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1255 public static final String ACTION_SEARCH = "android.intent.action.SEARCH";
1256 /**
Jim Miller7e4ad352009-03-25 18:16:41 -07001257 * Activity Action: Start the platform-defined tutorial
1258 * <p>Input: {@link android.app.SearchManager#QUERY getStringExtra(SearchManager.QUERY)}
1259 * is the text to search for. If empty, simply
1260 * enter your search results Activity with the search UI activated.
1261 * <p>Output: nothing.
1262 */
1263 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1264 public static final String ACTION_SYSTEM_TUTORIAL = "android.intent.action.SYSTEM_TUTORIAL";
1265 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001266 * Activity Action: Perform a web search.
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08001267 * <p>
1268 * Input: {@link android.app.SearchManager#QUERY
1269 * getStringExtra(SearchManager.QUERY)} is the text to search for. If it is
1270 * a url starts with http or https, the site will be opened. If it is plain
1271 * text, Google search will be applied.
1272 * <p>
1273 * Output: nothing.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001274 */
1275 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1276 public static final String ACTION_WEB_SEARCH = "android.intent.action.WEB_SEARCH";
Dianne Hackbornf9c5e0f2013-01-23 14:39:13 -08001277
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001278 /**
Jim Miller07994402012-05-02 14:22:27 -07001279 * Activity Action: Perform assist action.
1280 * <p>
Adam Skory7140a252013-09-11 12:04:58 +01001281 * Input: {@link #EXTRA_ASSIST_PACKAGE}, {@link #EXTRA_ASSIST_CONTEXT}, can provide
1282 * additional optional contextual information about where the user was when they
Dianne Hackborna3acdb32015-06-08 17:07:40 -07001283 * requested the assist; {@link #EXTRA_REFERRER} may be set with additional referrer
1284 * information.
Jim Miller07994402012-05-02 14:22:27 -07001285 * Output: nothing.
1286 */
1287 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1288 public static final String ACTION_ASSIST = "android.intent.action.ASSIST";
Dianne Hackbornf9c5e0f2013-01-23 14:39:13 -08001289
1290 /**
Bjorn Bringertbc086862013-03-01 12:59:24 +00001291 * Activity Action: Perform voice assist action.
1292 * <p>
Adam Skory7140a252013-09-11 12:04:58 +01001293 * Input: {@link #EXTRA_ASSIST_PACKAGE}, {@link #EXTRA_ASSIST_CONTEXT}, can provide
1294 * additional optional contextual information about where the user was when they
Adam Skorydfc7fd72013-08-05 19:23:41 -07001295 * requested the voice assist.
Bjorn Bringertbc086862013-03-01 12:59:24 +00001296 * Output: nothing.
Adam Skory7140a252013-09-11 12:04:58 +01001297 * @hide
Bjorn Bringertbc086862013-03-01 12:59:24 +00001298 */
1299 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1300 public static final String ACTION_VOICE_ASSIST = "android.intent.action.VOICE_ASSIST";
1301
1302 /**
Adam Skory7140a252013-09-11 12:04:58 +01001303 * An optional field on {@link #ACTION_ASSIST} containing the name of the current foreground
1304 * application package at the time the assist was invoked.
Dianne Hackbornf9c5e0f2013-01-23 14:39:13 -08001305 */
1306 public static final String EXTRA_ASSIST_PACKAGE
1307 = "android.intent.extra.ASSIST_PACKAGE";
1308
1309 /**
Dianne Hackborna83ce1d2015-03-11 15:16:13 -07001310 * An optional field on {@link #ACTION_ASSIST} containing the uid of the current foreground
1311 * application package at the time the assist was invoked.
1312 */
1313 public static final String EXTRA_ASSIST_UID
1314 = "android.intent.extra.ASSIST_UID";
1315
1316 /**
Adam Skory7140a252013-09-11 12:04:58 +01001317 * An optional field on {@link #ACTION_ASSIST} and containing additional contextual
1318 * information supplied by the current foreground app at the time of the assist request.
1319 * This is a {@link Bundle} of additional data.
Dianne Hackbornf9c5e0f2013-01-23 14:39:13 -08001320 */
1321 public static final String EXTRA_ASSIST_CONTEXT
1322 = "android.intent.extra.ASSIST_CONTEXT";
1323
Jim Miller07994402012-05-02 14:22:27 -07001324 /**
Michael Wright8ab940a2014-09-01 11:01:27 -07001325 * An optional field on {@link #ACTION_ASSIST} suggesting that the user will likely use a
1326 * keyboard as the primary input device for assistance.
1327 */
1328 public static final String EXTRA_ASSIST_INPUT_HINT_KEYBOARD =
1329 "android.intent.extra.ASSIST_INPUT_HINT_KEYBOARD";
1330
1331 /**
Tim Kilbourn0e5f1102015-06-05 16:18:09 -07001332 * An optional field on {@link #ACTION_ASSIST} containing the InputDevice id
1333 * that was used to invoke the assist.
1334 */
1335 public static final String EXTRA_ASSIST_INPUT_DEVICE_ID =
1336 "android.intent.extra.ASSIST_INPUT_DEVICE_ID";
1337
1338 /**
Trevor Johns682c24e2016-04-12 10:13:47 -07001339 * Activity Action: List all available applications.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001340 * <p>Input: Nothing.
1341 * <p>Output: nothing.
1342 */
1343 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1344 public static final String ACTION_ALL_APPS = "android.intent.action.ALL_APPS";
1345 /**
Trevor Johns682c24e2016-04-12 10:13:47 -07001346 * Activity Action: Show settings for choosing wallpaper.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001347 * <p>Input: Nothing.
1348 * <p>Output: Nothing.
1349 */
1350 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1351 public static final String ACTION_SET_WALLPAPER = "android.intent.action.SET_WALLPAPER";
1352
1353 /**
1354 * Activity Action: Show activity for reporting a bug.
1355 * <p>Input: Nothing.
1356 * <p>Output: Nothing.
1357 */
1358 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1359 public static final String ACTION_BUG_REPORT = "android.intent.action.BUG_REPORT";
1360
1361 /**
1362 * Activity Action: Main entry point for factory tests. Only used when
1363 * the device is booting in factory test node. The implementing package
1364 * must be installed in the system image.
1365 * <p>Input: nothing
1366 * <p>Output: nothing
1367 */
1368 public static final String ACTION_FACTORY_TEST = "android.intent.action.FACTORY_TEST";
1369
1370 /**
1371 * Activity Action: The user pressed the "call" button to go to the dialer
1372 * or other appropriate UI for placing a call.
1373 * <p>Input: Nothing.
1374 * <p>Output: Nothing.
1375 */
1376 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1377 public static final String ACTION_CALL_BUTTON = "android.intent.action.CALL_BUTTON";
1378
1379 /**
1380 * Activity Action: Start Voice Command.
1381 * <p>Input: Nothing.
1382 * <p>Output: Nothing.
1383 */
1384 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1385 public static final String ACTION_VOICE_COMMAND = "android.intent.action.VOICE_COMMAND";
The Android Open Source Projectba87e3e2009-03-13 13:04:22 -07001386
1387 /**
1388 * Activity Action: Start action associated with long pressing on the
1389 * search key.
1390 * <p>Input: Nothing.
1391 * <p>Output: Nothing.
1392 */
1393 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1394 public static final String ACTION_SEARCH_LONG_PRESS = "android.intent.action.SEARCH_LONG_PRESS";
The Android Open Source Project10592532009-03-18 17:39:46 -07001395
Jacek Surazski86b6c532009-05-13 14:38:28 +02001396 /**
1397 * Activity Action: The user pressed the "Report" button in the crash/ANR dialog.
1398 * This intent is delivered to the package which installed the application, usually
Dirk Dougherty4d7bc6552012-01-27 17:56:49 -08001399 * Google Play.
Jacek Surazski86b6c532009-05-13 14:38:28 +02001400 * <p>Input: No data is specified. The bug report is passed in using
1401 * an {@link #EXTRA_BUG_REPORT} field.
1402 * <p>Output: Nothing.
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001403 *
1404 * @see #EXTRA_BUG_REPORT
Jacek Surazski86b6c532009-05-13 14:38:28 +02001405 */
1406 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1407 public static final String ACTION_APP_ERROR = "android.intent.action.APP_ERROR";
Dianne Hackborn3d74bb42009-06-19 10:35:21 -07001408
1409 /**
1410 * Activity Action: Show power usage information to the user.
1411 * <p>Input: Nothing.
1412 * <p>Output: Nothing.
1413 */
1414 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1415 public static final String ACTION_POWER_USAGE_SUMMARY = "android.intent.action.POWER_USAGE_SUMMARY";
Tom Taylord4a47292009-12-21 13:59:18 -08001416
Dianne Hackbornd7cd29d2009-07-01 11:22:45 -07001417 /**
1418 * Activity Action: Setup wizard to launch after a platform update. This
1419 * activity should have a string meta-data field associated with it,
1420 * {@link #METADATA_SETUP_VERSION}, which defines the current version of
1421 * the platform for setup. The activity will be launched only if
1422 * {@link android.provider.Settings.Secure#LAST_SETUP_SHOWN} is not the
1423 * same value.
1424 * <p>Input: Nothing.
1425 * <p>Output: Nothing.
1426 * @hide
1427 */
1428 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1429 public static final String ACTION_UPGRADE_SETUP = "android.intent.action.UPGRADE_SETUP";
Tom Taylord4a47292009-12-21 13:59:18 -08001430
Dianne Hackbornd7cd29d2009-07-01 11:22:45 -07001431 /**
Clara Bayarrieb3c2d32016-04-01 14:37:32 +01001432 * Activity Action: Start the Keyboard Shortcuts Helper screen.
1433 * <p>Input: Nothing.
1434 * <p>Output: Nothing.
1435 * @hide
1436 */
1437 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1438 public static final String ACTION_SHOW_KEYBOARD_SHORTCUTS =
1439 "android.intent.action.SHOW_KEYBOARD_SHORTCUTS";
1440
1441 /**
Andrei Stingaceanu0bf096f2016-04-14 18:11:57 +01001442 * Activity Action: Dismiss the Keyboard Shortcuts Helper screen.
1443 * <p>Input: Nothing.
1444 * <p>Output: Nothing.
1445 * @hide
1446 */
1447 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1448 public static final String ACTION_DISMISS_KEYBOARD_SHORTCUTS =
1449 "android.intent.action.DISMISS_KEYBOARD_SHORTCUTS";
1450
1451 /**
Jeff Sharkey7f868272011-06-05 16:05:02 -07001452 * Activity Action: Show settings for managing network data usage of a
1453 * specific application. Applications should define an activity that offers
1454 * options to control data usage.
1455 */
1456 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1457 public static final String ACTION_MANAGE_NETWORK_USAGE =
1458 "android.intent.action.MANAGE_NETWORK_USAGE";
1459
1460 /**
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001461 * Activity Action: Launch application installer.
1462 * <p>
Todd Kennedy9cc589a2016-08-18 16:23:17 -07001463 * Input: The data must be a content: URI at which the application
Dianne Hackborneba784ff2012-09-19 12:42:37 -07001464 * can be retrieved. As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN_MR1},
1465 * you can also use "package:<package-name>" to install an application for the
1466 * current user that is already installed for another user. You can optionally supply
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001467 * {@link #EXTRA_INSTALLER_PACKAGE_NAME}, {@link #EXTRA_NOT_UNKNOWN_SOURCE},
1468 * {@link #EXTRA_ALLOW_REPLACE}, and {@link #EXTRA_RETURN_RESULT}.
1469 * <p>
1470 * Output: If {@link #EXTRA_RETURN_RESULT}, returns whether the install
1471 * succeeded.
Svet Ganov86877e42015-05-28 08:19:48 -07001472 * <p>
1473 * <strong>Note:</strong>If your app is targeting API level higher than 22 you
1474 * need to hold {@link android.Manifest.permission#REQUEST_INSTALL_PACKAGES}
1475 * in order to launch the application installer.
1476 * </p>
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001477 *
1478 * @see #EXTRA_INSTALLER_PACKAGE_NAME
1479 * @see #EXTRA_NOT_UNKNOWN_SOURCE
1480 * @see #EXTRA_RETURN_RESULT
1481 */
1482 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1483 public static final String ACTION_INSTALL_PACKAGE = "android.intent.action.INSTALL_PACKAGE";
1484
1485 /**
Todd Kennedyb8a279e2015-11-18 09:59:47 -08001486 * Activity Action: Launch ephemeral installer.
1487 * <p>
1488 * Input: The data must be a http: URI that the ephemeral application is registered
1489 * to handle.
1490 * <p class="note">
1491 * This is a protected intent that can only be sent by the system.
1492 * </p>
1493 *
1494 * @hide
1495 */
Todd Kennedyb8a279e2015-11-18 09:59:47 -08001496 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1497 public static final String ACTION_INSTALL_EPHEMERAL_PACKAGE
1498 = "android.intent.action.INSTALL_EPHEMERAL_PACKAGE";
1499
1500 /**
1501 * Service Action: Resolve ephemeral application.
1502 * <p>
1503 * The system will have a persistent connection to this service.
1504 * This is a protected intent that can only be sent by the system.
1505 * </p>
1506 *
1507 * @hide
1508 */
Todd Kennedyb8a279e2015-11-18 09:59:47 -08001509 @SdkConstant(SdkConstantType.SERVICE_ACTION)
1510 public static final String ACTION_RESOLVE_EPHEMERAL_PACKAGE
1511 = "android.intent.action.RESOLVE_EPHEMERAL_PACKAGE";
1512
1513 /**
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001514 * Used as a string extra field with {@link #ACTION_INSTALL_PACKAGE} to install a
1515 * package. Specifies the installer package name; this package will receive the
1516 * {@link #ACTION_APP_ERROR} intent.
1517 */
1518 public static final String EXTRA_INSTALLER_PACKAGE_NAME
1519 = "android.intent.extra.INSTALLER_PACKAGE_NAME";
1520
1521 /**
1522 * Used as a boolean extra field with {@link #ACTION_INSTALL_PACKAGE} to install a
1523 * package. Specifies that the application being installed should not be
1524 * treated as coming from an unknown source, but as coming from the app
1525 * invoking the Intent. For this to work you must start the installer with
1526 * startActivityForResult().
1527 */
1528 public static final String EXTRA_NOT_UNKNOWN_SOURCE
1529 = "android.intent.extra.NOT_UNKNOWN_SOURCE";
1530
1531 /**
rich cannings706e8ba2012-08-20 13:20:14 -07001532 * Used as a URI extra field with {@link #ACTION_INSTALL_PACKAGE} and
1533 * {@link #ACTION_VIEW} to indicate the URI from which the local APK in the Intent
rich cannings368ed012012-06-07 15:37:57 -07001534 * data field originated from.
1535 */
rich cannings706e8ba2012-08-20 13:20:14 -07001536 public static final String EXTRA_ORIGINATING_URI
1537 = "android.intent.extra.ORIGINATING_URI";
rich cannings368ed012012-06-07 15:37:57 -07001538
1539 /**
Dianne Hackborn85d558c2014-11-04 10:31:54 -08001540 * This extra can be used with any Intent used to launch an activity, supplying information
1541 * about who is launching that activity. This field contains a {@link android.net.Uri}
1542 * object, typically an http: or https: URI of the web site that the referral came from;
1543 * it can also use the {@link #URI_ANDROID_APP_SCHEME android-app:} scheme to identify
1544 * a native application that it came from.
1545 *
1546 * <p>To retrieve this value in a client, use {@link android.app.Activity#getReferrer}
1547 * instead of directly retrieving the extra. It is also valid for applications to
1548 * instead supply {@link #EXTRA_REFERRER_NAME} for cases where they can only create
1549 * a string, not a Uri; the field here, if supplied, will always take precedence,
1550 * however.</p>
1551 *
1552 * @see #EXTRA_REFERRER_NAME
rich cannings368ed012012-06-07 15:37:57 -07001553 */
1554 public static final String EXTRA_REFERRER
1555 = "android.intent.extra.REFERRER";
1556
1557 /**
Dianne Hackborn85d558c2014-11-04 10:31:54 -08001558 * Alternate version of {@link #EXTRA_REFERRER} that supplies the URI as a String rather
1559 * than a {@link android.net.Uri} object. Only for use in cases where Uri objects can
1560 * not be created, in particular when Intent extras are supplied through the
1561 * {@link #URI_INTENT_SCHEME intent:} or {@link #URI_ANDROID_APP_SCHEME android-app:}
1562 * schemes.
1563 *
1564 * @see #EXTRA_REFERRER
1565 */
1566 public static final String EXTRA_REFERRER_NAME
1567 = "android.intent.extra.REFERRER_NAME";
1568
1569 /**
Ben Gruver37d83a32012-09-27 13:02:06 -07001570 * Used as an int extra field with {@link #ACTION_INSTALL_PACKAGE} and
Gina Dimino98ad8882016-05-31 17:25:48 -07001571 * {@link #ACTION_VIEW} to indicate the uid of the package that initiated the install
Ben Gruver37d83a32012-09-27 13:02:06 -07001572 * @hide
1573 */
Svet Ganovae0e03a2016-02-25 18:22:10 -08001574 @SystemApi
Ben Gruver37d83a32012-09-27 13:02:06 -07001575 public static final String EXTRA_ORIGINATING_UID
1576 = "android.intent.extra.ORIGINATING_UID";
1577
1578 /**
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001579 * Used as a boolean extra field with {@link #ACTION_INSTALL_PACKAGE} to install a
1580 * package. Tells the installer UI to skip the confirmation with the user
1581 * if the .apk is replacing an existing one.
Dianne Hackborn0e128bb2012-05-01 14:40:15 -07001582 * @deprecated As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN}, Android
1583 * will no longer show an interstitial message about updating existing
1584 * applications so this is no longer needed.
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001585 */
Dianne Hackborn0e128bb2012-05-01 14:40:15 -07001586 @Deprecated
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001587 public static final String EXTRA_ALLOW_REPLACE
1588 = "android.intent.extra.ALLOW_REPLACE";
1589
1590 /**
1591 * Used as a boolean extra field with {@link #ACTION_INSTALL_PACKAGE} or
1592 * {@link #ACTION_UNINSTALL_PACKAGE}. Specifies that the installer UI should
1593 * return to the application the result code of the install/uninstall. The returned result
1594 * code will be {@link android.app.Activity#RESULT_OK} on success or
1595 * {@link android.app.Activity#RESULT_FIRST_USER} on failure.
1596 */
1597 public static final String EXTRA_RETURN_RESULT
1598 = "android.intent.extra.RETURN_RESULT";
1599
1600 /**
1601 * Package manager install result code. @hide because result codes are not
1602 * yet ready to be exposed.
1603 */
1604 public static final String EXTRA_INSTALL_RESULT
1605 = "android.intent.extra.INSTALL_RESULT";
1606
1607 /**
1608 * Activity Action: Launch application uninstaller.
1609 * <p>
1610 * Input: The data must be a package: URI whose scheme specific part is
1611 * the package name of the current installed package to be uninstalled.
1612 * You can optionally supply {@link #EXTRA_RETURN_RESULT}.
1613 * <p>
1614 * Output: If {@link #EXTRA_RETURN_RESULT}, returns whether the install
1615 * succeeded.
1616 */
1617 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1618 public static final String ACTION_UNINSTALL_PACKAGE = "android.intent.action.UNINSTALL_PACKAGE";
1619
1620 /**
Dianne Hackborn6d235d82012-09-16 18:25:40 -07001621 * Specify whether the package should be uninstalled for all users.
1622 * @hide because these should not be part of normal application flow.
1623 */
1624 public static final String EXTRA_UNINSTALL_ALL_USERS
1625 = "android.intent.extra.UNINSTALL_ALL_USERS";
1626
1627 /**
Dianne Hackbornd7cd29d2009-07-01 11:22:45 -07001628 * A string associated with a {@link #ACTION_UPGRADE_SETUP} activity
1629 * describing the last run version of the platform that was setup.
1630 * @hide
1631 */
1632 public static final String METADATA_SETUP_VERSION = "android.SETUP_VERSION";
1633
Svet Ganov3695b8a2015-03-24 16:30:25 -07001634 /**
1635 * Activity action: Launch UI to manage the permissions of an app.
1636 * <p>
1637 * Input: {@link #EXTRA_PACKAGE_NAME} specifies the package whose permissions
1638 * will be managed by the launched UI.
1639 * </p>
1640 * <p>
1641 * Output: Nothing.
1642 * </p>
1643 *
1644 * @see #EXTRA_PACKAGE_NAME
1645 *
1646 * @hide
1647 */
Svet Ganovae0e03a2016-02-25 18:22:10 -08001648 @SystemApi
Svet Ganov3695b8a2015-03-24 16:30:25 -07001649 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1650 public static final String ACTION_MANAGE_APP_PERMISSIONS =
1651 "android.intent.action.MANAGE_APP_PERMISSIONS";
1652
1653 /**
Svet Ganov321f0152015-05-16 22:51:50 -07001654 * Activity action: Launch UI to manage permissions.
1655 * <p>
1656 * Input: Nothing.
1657 * </p>
1658 * <p>
1659 * Output: Nothing.
1660 * </p>
1661 *
1662 * @hide
1663 */
Svet Ganovae0e03a2016-02-25 18:22:10 -08001664 @SystemApi
Svet Ganov321f0152015-05-16 22:51:50 -07001665 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1666 public static final String ACTION_MANAGE_PERMISSIONS =
1667 "android.intent.action.MANAGE_PERMISSIONS";
1668
1669 /**
Svet Ganov9c165d72015-12-01 19:52:26 -08001670 * Activity action: Launch UI to review permissions for an app.
1671 * The system uses this intent if permission review for apps not
1672 * supporting the new runtime permissions model is enabled. In
1673 * this mode a permission review is required before any of the
1674 * app components can run.
1675 * <p>
1676 * Input: {@link #EXTRA_PACKAGE_NAME} specifies the package whose
1677 * permissions will be reviewed (mandatory).
1678 * </p>
1679 * <p>
1680 * Input: {@link #EXTRA_INTENT} specifies a pending intent to
1681 * be fired after the permission review (optional).
1682 * </p>
1683 * <p>
1684 * Input: {@link #EXTRA_REMOTE_CALLBACK} specifies a callback to
1685 * be invoked after the permission review (optional).
1686 * </p>
1687 * <p>
1688 * Input: {@link #EXTRA_RESULT_NEEDED} specifies whether the intent
1689 * passed via {@link #EXTRA_INTENT} needs a result (optional).
1690 * </p>
1691 * <p>
1692 * Output: Nothing.
1693 * </p>
1694 *
1695 * @see #EXTRA_PACKAGE_NAME
1696 * @see #EXTRA_INTENT
1697 * @see #EXTRA_REMOTE_CALLBACK
1698 * @see #EXTRA_RESULT_NEEDED
1699 *
1700 * @hide
1701 */
Svet Ganovae0e03a2016-02-25 18:22:10 -08001702 @SystemApi
Svet Ganov9c165d72015-12-01 19:52:26 -08001703 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1704 public static final String ACTION_REVIEW_PERMISSIONS =
1705 "android.intent.action.REVIEW_PERMISSIONS";
1706
1707 /**
1708 * Intent extra: A callback for reporting remote result as a bundle.
1709 * <p>
1710 * Type: IRemoteCallback
1711 * </p>
1712 *
1713 * @hide
1714 */
Svet Ganovae0e03a2016-02-25 18:22:10 -08001715 @SystemApi
Svet Ganov9c165d72015-12-01 19:52:26 -08001716 public static final String EXTRA_REMOTE_CALLBACK = "android.intent.extra.REMOTE_CALLBACK";
1717
1718 /**
Svet Ganov3695b8a2015-03-24 16:30:25 -07001719 * Intent extra: An app package name.
1720 * <p>
1721 * Type: String
Svet Ganov0b316702015-05-23 13:25:11 -07001722 * </p>
Svet Ganov3695b8a2015-03-24 16:30:25 -07001723 *
Svet Ganov3695b8a2015-03-24 16:30:25 -07001724 */
Svet Ganov3695b8a2015-03-24 16:30:25 -07001725 public static final String EXTRA_PACKAGE_NAME = "android.intent.extra.PACKAGE_NAME";
1726
1727 /**
Todd Kennedye5195dd2016-10-19 15:29:19 -07001728 * Intent extra: An app split name.
1729 * <p>
1730 * Type: String
1731 * </p>
1732 * @hide
1733 */
1734 @SystemApi
1735 public static final String EXTRA_SPLIT_NAME = "android.intent.extra.SPLIT_NAME";
1736
1737 /**
Svet Ganov9c165d72015-12-01 19:52:26 -08001738 * Intent extra: An extra for specifying whether a result is needed.
1739 * <p>
1740 * Type: boolean
1741 * </p>
1742 *
1743 * @hide
1744 */
Svet Ganovae0e03a2016-02-25 18:22:10 -08001745 @SystemApi
Svet Ganov9c165d72015-12-01 19:52:26 -08001746 public static final String EXTRA_RESULT_NEEDED = "android.intent.extra.RESULT_NEEDED";
1747
1748 /**
Svet Ganov3695b8a2015-03-24 16:30:25 -07001749 * Activity action: Launch UI to manage which apps have a given permission.
1750 * <p>
1751 * Input: {@link #EXTRA_PERMISSION_NAME} specifies the permission access
1752 * to which will be managed by the launched UI.
1753 * </p>
1754 * <p>
1755 * Output: Nothing.
1756 * </p>
1757 *
1758 * @see #EXTRA_PERMISSION_NAME
1759 *
1760 * @hide
1761 */
Svet Ganovae0e03a2016-02-25 18:22:10 -08001762 @SystemApi
Svet Ganov3695b8a2015-03-24 16:30:25 -07001763 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1764 public static final String ACTION_MANAGE_PERMISSION_APPS =
1765 "android.intent.action.MANAGE_PERMISSION_APPS";
1766
1767 /**
1768 * Intent extra: The name of a permission.
1769 * <p>
1770 * Type: String
1771 * </p>
1772 *
1773 * @hide
1774 */
1775 @SystemApi
1776 public static final String EXTRA_PERMISSION_NAME = "android.intent.extra.PERMISSION_NAME";
1777
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001778 // ---------------------------------------------------------------------
1779 // ---------------------------------------------------------------------
1780 // Standard intent broadcast actions (see action variable).
1781
1782 /**
Jeff Brown037c33e2014-04-09 00:31:55 -07001783 * Broadcast Action: Sent when the device goes to sleep and becomes non-interactive.
1784 * <p>
1785 * For historical reasons, the name of this broadcast action refers to the power
1786 * state of the screen but it is actually sent in response to changes in the
1787 * overall interactive state of the device.
1788 * </p><p>
1789 * This broadcast is sent when the device becomes non-interactive which may have
1790 * nothing to do with the screen turning off. To determine the
1791 * actual state of the screen, use {@link android.view.Display#getState}.
1792 * </p><p>
1793 * See {@link android.os.PowerManager#isInteractive} for details.
1794 * </p>
Casey Hodbf6785c2015-03-17 15:59:39 -07001795 * You <em>cannot</em> receive this through components declared in
1796 * manifests, only by explicitly registering for it with
1797 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
1798 * Context.registerReceiver()}.
Tom Taylord4a47292009-12-21 13:59:18 -08001799 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001800 * <p class="note">This is a protected intent that can only be sent
1801 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001802 */
1803 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1804 public static final String ACTION_SCREEN_OFF = "android.intent.action.SCREEN_OFF";
Jeff Brown037c33e2014-04-09 00:31:55 -07001805
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001806 /**
Jeff Brown037c33e2014-04-09 00:31:55 -07001807 * Broadcast Action: Sent when the device wakes up and becomes interactive.
1808 * <p>
1809 * For historical reasons, the name of this broadcast action refers to the power
1810 * state of the screen but it is actually sent in response to changes in the
1811 * overall interactive state of the device.
1812 * </p><p>
1813 * This broadcast is sent when the device becomes interactive which may have
1814 * nothing to do with the screen turning on. To determine the
1815 * actual state of the screen, use {@link android.view.Display#getState}.
1816 * </p><p>
1817 * See {@link android.os.PowerManager#isInteractive} for details.
1818 * </p>
Casey Hodbf6785c2015-03-17 15:59:39 -07001819 * You <em>cannot</em> receive this through components declared in
1820 * manifests, only by explicitly registering for it with
1821 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
1822 * Context.registerReceiver()}.
Tom Taylord4a47292009-12-21 13:59:18 -08001823 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001824 * <p class="note">This is a protected intent that can only be sent
1825 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001826 */
1827 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1828 public static final String ACTION_SCREEN_ON = "android.intent.action.SCREEN_ON";
The Android Open Source Projectb2a3dd82009-03-09 11:52:12 -07001829
1830 /**
Dianne Hackbornbe87e2f2012-09-28 16:31:34 -07001831 * Broadcast Action: Sent after the system stops dreaming.
1832 *
1833 * <p class="note">This is a protected intent that can only be sent by the system.
1834 * It is only sent to registered receivers.</p>
1835 */
1836 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1837 public static final String ACTION_DREAMING_STOPPED = "android.intent.action.DREAMING_STOPPED";
1838
1839 /**
1840 * Broadcast Action: Sent after the system starts dreaming.
1841 *
1842 * <p class="note">This is a protected intent that can only be sent by the system.
1843 * It is only sent to registered receivers.</p>
1844 */
1845 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1846 public static final String ACTION_DREAMING_STARTED = "android.intent.action.DREAMING_STARTED";
1847
1848 /**
The Android Open Source Project10592532009-03-18 17:39:46 -07001849 * 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 -07001850 * keyguard is gone).
Tom Taylord4a47292009-12-21 13:59:18 -08001851 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001852 * <p class="note">This is a protected intent that can only be sent
1853 * by the system.
The Android Open Source Projectb2a3dd82009-03-09 11:52:12 -07001854 */
1855 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Dianne Hackborn1c633fc2009-12-08 19:45:14 -08001856 public static final String ACTION_USER_PRESENT = "android.intent.action.USER_PRESENT";
The Android Open Source Projectb2a3dd82009-03-09 11:52:12 -07001857
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001858 /**
1859 * Broadcast Action: The current time has changed. Sent every
Casey Hodbf6785c2015-03-17 15:59:39 -07001860 * minute. You <em>cannot</em> receive this through components declared
John Spurlock6098c5d2013-06-17 10:32:46 -04001861 * in manifests, only by explicitly registering for it with
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001862 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
1863 * Context.registerReceiver()}.
Tom Taylord4a47292009-12-21 13:59:18 -08001864 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001865 * <p class="note">This is a protected intent that can only be sent
1866 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001867 */
1868 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1869 public static final String ACTION_TIME_TICK = "android.intent.action.TIME_TICK";
1870 /**
1871 * Broadcast Action: The time was set.
1872 */
1873 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1874 public static final String ACTION_TIME_CHANGED = "android.intent.action.TIME_SET";
1875 /**
1876 * Broadcast Action: The date has changed.
1877 */
1878 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1879 public static final String ACTION_DATE_CHANGED = "android.intent.action.DATE_CHANGED";
1880 /**
1881 * Broadcast Action: The timezone has changed. The intent will have the following extra values:</p>
1882 * <ul>
1883 * <li><em>time-zone</em> - The java.util.TimeZone.getID() value identifying the new time zone.</li>
1884 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08001885 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001886 * <p class="note">This is a protected intent that can only be sent
1887 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001888 */
1889 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1890 public static final String ACTION_TIMEZONE_CHANGED = "android.intent.action.TIMEZONE_CHANGED";
1891 /**
Robert Greenwalt03595d02010-11-02 14:08:23 -07001892 * Clear DNS Cache Action: This is broadcast when networks have changed and old
1893 * DNS entries should be tossed.
1894 * @hide
1895 */
1896 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1897 public static final String ACTION_CLEAR_DNS_CACHE = "android.intent.action.CLEAR_DNS_CACHE";
1898 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001899 * Alarm Changed Action: This is broadcast when the AlarmClock
1900 * application's alarm is set or unset. It is used by the
1901 * AlarmClock application and the StatusBar service.
1902 * @hide
1903 */
1904 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1905 public static final String ACTION_ALARM_CHANGED = "android.intent.action.ALARM_CHANGED";
Jeff Sharkeybedbaa92015-12-02 16:42:25 -07001906
1907 /**
Jeff Sharkeycf3f0a12016-03-17 19:57:58 -06001908 * Broadcast Action: This is broadcast once, after the user has finished
1909 * booting, but while still in the "locked" state. It can be used to perform
1910 * application-specific initialization, such as installing alarms. You must
1911 * hold the {@link android.Manifest.permission#RECEIVE_BOOT_COMPLETED}
1912 * permission in order to receive this broadcast.
Jeff Sharkeybedbaa92015-12-02 16:42:25 -07001913 * <p>
Jeff Sharkeycf3f0a12016-03-17 19:57:58 -06001914 * This broadcast is sent immediately at boot by all devices (regardless of
1915 * direct boot support) running {@link android.os.Build.VERSION_CODES#N} or
1916 * higher. Upon receipt of this broadcast, the user is still locked and only
1917 * device-protected storage can be accessed safely. If you want to access
1918 * credential-protected storage, you need to wait for the user to be
1919 * unlocked (typically by entering their lock pattern or PIN for the first
1920 * time), after which the {@link #ACTION_USER_UNLOCKED} and
1921 * {@link #ACTION_BOOT_COMPLETED} broadcasts are sent.
1922 * <p>
1923 * To receive this broadcast, your receiver component must be marked as
1924 * being {@link ComponentInfo#directBootAware}.
Jeff Sharkeybedbaa92015-12-02 16:42:25 -07001925 * <p class="note">
1926 * This is a protected intent that can only be sent by the system.
Jeff Sharkeycf3f0a12016-03-17 19:57:58 -06001927 *
1928 * @see Context#createDeviceProtectedStorageContext()
Jeff Sharkeybedbaa92015-12-02 16:42:25 -07001929 */
1930 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1931 public static final String ACTION_LOCKED_BOOT_COMPLETED = "android.intent.action.LOCKED_BOOT_COMPLETED";
1932
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001933 /**
Jeff Sharkeycf3f0a12016-03-17 19:57:58 -06001934 * Broadcast Action: This is broadcast once, after the user has finished
1935 * booting. It can be used to perform application-specific initialization,
1936 * such as installing alarms. You must hold the
1937 * {@link android.Manifest.permission#RECEIVE_BOOT_COMPLETED} permission in
1938 * order to receive this broadcast.
1939 * <p>
1940 * This broadcast is sent at boot by all devices (both with and without
1941 * direct boot support). Upon receipt of this broadcast, the user is
1942 * unlocked and both device-protected and credential-protected storage can
1943 * accessed safely.
1944 * <p>
1945 * If you need to run while the user is still locked (before they've entered
1946 * their lock pattern or PIN for the first time), you can listen for the
1947 * {@link #ACTION_LOCKED_BOOT_COMPLETED} broadcast.
1948 * <p class="note">
1949 * This is a protected intent that can only be sent by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001950 */
1951 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1952 public static final String ACTION_BOOT_COMPLETED = "android.intent.action.BOOT_COMPLETED";
Jeff Sharkeybedbaa92015-12-02 16:42:25 -07001953
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001954 /**
1955 * Broadcast Action: This is broadcast when a user action should request a
1956 * temporary system dialog to dismiss. Some examples of temporary system
1957 * dialogs are the notification window-shade and the recent tasks dialog.
1958 */
1959 public static final String ACTION_CLOSE_SYSTEM_DIALOGS = "android.intent.action.CLOSE_SYSTEM_DIALOGS";
1960 /**
1961 * Broadcast Action: Trigger the download and eventual installation
1962 * of a package.
1963 * <p>Input: {@link #getData} is the URI of the package file to download.
Tom Taylord4a47292009-12-21 13:59:18 -08001964 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001965 * <p class="note">This is a protected intent that can only be sent
1966 * by the system.
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001967 *
1968 * @deprecated This constant has never been used.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001969 */
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001970 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001971 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1972 public static final String ACTION_PACKAGE_INSTALL = "android.intent.action.PACKAGE_INSTALL";
1973 /**
1974 * Broadcast Action: A new application package has been installed on the
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07001975 * device. The data contains the name of the package. Note that the
1976 * newly installed package does <em>not</em> receive this broadcast.
Jeff Sharkeyd0c6ccb2012-09-14 16:26:37 -07001977 * <p>May include the following extras:
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001978 * <ul>
1979 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the new package.
1980 * <li> {@link #EXTRA_REPLACING} is set to true if this is following
1981 * an {@link #ACTION_PACKAGE_REMOVED} broadcast for the same package.
1982 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08001983 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001984 * <p class="note">This is a protected intent that can only be sent
1985 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001986 */
1987 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1988 public static final String ACTION_PACKAGE_ADDED = "android.intent.action.PACKAGE_ADDED";
1989 /**
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07001990 * Broadcast Action: A new version of an application package has been
1991 * installed, replacing an existing version that was previously installed.
1992 * The data contains the name of the package.
Jeff Sharkeyd0c6ccb2012-09-14 16:26:37 -07001993 * <p>May include the following extras:
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07001994 * <ul>
1995 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the new package.
1996 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08001997 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001998 * <p class="note">This is a protected intent that can only be sent
1999 * by the system.
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07002000 */
2001 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2002 public static final String ACTION_PACKAGE_REPLACED = "android.intent.action.PACKAGE_REPLACED";
2003 /**
Dianne Hackborne7f97212011-02-24 14:40:20 -08002004 * Broadcast Action: A new version of your application has been installed
2005 * over an existing one. This is only sent to the application that was
2006 * replaced. It does not contain any additional data; to receive it, just
2007 * use an intent filter for this action.
2008 *
2009 * <p class="note">This is a protected intent that can only be sent
2010 * by the system.
2011 */
2012 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2013 public static final String ACTION_MY_PACKAGE_REPLACED = "android.intent.action.MY_PACKAGE_REPLACED";
2014 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002015 * Broadcast Action: An existing application package has been removed from
2016 * the device. The data contains the name of the package. The package
Trevor Johns682c24e2016-04-12 10:13:47 -07002017 * that is being removed does <em>not</em> receive this Intent.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002018 * <ul>
2019 * <li> {@link #EXTRA_UID} containing the integer uid previously assigned
2020 * to the package.
2021 * <li> {@link #EXTRA_DATA_REMOVED} is set to true if the entire
2022 * application -- data and code -- is being removed.
2023 * <li> {@link #EXTRA_REPLACING} is set to true if this will be followed
2024 * by an {@link #ACTION_PACKAGE_ADDED} broadcast for the same package.
2025 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002026 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002027 * <p class="note">This is a protected intent that can only be sent
2028 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002029 */
2030 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2031 public static final String ACTION_PACKAGE_REMOVED = "android.intent.action.PACKAGE_REMOVED";
2032 /**
Dianne Hackbornf9abb402011-08-10 15:00:59 -07002033 * Broadcast Action: An existing application package has been completely
2034 * removed from the device. The data contains the name of the package.
2035 * This is like {@link #ACTION_PACKAGE_REMOVED}, but only set when
2036 * {@link #EXTRA_DATA_REMOVED} is true and
2037 * {@link #EXTRA_REPLACING} is false of that broadcast.
2038 *
2039 * <ul>
2040 * <li> {@link #EXTRA_UID} containing the integer uid previously assigned
2041 * to the package.
2042 * </ul>
2043 *
2044 * <p class="note">This is a protected intent that can only be sent
2045 * by the system.
2046 */
2047 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2048 public static final String ACTION_PACKAGE_FULLY_REMOVED
2049 = "android.intent.action.PACKAGE_FULLY_REMOVED";
2050 /**
Trevor Johns682c24e2016-04-12 10:13:47 -07002051 * Broadcast Action: An existing application package has been changed (for
2052 * example, a component has been enabled or disabled). The data contains
2053 * the name of the package.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002054 * <ul>
2055 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
Dianne Hackborn86a72da2009-11-11 20:12:41 -08002056 * <li> {@link #EXTRA_CHANGED_COMPONENT_NAME_LIST} containing the class name
Dianne Hackbornfd7aded2013-01-22 17:10:23 -08002057 * of the changed components (or the package name itself).
Dianne Hackborn86a72da2009-11-11 20:12:41 -08002058 * <li> {@link #EXTRA_DONT_KILL_APP} containing boolean field to override the
2059 * default action of restarting the application.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002060 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002061 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002062 * <p class="note">This is a protected intent that can only be sent
2063 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002064 */
2065 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2066 public static final String ACTION_PACKAGE_CHANGED = "android.intent.action.PACKAGE_CHANGED";
2067 /**
Dianne Hackborn21f1bd12010-02-19 17:02:21 -08002068 * @hide
2069 * Broadcast Action: Ask system services if there is any reason to
2070 * restart the given package. The data contains the name of the
2071 * package.
2072 * <ul>
2073 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
2074 * <li> {@link #EXTRA_PACKAGES} String array of all packages to check.
2075 * </ul>
2076 *
2077 * <p class="note">This is a protected intent that can only be sent
2078 * by the system.
2079 */
Soonil Nagarkar0e8fd092015-02-10 10:37:36 -08002080 @SystemApi
Dianne Hackborn21f1bd12010-02-19 17:02:21 -08002081 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2082 public static final String ACTION_QUERY_PACKAGE_RESTART = "android.intent.action.QUERY_PACKAGE_RESTART";
2083 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002084 * Broadcast Action: The user has restarted a package, and all of its
2085 * processes have been killed. All runtime state
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002086 * associated with it (processes, alarms, notifications, etc) should
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07002087 * be removed. Note that the restarted package does <em>not</em>
2088 * receive this broadcast.
2089 * The data contains the name of the package.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002090 * <ul>
2091 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
2092 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002093 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002094 * <p class="note">This is a protected intent that can only be sent
2095 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002096 */
2097 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2098 public static final String ACTION_PACKAGE_RESTARTED = "android.intent.action.PACKAGE_RESTARTED";
2099 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002100 * Broadcast Action: The user has cleared the data of a package. This should
2101 * be preceded by {@link #ACTION_PACKAGE_RESTARTED}, after which all of
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07002102 * its persistent data is erased and this broadcast sent.
2103 * Note that the cleared package does <em>not</em>
2104 * receive this broadcast. The data contains the name of the package.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002105 * <ul>
2106 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
2107 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002108 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002109 * <p class="note">This is a protected intent that can only be sent
2110 * by the system.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002111 */
2112 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2113 public static final String ACTION_PACKAGE_DATA_CLEARED = "android.intent.action.PACKAGE_DATA_CLEARED";
2114 /**
Andrei Stingaceanu69d5ebc2016-01-14 12:59:03 +00002115 * Broadcast Action: Packages have been suspended.
2116 * <p>Includes the following extras:
2117 * <ul>
2118 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages which have been suspended
2119 * </ul>
2120 *
2121 * <p class="note">This is a protected intent that can only be sent
2122 * by the system. It is only sent to registered receivers.
2123 */
2124 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2125 public static final String ACTION_PACKAGES_SUSPENDED = "android.intent.action.PACKAGES_SUSPENDED";
2126 /**
2127 * Broadcast Action: Packages have been unsuspended.
2128 * <p>Includes the following extras:
2129 * <ul>
2130 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages which have been unsuspended
2131 * </ul>
2132 *
2133 * <p class="note">This is a protected intent that can only be sent
2134 * by the system. It is only sent to registered receivers.
2135 */
2136 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2137 public static final String ACTION_PACKAGES_UNSUSPENDED = "android.intent.action.PACKAGES_UNSUSPENDED";
2138 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002139 * Broadcast Action: A user ID has been removed from the system. The user
2140 * ID number is stored in the extra data under {@link #EXTRA_UID}.
Tom Taylord4a47292009-12-21 13:59:18 -08002141 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002142 * <p class="note">This is a protected intent that can only be sent
2143 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002144 */
2145 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2146 public static final String ACTION_UID_REMOVED = "android.intent.action.UID_REMOVED";
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002147
2148 /**
Trevor Johns682c24e2016-04-12 10:13:47 -07002149 * Broadcast Action: Sent to the installer package of an application when
2150 * that application is first launched (that is the first time it is moved
2151 * out of the stopped state). The data contains the name of the package.
Dianne Hackborne7f97212011-02-24 14:40:20 -08002152 *
2153 * <p class="note">This is a protected intent that can only be sent
2154 * by the system.
2155 */
2156 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2157 public static final String ACTION_PACKAGE_FIRST_LAUNCH = "android.intent.action.PACKAGE_FIRST_LAUNCH";
2158
2159 /**
Kenny Root5ab21572011-07-27 11:11:19 -07002160 * Broadcast Action: Sent to the system package verifier when a package
2161 * needs to be verified. The data contains the package URI.
2162 * <p class="note">
2163 * This is a protected intent that can only be sent by the system.
2164 * </p>
Kenny Root5ab21572011-07-27 11:11:19 -07002165 */
2166 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2167 public static final String ACTION_PACKAGE_NEEDS_VERIFICATION = "android.intent.action.PACKAGE_NEEDS_VERIFICATION";
2168
2169 /**
rich canningsd1b5cfc2012-08-29 14:49:51 -07002170 * Broadcast Action: Sent to the system package verifier when a package is
2171 * verified. The data contains the package URI.
2172 * <p class="note">
2173 * This is a protected intent that can only be sent by the system.
2174 */
2175 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2176 public static final String ACTION_PACKAGE_VERIFIED = "android.intent.action.PACKAGE_VERIFIED";
2177
2178 /**
Trevor Johns682c24e2016-04-12 10:13:47 -07002179 * Broadcast Action: Sent to the system intent filter verifier when an
2180 * intent filter needs to be verified. The data contains the filter data
2181 * hosts to be verified against.
Fabrice Di Meglio1c1b4712014-11-19 17:12:32 -08002182 * <p class="note">
2183 * This is a protected intent that can only be sent by the system.
2184 * </p>
2185 *
2186 * @hide
2187 */
2188 @SystemApi
2189 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2190 public static final String ACTION_INTENT_FILTER_NEEDS_VERIFICATION = "android.intent.action.INTENT_FILTER_NEEDS_VERIFICATION";
2191
2192 /**
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002193 * Broadcast Action: Resources for a set of packages (which were
2194 * previously unavailable) are currently
2195 * available since the media on which they exist is available.
2196 * The extra data {@link #EXTRA_CHANGED_PACKAGE_LIST} contains a
2197 * list of packages whose availability changed.
2198 * The extra data {@link #EXTRA_CHANGED_UID_LIST} contains a
2199 * list of uids of packages whose availability changed.
2200 * Note that the
2201 * packages in this list do <em>not</em> receive this broadcast.
2202 * The specified set of packages are now available on the system.
2203 * <p>Includes the following extras:
2204 * <ul>
2205 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages
2206 * whose resources(were previously unavailable) are currently available.
2207 * {@link #EXTRA_CHANGED_UID_LIST} is the set of uids of the
2208 * packages whose resources(were previously unavailable)
2209 * are currently available.
2210 * </ul>
2211 *
2212 * <p class="note">This is a protected intent that can only be sent
2213 * by the system.
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002214 */
2215 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08002216 public static final String ACTION_EXTERNAL_APPLICATIONS_AVAILABLE =
2217 "android.intent.action.EXTERNAL_APPLICATIONS_AVAILABLE";
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002218
2219 /**
2220 * Broadcast Action: Resources for a set of packages are currently
2221 * unavailable since the media on which they exist is unavailable.
2222 * The extra data {@link #EXTRA_CHANGED_PACKAGE_LIST} contains a
2223 * list of packages whose availability changed.
2224 * The extra data {@link #EXTRA_CHANGED_UID_LIST} contains a
2225 * list of uids of packages whose availability changed.
2226 * The specified set of packages can no longer be
2227 * launched and are practically unavailable on the system.
2228 * <p>Inclues the following extras:
2229 * <ul>
2230 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages
2231 * whose resources are no longer available.
2232 * {@link #EXTRA_CHANGED_UID_LIST} is the set of packages
2233 * whose resources are no longer available.
2234 * </ul>
2235 *
2236 * <p class="note">This is a protected intent that can only be sent
2237 * by the system.
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002238 */
2239 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08002240 public static final String ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE =
Joe Onorato8a051a42010-03-04 15:54:50 -05002241 "android.intent.action.EXTERNAL_APPLICATIONS_UNAVAILABLE";
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002242
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002243 /**
Makoto Onuki10305202016-07-14 18:14:08 -07002244 * Broadcast Action: preferred activities have changed *explicitly*.
2245 *
2246 * <p>Note there are cases where a preferred activity is invalidated *implicitly*, e.g.
2247 * when an app is installed or uninstalled, but in such cases this broadcast will *not*
2248 * be sent.
2249 *
2250 * {@link #EXTRA_USER_HANDLE} contains the user ID in question.
2251 *
2252 * @hide
2253 */
2254 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2255 public static final String ACTION_PREFERRED_ACTIVITY_CHANGED =
2256 "android.intent.action.ACTION_PREFERRED_ACTIVITY_CHANGED";
2257
2258
2259 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002260 * Broadcast Action: The current system wallpaper has changed. See
Scott Main8b2e0002009-09-29 18:17:31 -07002261 * {@link android.app.WallpaperManager} for retrieving the new wallpaper.
Dianne Hackbornc5bf7582012-04-25 19:12:07 -07002262 * This should <em>only</em> be used to determine when the wallpaper
2263 * has changed to show the new wallpaper to the user. You should certainly
2264 * never, in response to this, change the wallpaper or other attributes of
2265 * it such as the suggested size. That would be crazy, right? You'd cause
2266 * all kinds of loops, especially if other apps are doing similar things,
2267 * right? Of course. So please don't do this.
2268 *
2269 * @deprecated Modern applications should use
2270 * {@link android.view.WindowManager.LayoutParams#FLAG_SHOW_WALLPAPER
2271 * WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER} to have the wallpaper
2272 * shown behind their UI, rather than watching for this broadcast and
2273 * rendering the wallpaper on their own.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002274 */
Dianne Hackbornc5bf7582012-04-25 19:12:07 -07002275 @Deprecated @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002276 public static final String ACTION_WALLPAPER_CHANGED = "android.intent.action.WALLPAPER_CHANGED";
2277 /**
2278 * Broadcast Action: The current device {@link android.content.res.Configuration}
2279 * (orientation, locale, etc) has changed. When such a change happens, the
2280 * UIs (view hierarchy) will need to be rebuilt based on this new
2281 * information; for the most part, applications don't need to worry about
2282 * this, because the system will take care of stopping and restarting the
2283 * application to make sure it sees the new changes. Some system code that
2284 * can not be restarted will need to watch for this action and handle it
2285 * appropriately.
Tom Taylord4a47292009-12-21 13:59:18 -08002286 *
Dianne Hackborn362d5b92009-11-11 18:04:39 -08002287 * <p class="note">
Casey Hodbf6785c2015-03-17 15:59:39 -07002288 * You <em>cannot</em> receive this through components declared
Dianne Hackborn362d5b92009-11-11 18:04:39 -08002289 * in manifests, only by explicitly registering for it with
2290 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
2291 * Context.registerReceiver()}.
Tom Taylord4a47292009-12-21 13:59:18 -08002292 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002293 * <p class="note">This is a protected intent that can only be sent
2294 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002295 *
2296 * @see android.content.res.Configuration
2297 */
2298 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2299 public static final String ACTION_CONFIGURATION_CHANGED = "android.intent.action.CONFIGURATION_CHANGED";
2300 /**
Dianne Hackborn362d5b92009-11-11 18:04:39 -08002301 * Broadcast Action: The current device's locale has changed.
Tom Taylord4a47292009-12-21 13:59:18 -08002302 *
Dianne Hackborn362d5b92009-11-11 18:04:39 -08002303 * <p class="note">This is a protected intent that can only be sent
2304 * by the system.
2305 */
2306 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2307 public static final String ACTION_LOCALE_CHANGED = "android.intent.action.LOCALE_CHANGED";
2308 /**
Dianne Hackbornedd93162009-09-19 14:03:05 -07002309 * Broadcast Action: This is a <em>sticky broadcast</em> containing the
2310 * charging state, level, and other information about the battery.
2311 * See {@link android.os.BatteryManager} for documentation on the
2312 * contents of the Intent.
The Android Open Source Project10592532009-03-18 17:39:46 -07002313 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002314 * <p class="note">
Casey Hodbf6785c2015-03-17 15:59:39 -07002315 * You <em>cannot</em> receive this through components declared
Dianne Hackborn854060af2009-07-09 18:14:31 -07002316 * in manifests, only by explicitly registering for it with
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002317 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
Dianne Hackbornedd93162009-09-19 14:03:05 -07002318 * Context.registerReceiver()}. See {@link #ACTION_BATTERY_LOW},
2319 * {@link #ACTION_BATTERY_OKAY}, {@link #ACTION_POWER_CONNECTED},
2320 * and {@link #ACTION_POWER_DISCONNECTED} for distinct battery-related
2321 * broadcasts that are sent and can be received through manifest
2322 * receivers.
Tom Taylord4a47292009-12-21 13:59:18 -08002323 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002324 * <p class="note">This is a protected intent that can only be sent
2325 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002326 */
2327 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2328 public static final String ACTION_BATTERY_CHANGED = "android.intent.action.BATTERY_CHANGED";
2329 /**
2330 * Broadcast Action: Indicates low battery condition on the device.
2331 * This broadcast corresponds to the "Low battery warning" system dialog.
Tom Taylord4a47292009-12-21 13:59:18 -08002332 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002333 * <p class="note">This is a protected intent that can only be sent
2334 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002335 */
2336 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2337 public static final String ACTION_BATTERY_LOW = "android.intent.action.BATTERY_LOW";
2338 /**
Dianne Hackborn1dac2772009-06-26 18:16:48 -07002339 * Broadcast Action: Indicates the battery is now okay after being low.
2340 * This will be sent after {@link #ACTION_BATTERY_LOW} once the battery has
2341 * gone back up to an okay state.
Tom Taylord4a47292009-12-21 13:59:18 -08002342 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002343 * <p class="note">This is a protected intent that can only be sent
2344 * by the system.
Dianne Hackborn1dac2772009-06-26 18:16:48 -07002345 */
2346 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2347 public static final String ACTION_BATTERY_OKAY = "android.intent.action.BATTERY_OKAY";
2348 /**
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002349 * Broadcast Action: External power has been connected to the device.
2350 * This is intended for applications that wish to register specifically to this notification.
2351 * Unlike ACTION_BATTERY_CHANGED, applications will be woken for this and so do not have to
2352 * stay active to receive this notification. This action can be used to implement actions
2353 * that wait until power is available to trigger.
Tom Taylord4a47292009-12-21 13:59:18 -08002354 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002355 * <p class="note">This is a protected intent that can only be sent
2356 * by the system.
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002357 */
2358 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Dianne Hackbornfe240ec2009-08-27 12:51:11 -07002359 public static final String ACTION_POWER_CONNECTED = "android.intent.action.ACTION_POWER_CONNECTED";
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002360 /**
2361 * Broadcast Action: External power has been removed from the device.
2362 * This is intended for applications that wish to register specifically to this notification.
2363 * Unlike ACTION_BATTERY_CHANGED, applications will be woken for this and so do not have to
2364 * stay active to receive this notification. This action can be used to implement actions
Romain Guy4969af72009-06-17 10:53:19 -07002365 * that wait until power is available to trigger.
Tom Taylord4a47292009-12-21 13:59:18 -08002366 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002367 * <p class="note">This is a protected intent that can only be sent
2368 * by the system.
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002369 */
2370 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jean-Baptiste Queru1ef45642008-10-24 11:49:25 -07002371 public static final String ACTION_POWER_DISCONNECTED =
Dianne Hackbornfe240ec2009-08-27 12:51:11 -07002372 "android.intent.action.ACTION_POWER_DISCONNECTED";
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002373 /**
Dianne Hackborn55280a92009-05-07 15:53:46 -07002374 * Broadcast Action: Device is shutting down.
2375 * This is broadcast when the device is being shut down (completely turned
2376 * off, not sleeping). Once the broadcast is complete, the final shutdown
2377 * will proceed and all unsaved data lost. Apps will not normally need
Dianne Hackbornfe240ec2009-08-27 12:51:11 -07002378 * to handle this, since the foreground activity will be paused as well.
Tom Taylord4a47292009-12-21 13:59:18 -08002379 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002380 * <p class="note">This is a protected intent that can only be sent
2381 * by the system.
Dianne Hackborn57a7f592013-07-22 18:21:32 -07002382 * <p>May include the following extras:
2383 * <ul>
2384 * <li> {@link #EXTRA_SHUTDOWN_USERSPACE_ONLY} a boolean that is set to true if this
2385 * shutdown is only for userspace processes. If not set, assumed to be false.
2386 * </ul>
Dianne Hackborn55280a92009-05-07 15:53:46 -07002387 */
2388 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Romain Guy4969af72009-06-17 10:53:19 -07002389 public static final String ACTION_SHUTDOWN = "android.intent.action.ACTION_SHUTDOWN";
Dianne Hackborn55280a92009-05-07 15:53:46 -07002390 /**
Mike Lockwoodbad80e02009-07-30 01:21:08 -07002391 * Activity Action: Start this activity to request system shutdown.
2392 * The optional boolean extra field {@link #EXTRA_KEY_CONFIRM} can be set to true
Yusuke Sato705ffd12015-07-21 15:52:11 -07002393 * to request confirmation from the user before shutting down. The optional boolean
2394 * extra field {@link #EXTRA_USER_REQUESTED_SHUTDOWN} can be set to true to
2395 * indicate that the shutdown is requested by the user.
Mike Lockwoodbad80e02009-07-30 01:21:08 -07002396 *
2397 * <p class="note">This is a protected intent that can only be sent
2398 * by the system.
2399 *
2400 * {@hide}
2401 */
2402 public static final String ACTION_REQUEST_SHUTDOWN = "android.intent.action.ACTION_REQUEST_SHUTDOWN";
2403 /**
Dianne Hackbornedd93162009-09-19 14:03:05 -07002404 * Broadcast Action: A sticky broadcast that indicates low memory
2405 * condition on the device
Tom Taylord4a47292009-12-21 13:59:18 -08002406 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002407 * <p class="note">This is a protected intent that can only be sent
2408 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002409 */
2410 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2411 public static final String ACTION_DEVICE_STORAGE_LOW = "android.intent.action.DEVICE_STORAGE_LOW";
2412 /**
2413 * Broadcast Action: Indicates low memory condition on the device no longer exists
Tom Taylord4a47292009-12-21 13:59:18 -08002414 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002415 * <p class="note">This is a protected intent that can only be sent
2416 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002417 */
2418 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2419 public static final String ACTION_DEVICE_STORAGE_OK = "android.intent.action.DEVICE_STORAGE_OK";
2420 /**
Jake Hambybb371632010-08-23 18:16:48 -07002421 * Broadcast Action: A sticky broadcast that indicates a memory full
2422 * condition on the device. This is intended for activities that want
2423 * to be able to fill the data partition completely, leaving only
2424 * enough free space to prevent system-wide SQLite failures.
2425 *
2426 * <p class="note">This is a protected intent that can only be sent
2427 * by the system.
2428 *
2429 * {@hide}
2430 */
2431 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2432 public static final String ACTION_DEVICE_STORAGE_FULL = "android.intent.action.DEVICE_STORAGE_FULL";
2433 /**
2434 * Broadcast Action: Indicates memory full condition on the device
2435 * no longer exists.
2436 *
2437 * <p class="note">This is a protected intent that can only be sent
2438 * by the system.
2439 *
2440 * {@hide}
2441 */
2442 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2443 public static final String ACTION_DEVICE_STORAGE_NOT_FULL = "android.intent.action.DEVICE_STORAGE_NOT_FULL";
2444 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002445 * Broadcast Action: Indicates low memory condition notification acknowledged by user
2446 * and package management should be started.
2447 * This is triggered by the user from the ACTION_DEVICE_STORAGE_LOW
2448 * notification.
2449 */
2450 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2451 public static final String ACTION_MANAGE_PACKAGE_STORAGE = "android.intent.action.MANAGE_PACKAGE_STORAGE";
2452 /**
2453 * Broadcast Action: The device has entered USB Mass Storage mode.
2454 * This is used mainly for the USB Settings panel.
2455 * Apps should listen for ACTION_MEDIA_MOUNTED and ACTION_MEDIA_UNMOUNTED broadcasts to be notified
2456 * when the SD card file system is mounted or unmounted
Mike Lockwood7e4db372011-06-07 11:23:44 -07002457 * @deprecated replaced by android.os.storage.StorageEventListener
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002458 */
Mike Lockwoodda85e522011-06-07 09:08:34 -07002459 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002460 public static final String ACTION_UMS_CONNECTED = "android.intent.action.UMS_CONNECTED";
2461
2462 /**
2463 * Broadcast Action: The device has exited USB Mass Storage mode.
2464 * This is used mainly for the USB Settings panel.
2465 * Apps should listen for ACTION_MEDIA_MOUNTED and ACTION_MEDIA_UNMOUNTED broadcasts to be notified
2466 * when the SD card file system is mounted or unmounted
Mike Lockwood7e4db372011-06-07 11:23:44 -07002467 * @deprecated replaced by android.os.storage.StorageEventListener
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002468 */
Mike Lockwoodda85e522011-06-07 09:08:34 -07002469 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002470 public static final String ACTION_UMS_DISCONNECTED = "android.intent.action.UMS_DISCONNECTED";
2471
2472 /**
2473 * Broadcast Action: External media has been removed.
2474 * The path to the mount point for the removed media is contained in the Intent.mData field.
2475 */
2476 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2477 public static final String ACTION_MEDIA_REMOVED = "android.intent.action.MEDIA_REMOVED";
2478
2479 /**
2480 * Broadcast Action: External media is present, but not mounted at its mount point.
suyi Yuanbe7af832013-01-04 21:21:59 +08002481 * 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 -07002482 */
2483 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2484 public static final String ACTION_MEDIA_UNMOUNTED = "android.intent.action.MEDIA_UNMOUNTED";
2485
2486 /**
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08002487 * Broadcast Action: External media is present, and being disk-checked
2488 * 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 -08002489 */
2490 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2491 public static final String ACTION_MEDIA_CHECKING = "android.intent.action.MEDIA_CHECKING";
2492
2493 /**
2494 * Broadcast Action: External media is present, but is using an incompatible fs (or is blank)
2495 * 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 -08002496 */
2497 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2498 public static final String ACTION_MEDIA_NOFS = "android.intent.action.MEDIA_NOFS";
2499
2500 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002501 * Broadcast Action: External media is present and mounted at its mount point.
suyi Yuanbe7af832013-01-04 21:21:59 +08002502 * 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 -07002503 * The Intent contains an extra with name "read-only" and Boolean value to indicate if the
2504 * media was mounted read only.
2505 */
2506 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2507 public static final String ACTION_MEDIA_MOUNTED = "android.intent.action.MEDIA_MOUNTED";
2508
2509 /**
2510 * Broadcast Action: External media is unmounted because it is being shared via USB mass storage.
Mike Lockwoodbf2dd442010-03-03 06:16:52 -05002511 * 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 -07002512 */
2513 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2514 public static final String ACTION_MEDIA_SHARED = "android.intent.action.MEDIA_SHARED";
2515
2516 /**
Mike Lockwoodbf2dd442010-03-03 06:16:52 -05002517 * Broadcast Action: External media is no longer being shared via USB mass storage.
2518 * The path to the mount point for the previously shared media is contained in the Intent.mData field.
2519 *
2520 * @hide
2521 */
2522 public static final String ACTION_MEDIA_UNSHARED = "android.intent.action.MEDIA_UNSHARED";
2523
2524 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002525 * Broadcast Action: External media was removed from SD card slot, but mount point was not unmounted.
2526 * The path to the mount point for the removed media is contained in the Intent.mData field.
2527 */
2528 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2529 public static final String ACTION_MEDIA_BAD_REMOVAL = "android.intent.action.MEDIA_BAD_REMOVAL";
2530
2531 /**
2532 * Broadcast Action: External media is present but cannot be mounted.
suyi Yuanbe7af832013-01-04 21:21:59 +08002533 * 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 -07002534 */
2535 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2536 public static final String ACTION_MEDIA_UNMOUNTABLE = "android.intent.action.MEDIA_UNMOUNTABLE";
2537
2538 /**
2539 * Broadcast Action: User has expressed the desire to remove the external storage media.
2540 * Applications should close all files they have open within the mount point when they receive this intent.
2541 * The path to the mount point for the media to be ejected is contained in the Intent.mData field.
2542 */
2543 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2544 public static final String ACTION_MEDIA_EJECT = "android.intent.action.MEDIA_EJECT";
2545
2546 /**
2547 * Broadcast Action: The media scanner has started scanning a directory.
2548 * The path to the directory being scanned is contained in the Intent.mData field.
2549 */
2550 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2551 public static final String ACTION_MEDIA_SCANNER_STARTED = "android.intent.action.MEDIA_SCANNER_STARTED";
2552
2553 /**
2554 * Broadcast Action: The media scanner has finished scanning a directory.
2555 * The path to the scanned directory is contained in the Intent.mData field.
2556 */
2557 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2558 public static final String ACTION_MEDIA_SCANNER_FINISHED = "android.intent.action.MEDIA_SCANNER_FINISHED";
2559
2560 /**
2561 * Broadcast Action: Request the media scanner to scan a file and add it to the media database.
2562 * The path to the file is contained in the Intent.mData field.
2563 */
2564 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2565 public static final String ACTION_MEDIA_SCANNER_SCAN_FILE = "android.intent.action.MEDIA_SCANNER_SCAN_FILE";
2566
2567 /**
2568 * Broadcast Action: The "Media Button" was pressed. Includes a single
2569 * extra field, {@link #EXTRA_KEY_EVENT}, containing the key event that
2570 * caused the broadcast.
2571 */
2572 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2573 public static final String ACTION_MEDIA_BUTTON = "android.intent.action.MEDIA_BUTTON";
2574
2575 /**
2576 * Broadcast Action: The "Camera Button" was pressed. Includes a single
2577 * extra field, {@link #EXTRA_KEY_EVENT}, containing the key event that
2578 * caused the broadcast.
2579 */
2580 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2581 public static final String ACTION_CAMERA_BUTTON = "android.intent.action.CAMERA_BUTTON";
2582
2583 // *** NOTE: @todo(*) The following really should go into a more domain-specific
2584 // location; they are not general-purpose actions.
2585
2586 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09002587 * Broadcast Action: A GTalk connection has been established.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002588 */
2589 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2590 public static final String ACTION_GTALK_SERVICE_CONNECTED =
2591 "android.intent.action.GTALK_CONNECTED";
2592
2593 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09002594 * Broadcast Action: A GTalk connection has been disconnected.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002595 */
2596 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2597 public static final String ACTION_GTALK_SERVICE_DISCONNECTED =
2598 "android.intent.action.GTALK_DISCONNECTED";
The Android Open Source Project10592532009-03-18 17:39:46 -07002599
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08002600 /**
2601 * Broadcast Action: An input method has been changed.
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08002602 */
2603 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2604 public static final String ACTION_INPUT_METHOD_CHANGED =
2605 "android.intent.action.INPUT_METHOD_CHANGED";
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002606
2607 /**
2608 * <p>Broadcast Action: The user has switched the phone into or out of Airplane Mode. One or
2609 * more radios have been turned off or on. The intent will have the following extra value:</p>
2610 * <ul>
2611 * <li><em>state</em> - A boolean value indicating whether Airplane Mode is on. If true,
2612 * then cell radio and possibly other radios such as bluetooth or WiFi may have also been
2613 * turned off</li>
2614 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002615 *
Peng Xua35b5532016-01-20 00:05:45 -08002616 * <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 -07002617 */
2618 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2619 public static final String ACTION_AIRPLANE_MODE_CHANGED = "android.intent.action.AIRPLANE_MODE";
2620
2621 /**
2622 * Broadcast Action: Some content providers have parts of their namespace
2623 * where they publish new events or items that the user may be especially
2624 * interested in. For these things, they may broadcast this action when the
2625 * set of interesting items change.
2626 *
2627 * For example, GmailProvider sends this notification when the set of unread
2628 * mail in the inbox changes.
2629 *
2630 * <p>The data of the intent identifies which part of which provider
2631 * changed. When queried through the content resolver, the data URI will
2632 * return the data set in question.
2633 *
2634 * <p>The intent will have the following extra values:
2635 * <ul>
2636 * <li><em>count</em> - The number of items in the data set. This is the
2637 * same as the number of items in the cursor returned by querying the
2638 * data URI. </li>
2639 * </ul>
2640 *
2641 * This intent will be sent at boot (if the count is non-zero) and when the
2642 * data set changes. It is possible for the data set to change without the
2643 * count changing (for example, if a new unread message arrives in the same
2644 * sync operation in which a message is archived). The phone should still
2645 * ring/vibrate/etc as normal in this case.
2646 */
2647 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2648 public static final String ACTION_PROVIDER_CHANGED =
2649 "android.intent.action.PROVIDER_CHANGED";
2650
2651 /**
2652 * Broadcast Action: Wired Headset plugged in or unplugged.
2653 *
Jean-Michel Trivic5258432014-08-27 15:46:54 -07002654 * Same as {@link android.media.AudioManager#ACTION_HEADSET_PLUG}, to be consulted for value
2655 * and documentation.
2656 * <p>If the minimum SDK version of your application is
Dianne Hackborn955d8d62014-10-07 20:17:19 -07002657 * {@link android.os.Build.VERSION_CODES#LOLLIPOP}, it is recommended to refer
Jean-Michel Trivic5258432014-08-27 15:46:54 -07002658 * to the <code>AudioManager</code> constant in your receiver registration code instead.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002659 */
2660 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jean-Michel Trivic5258432014-08-27 15:46:54 -07002661 public static final String ACTION_HEADSET_PLUG = android.media.AudioManager.ACTION_HEADSET_PLUG;
Eric Laurent59f48272012-04-05 19:42:21 -07002662
2663 /**
Joe Onorato9cdffa12011-04-06 18:27:27 -07002664 * <p>Broadcast Action: The user has switched on advanced settings in the settings app:</p>
2665 * <ul>
2666 * <li><em>state</em> - A boolean value indicating whether the settings is on or off.</li>
2667 * </ul>
2668 *
2669 * <p class="note">This is a protected intent that can only be sent
2670 * by the system.
2671 *
2672 * @hide
2673 */
2674 //@SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2675 public static final String ACTION_ADVANCED_SETTINGS_CHANGED
2676 = "android.intent.action.ADVANCED_SETTINGS";
2677
2678 /**
Robin Lee66e5d962014-04-09 16:44:21 +01002679 * Broadcast Action: Sent after application restrictions are changed.
2680 *
2681 * <p class="note">This is a protected intent that can only be sent
2682 * by the system.</p>
2683 */
2684 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2685 public static final String ACTION_APPLICATION_RESTRICTIONS_CHANGED =
2686 "android.intent.action.APPLICATION_RESTRICTIONS_CHANGED";
2687
2688 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002689 * Broadcast Action: An outgoing call is about to be placed.
2690 *
Dirk Dougherty367ce902013-05-28 17:37:12 -07002691 * <p>The Intent will have the following extra value:</p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002692 * <ul>
The Android Open Source Project10592532009-03-18 17:39:46 -07002693 * <li><em>{@link android.content.Intent#EXTRA_PHONE_NUMBER}</em> -
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002694 * the phone number originally intended to be dialed.</li>
2695 * </ul>
2696 * <p>Once the broadcast is finished, the resultData is used as the actual
2697 * number to call. If <code>null</code>, no call will be placed.</p>
The Android Open Source Project10592532009-03-18 17:39:46 -07002698 * <p>It is perfectly acceptable for multiple receivers to process the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002699 * outgoing call in turn: for example, a parental control application
2700 * might verify that the user is authorized to place the call at that
2701 * time, then a number-rewriting application might add an area code if
2702 * one was not specified.</p>
2703 * <p>For consistency, any receiver whose purpose is to prohibit phone
2704 * calls should have a priority of 0, to ensure it will see the final
2705 * phone number to be dialed.
The Android Open Source Project10592532009-03-18 17:39:46 -07002706 * Any receiver whose purpose is to rewrite phone numbers to be called
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002707 * should have a positive priority.
2708 * Negative priorities are reserved for the system for this broadcast;
2709 * using them may cause problems.</p>
Dirk Dougherty932fbcc2013-05-29 15:19:14 -07002710 * <p>Any BroadcastReceiver receiving this Intent <em>must not</em>
2711 * abort the broadcast.</p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002712 * <p>Emergency calls cannot be intercepted using this mechanism, and
2713 * other calls cannot be modified to call emergency numbers using this
2714 * mechanism.
Santos Cordonba701362013-05-17 14:48:54 -07002715 * <p>Some apps (such as VoIP apps) may want to redirect the outgoing
2716 * call to use their own service instead. Those apps should first prevent
2717 * the call from being placed by setting resultData to <code>null</code>
2718 * and then start their own app to make the call.
The Android Open Source Project10592532009-03-18 17:39:46 -07002719 * <p>You must hold the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002720 * {@link android.Manifest.permission#PROCESS_OUTGOING_CALLS}
2721 * permission to receive this Intent.</p>
Tom Taylord4a47292009-12-21 13:59:18 -08002722 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002723 * <p class="note">This is a protected intent that can only be sent
2724 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002725 */
2726 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2727 public static final String ACTION_NEW_OUTGOING_CALL =
2728 "android.intent.action.NEW_OUTGOING_CALL";
2729
2730 /**
2731 * Broadcast Action: Have the device reboot. This is only for use by
2732 * system code.
Tom Taylord4a47292009-12-21 13:59:18 -08002733 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002734 * <p class="note">This is a protected intent that can only be sent
2735 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002736 */
2737 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2738 public static final String ACTION_REBOOT =
2739 "android.intent.action.REBOOT";
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002740
Wei Huang97ecc9c2009-05-11 17:44:20 -07002741 /**
Dianne Hackborn7299c412010-03-04 18:41:49 -08002742 * Broadcast Action: A sticky broadcast for changes in the physical
2743 * docking state of the device.
Tobias Haamel154f7a12010-02-17 11:56:39 -08002744 *
2745 * <p>The intent will have the following extra values:
2746 * <ul>
2747 * <li><em>{@link #EXTRA_DOCK_STATE}</em> - the current dock
Dianne Hackborn7299c412010-03-04 18:41:49 -08002748 * state, indicating which dock the device is physically in.</li>
Tobias Haamel154f7a12010-02-17 11:56:39 -08002749 * </ul>
Dianne Hackborn7299c412010-03-04 18:41:49 -08002750 * <p>This is intended for monitoring the current physical dock state.
2751 * See {@link android.app.UiModeManager} for the normal API dealing with
2752 * dock mode changes.
Dianne Hackbornedd93162009-09-19 14:03:05 -07002753 */
2754 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2755 public static final String ACTION_DOCK_EVENT =
2756 "android.intent.action.DOCK_EVENT";
2757
2758 /**
Svetoslavb3038ec2013-02-13 14:39:30 -08002759 * Broadcast Action: A broadcast when idle maintenance can be started.
2760 * This means that the user is not interacting with the device and is
2761 * not expected to do so soon. Typical use of the idle maintenance is
2762 * to perform somehow expensive tasks that can be postponed at a moment
2763 * when they will not degrade user experience.
2764 * <p>
2765 * <p class="note">In order to keep the device responsive in case of an
2766 * unexpected user interaction, implementations of a maintenance task
2767 * should be interruptible. In such a scenario a broadcast with action
2768 * {@link #ACTION_IDLE_MAINTENANCE_END} will be sent. In other words, you
2769 * should not do the maintenance work in
2770 * {@link BroadcastReceiver#onReceive(Context, Intent)}, rather start a
2771 * maintenance service by {@link Context#startService(Intent)}. Also
2772 * you should hold a wake lock while your maintenance service is running
2773 * to prevent the device going to sleep.
2774 * </p>
2775 * <p>
2776 * <p class="note">This is a protected intent that can only be sent by
2777 * the system.
2778 * </p>
2779 *
2780 * @see #ACTION_IDLE_MAINTENANCE_END
Svetoslav6a08a122013-05-03 11:24:26 -07002781 *
2782 * @hide
Svetoslavb3038ec2013-02-13 14:39:30 -08002783 */
2784 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2785 public static final String ACTION_IDLE_MAINTENANCE_START =
2786 "android.intent.action.ACTION_IDLE_MAINTENANCE_START";
2787
2788 /**
2789 * Broadcast Action: A broadcast when idle maintenance should be stopped.
2790 * This means that the user was not interacting with the device as a result
2791 * of which a broadcast with action {@link #ACTION_IDLE_MAINTENANCE_START}
2792 * was sent and now the user started interacting with the device. Typical
2793 * use of the idle maintenance is to perform somehow expensive tasks that
2794 * can be postponed at a moment when they will not degrade user experience.
2795 * <p>
2796 * <p class="note">In order to keep the device responsive in case of an
2797 * unexpected user interaction, implementations of a maintenance task
2798 * should be interruptible. Hence, on receiving a broadcast with this
2799 * action, the maintenance task should be interrupted as soon as possible.
2800 * In other words, you should not do the maintenance work in
2801 * {@link BroadcastReceiver#onReceive(Context, Intent)}, rather stop the
2802 * maintenance service that was started on receiving of
2803 * {@link #ACTION_IDLE_MAINTENANCE_START}.Also you should release the wake
2804 * lock you acquired when your maintenance service started.
2805 * </p>
2806 * <p class="note">This is a protected intent that can only be sent
2807 * by the system.
2808 *
2809 * @see #ACTION_IDLE_MAINTENANCE_START
Svetoslav6a08a122013-05-03 11:24:26 -07002810 *
2811 * @hide
Svetoslavb3038ec2013-02-13 14:39:30 -08002812 */
2813 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2814 public static final String ACTION_IDLE_MAINTENANCE_END =
2815 "android.intent.action.ACTION_IDLE_MAINTENANCE_END";
2816
2817 /**
Wei Huang97ecc9c2009-05-11 17:44:20 -07002818 * Broadcast Action: a remote intent is to be broadcasted.
2819 *
2820 * A remote intent is used for remote RPC between devices. The remote intent
2821 * is serialized and sent from one device to another device. The receiving
2822 * device parses the remote intent and broadcasts it. Note that anyone can
2823 * broadcast a remote intent. However, if the intent receiver of the remote intent
2824 * does not trust intent broadcasts from arbitrary intent senders, it should require
2825 * the sender to hold certain permissions so only trusted sender's broadcast will be
2826 * let through.
Dianne Hackbornedd93162009-09-19 14:03:05 -07002827 * @hide
Wei Huang97ecc9c2009-05-11 17:44:20 -07002828 */
2829 public static final String ACTION_REMOTE_INTENT =
Costin Manolache8d83f9e2010-05-12 16:04:10 -07002830 "com.google.android.c2dm.intent.RECEIVE";
Wei Huang97ecc9c2009-05-11 17:44:20 -07002831
Dianne Hackborn9acc0302009-08-25 00:27:12 -07002832 /**
Jeff Sharkeybd91e2f2016-03-22 15:32:31 -06002833 * Broadcast Action: This is broadcast once when the user is booting after a
2834 * system update. It can be used to perform cleanup or upgrades after a
2835 * system update.
2836 * <p>
2837 * This broadcast is sent after the {@link #ACTION_LOCKED_BOOT_COMPLETED}
2838 * broadcast but before the {@link #ACTION_BOOT_COMPLETED} broadcast. It's
2839 * only sent when the {@link Build#FINGERPRINT} has changed, and it's only
2840 * sent to receivers in the system image.
Dianne Hackborn9acc0302009-08-25 00:27:12 -07002841 *
Dianne Hackborn9acc0302009-08-25 00:27:12 -07002842 * @hide
2843 */
2844 public static final String ACTION_PRE_BOOT_COMPLETED =
2845 "android.intent.action.PRE_BOOT_COMPLETED";
2846
Amith Yamasani13593602012-03-22 16:16:17 -07002847 /**
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08002848 * Broadcast to a specific application to query any supported restrictions to impose
Amith Yamasani7e99bc02013-04-16 18:24:51 -07002849 * on restricted users. The broadcast intent contains an extra
2850 * {@link #EXTRA_RESTRICTIONS_BUNDLE} with the currently persisted
2851 * restrictions as a Bundle of key/value pairs. The value types can be Boolean, String or
2852 * String[] depending on the restriction type.<p/>
2853 * The response should contain an extra {@link #EXTRA_RESTRICTIONS_LIST},
Amith Yamasani86118ba2013-03-28 14:33:16 -07002854 * which is of type <code>ArrayList&lt;RestrictionEntry&gt;</code>. It can also
2855 * contain an extra {@link #EXTRA_RESTRICTIONS_INTENT}, which is of type <code>Intent</code>.
2856 * The activity specified by that intent will be launched for a result which must contain
Amith Yamasani3b458ad2013-04-18 18:40:07 -07002857 * one of the extras {@link #EXTRA_RESTRICTIONS_LIST} or {@link #EXTRA_RESTRICTIONS_BUNDLE}.
2858 * The keys and values of the returned restrictions will be persisted.
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08002859 * @see RestrictionEntry
2860 */
2861 public static final String ACTION_GET_RESTRICTION_ENTRIES =
2862 "android.intent.action.GET_RESTRICTION_ENTRIES";
2863
2864 /**
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002865 * Sent the first time a user is starting, to allow system apps to
2866 * perform one time initialization. (This will not be seen by third
2867 * party applications because a newly initialized user does not have any
2868 * third party applications installed for it.) This is sent early in
2869 * starting the user, around the time the home app is started, before
Dianne Hackborn36d337a2012-10-08 14:33:47 -07002870 * {@link #ACTION_BOOT_COMPLETED} is sent. This is sent as a foreground
2871 * broadcast, since it is part of a visible user interaction; be as quick
2872 * as possible when handling it.
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002873 */
2874 public static final String ACTION_USER_INITIALIZE =
2875 "android.intent.action.USER_INITIALIZE";
2876
2877 /**
2878 * Sent when a user switch is happening, causing the process's user to be
2879 * brought to the foreground. This is only sent to receivers registered
2880 * through {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
2881 * Context.registerReceiver}. It is sent to the user that is going to the
Dianne Hackborn36d337a2012-10-08 14:33:47 -07002882 * foreground. This is sent as a foreground
2883 * broadcast, since it is part of a visible user interaction; be as quick
2884 * as possible when handling it.
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002885 */
2886 public static final String ACTION_USER_FOREGROUND =
2887 "android.intent.action.USER_FOREGROUND";
2888
2889 /**
2890 * Sent when a user switch is happening, causing the process's user to be
2891 * sent to the background. This is only sent to receivers registered
2892 * through {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
2893 * Context.registerReceiver}. It is sent to the user that is going to the
Dianne Hackborn36d337a2012-10-08 14:33:47 -07002894 * background. This is sent as a foreground
2895 * broadcast, since it is part of a visible user interaction; be as quick
2896 * as possible when handling it.
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002897 */
2898 public static final String ACTION_USER_BACKGROUND =
2899 "android.intent.action.USER_BACKGROUND";
2900
2901 /**
Dianne Hackborn36d337a2012-10-08 14:33:47 -07002902 * Broadcast sent to the system when a user is added. Carries an extra
2903 * EXTRA_USER_HANDLE that has the userHandle of the new user. It is sent to
2904 * all running users. You must hold
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002905 * {@link android.Manifest.permission#MANAGE_USERS} to receive this broadcast.
Amith Yamasani13593602012-03-22 16:16:17 -07002906 * @hide
2907 */
2908 public static final String ACTION_USER_ADDED =
2909 "android.intent.action.USER_ADDED";
2910
2911 /**
Dianne Hackborn36d337a2012-10-08 14:33:47 -07002912 * Broadcast sent by the system when a user is started. Carries an extra
2913 * EXTRA_USER_HANDLE that has the userHandle of the user. This is only sent to
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002914 * registered receivers, not manifest receivers. It is sent to the user
Dianne Hackborn36d337a2012-10-08 14:33:47 -07002915 * that has been started. 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 * @hide
2919 */
2920 public static final String ACTION_USER_STARTED =
2921 "android.intent.action.USER_STARTED";
2922
2923 /**
Dianne Hackborn36d337a2012-10-08 14:33:47 -07002924 * Broadcast sent when a user is in the process of starting. Carries an extra
2925 * EXTRA_USER_HANDLE that has the userHandle of the user. This is only
2926 * sent to registered receivers, not manifest receivers. It is sent to all
2927 * users (including the one that is being started). You must hold
2928 * {@link android.Manifest.permission#INTERACT_ACROSS_USERS} to receive
2929 * this broadcast. This is sent as a background broadcast, since
2930 * its result is not part of the primary UX flow; to safely keep track of
2931 * started/stopped state of a user you can use this in conjunction with
2932 * {@link #ACTION_USER_STOPPING}. It is <b>not</b> generally safe to use with
2933 * other user state broadcasts since those are foreground broadcasts so can
2934 * execute in a different order.
2935 * @hide
2936 */
2937 public static final String ACTION_USER_STARTING =
2938 "android.intent.action.USER_STARTING";
2939
2940 /**
2941 * Broadcast sent when a user is going to be stopped. Carries an extra
2942 * EXTRA_USER_HANDLE that has the userHandle of the user. This is only
2943 * sent to registered receivers, not manifest receivers. It is sent to all
2944 * users (including the one that is being stopped). You must hold
2945 * {@link android.Manifest.permission#INTERACT_ACROSS_USERS} to receive
2946 * this broadcast. The user will not stop until all receivers have
2947 * handled the broadcast. This is sent as a background broadcast, since
2948 * its result is not part of the primary UX flow; to safely keep track of
2949 * started/stopped state of a user you can use this in conjunction with
2950 * {@link #ACTION_USER_STARTING}. It is <b>not</b> generally safe to use with
2951 * other user state broadcasts since those are foreground broadcasts so can
2952 * execute in a different order.
2953 * @hide
2954 */
2955 public static final String ACTION_USER_STOPPING =
2956 "android.intent.action.USER_STOPPING";
2957
2958 /**
2959 * Broadcast sent to the system when a user is stopped. Carries an extra
2960 * EXTRA_USER_HANDLE that has the userHandle of the user. This is similar to
2961 * {@link #ACTION_PACKAGE_RESTARTED}, but for an entire user instead of a
2962 * specific package. This is only sent to registered receivers, not manifest
2963 * receivers. It is sent to all running users <em>except</em> the one that
2964 * has just been stopped (which is no longer running).
Dianne Hackborn80a4af22012-08-27 19:18:31 -07002965 * @hide
2966 */
2967 public static final String ACTION_USER_STOPPED =
2968 "android.intent.action.USER_STOPPED";
2969
2970 /**
Amith Yamasani2a003292012-08-14 18:25:45 -07002971 * 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 -07002972 * the userHandle of the user. It is sent to all running users except the
Amith Yamasanidb6a14c2012-10-17 21:16:52 -07002973 * one that has been removed. The user will not be completely removed until all receivers have
2974 * handled the broadcast. You must hold
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002975 * {@link android.Manifest.permission#MANAGE_USERS} to receive this broadcast.
Amith Yamasani13593602012-03-22 16:16:17 -07002976 * @hide
2977 */
2978 public static final String ACTION_USER_REMOVED =
2979 "android.intent.action.USER_REMOVED";
2980
2981 /**
Amith Yamasani2a003292012-08-14 18:25:45 -07002982 * Broadcast sent to the system when the user switches. Carries an extra EXTRA_USER_HANDLE that has
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002983 * the userHandle of the user to become the current one. This is only sent to
2984 * registered receivers, not manifest receivers. It is sent to all running users.
2985 * You must hold
2986 * {@link android.Manifest.permission#MANAGE_USERS} to receive this broadcast.
Amith Yamasani13593602012-03-22 16:16:17 -07002987 * @hide
2988 */
2989 public static final String ACTION_USER_SWITCHED =
2990 "android.intent.action.USER_SWITCHED";
2991
Amith Yamasanie928d7d2012-09-17 21:46:51 -07002992 /**
Jeff Sharkey8924e872015-11-30 12:52:10 -07002993 * Broadcast Action: Sent when the credential-encrypted private storage has
2994 * become unlocked for the target user. This is only sent to registered
2995 * receivers, not manifest receivers.
2996 */
2997 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2998 public static final String ACTION_USER_UNLOCKED = "android.intent.action.USER_UNLOCKED";
2999
3000 /**
Amith Yamasanie928d7d2012-09-17 21:46:51 -07003001 * Broadcast sent to the system when a user's information changes. Carries an extra
3002 * {@link #EXTRA_USER_HANDLE} to indicate which user's information changed.
Amith Yamasani6fc1d4e2013-05-08 16:43:58 -07003003 * This is only sent to registered receivers, not manifest receivers. It is sent to all users.
Amith Yamasanie928d7d2012-09-17 21:46:51 -07003004 * @hide
3005 */
3006 public static final String ACTION_USER_INFO_CHANGED =
3007 "android.intent.action.USER_INFO_CHANGED";
3008
Daniel Sandler2e7d25b2012-10-01 16:43:26 -04003009 /**
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01003010 * Broadcast sent to the primary user when an associated managed profile is added (the profile
3011 * was created and is ready to be used). Carries an extra {@link #EXTRA_USER} that specifies
Adam Connorsd4b584e2014-06-09 13:55:47 +01003012 * the UserHandle of the profile that was added. Only applications (for example Launchers)
3013 * that need to display merged content across both primary and managed profiles need to
3014 * worry about this broadcast. This is only sent to registered receivers,
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01003015 * not manifest receivers.
3016 */
3017 public static final String ACTION_MANAGED_PROFILE_ADDED =
3018 "android.intent.action.MANAGED_PROFILE_ADDED";
3019
3020 /**
3021 * Broadcast sent to the primary user when an associated managed profile is removed. Carries an
Adam Connorsd4b584e2014-06-09 13:55:47 +01003022 * extra {@link #EXTRA_USER} that specifies the UserHandle of the profile that was removed.
3023 * Only applications (for example Launchers) that need to display merged content across both
3024 * primary and managed profiles need to worry about this broadcast. This is only sent to
3025 * registered receivers, not manifest receivers.
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01003026 */
3027 public static final String ACTION_MANAGED_PROFILE_REMOVED =
3028 "android.intent.action.MANAGED_PROFILE_REMOVED";
3029
3030 /**
Kenny Guyb1b30262016-02-09 16:02:35 +00003031 * Broadcast sent to the primary user when the credential-encrypted private storage for
3032 * an associated managed profile is unlocked. Carries an extra {@link #EXTRA_USER} that
3033 * specifies the UserHandle of the profile that was unlocked. Only applications (for example
3034 * Launchers) that need to display merged content across both primary and managed profiles
3035 * need to worry about this broadcast. This is only sent to registered receivers,
3036 * not manifest receivers.
3037 */
3038 public static final String ACTION_MANAGED_PROFILE_UNLOCKED =
3039 "android.intent.action.MANAGED_PROFILE_UNLOCKED";
3040
3041 /**
Rubin Xue95057a2016-04-01 16:49:25 +01003042 * Broadcast sent to the primary user when an associated managed profile has become available.
3043 * Currently this includes when the user disables quiet mode for the profile. Carries an extra
Rubin Xuf13c9802016-01-21 18:06:00 +00003044 * {@link #EXTRA_USER} that specifies the UserHandle of the profile. When quiet mode is changed,
3045 * this broadcast will carry a boolean extra {@link #EXTRA_QUIET_MODE} indicating the new state
3046 * of quiet mode. This is only sent to registered receivers, not manifest receivers.
Rubin Xu0a29ecd2015-11-04 15:11:48 +00003047 */
Rubin Xue95057a2016-04-01 16:49:25 +01003048 public static final String ACTION_MANAGED_PROFILE_AVAILABLE =
3049 "android.intent.action.MANAGED_PROFILE_AVAILABLE";
3050
3051 /**
3052 * Broadcast sent to the primary user when an associated managed profile has become unavailable.
3053 * Currently this includes when the user enables quiet mode for the profile. Carries an extra
3054 * {@link #EXTRA_USER} that specifies the UserHandle of the profile. When quiet mode is changed,
3055 * this broadcast will carry a boolean extra {@link #EXTRA_QUIET_MODE} indicating the new state
3056 * of quiet mode. This is only sent to registered receivers, not manifest receivers.
3057 */
3058 public static final String ACTION_MANAGED_PROFILE_UNAVAILABLE =
3059 "android.intent.action.MANAGED_PROFILE_UNAVAILABLE";
Rubin Xu0a29ecd2015-11-04 15:11:48 +00003060
3061 /**
Robin Lee92b83c62016-08-31 13:27:51 +01003062 * Broadcast sent to the system user when the 'device locked' state changes for any user.
3063 * Carries an extra {@link #EXTRA_USER_HANDLE} that specifies the ID of the user for which
3064 * the device was locked or unlocked.
3065 *
3066 * This is only sent to registered receivers.
3067 *
3068 * @hide
3069 */
3070 public static final String ACTION_DEVICE_LOCKED_CHANGED =
3071 "android.intent.action.DEVICE_LOCKED_CHANGED";
3072
3073 /**
Daniel Sandler2e7d25b2012-10-01 16:43:26 -04003074 * Sent when the user taps on the clock widget in the system's "quick settings" area.
3075 */
3076 public static final String ACTION_QUICK_CLOCK =
3077 "android.intent.action.QUICK_CLOCK";
3078
Michael Wright0087a142013-02-05 16:29:39 -08003079 /**
Alan Viverette5a399492014-07-14 16:19:38 -07003080 * Activity Action: Shows the brightness setting dialog.
Michael Wright0087a142013-02-05 16:29:39 -08003081 * @hide
3082 */
3083 public static final String ACTION_SHOW_BRIGHTNESS_DIALOG =
3084 "android.intent.action.SHOW_BRIGHTNESS_DIALOG";
3085
Justin Kohd378ad72013-04-01 12:18:26 -07003086 /**
3087 * Broadcast Action: A global button was pressed. Includes a single
3088 * extra field, {@link #EXTRA_KEY_EVENT}, containing the key event that
3089 * caused the broadcast.
3090 * @hide
3091 */
3092 public static final String ACTION_GLOBAL_BUTTON = "android.intent.action.GLOBAL_BUTTON";
3093
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003094 /**
Dongwon Kang2034a4c2015-12-14 21:57:34 +09003095 * Broadcast Action: Sent when media resource is granted.
3096 * <p>
3097 * {@link #EXTRA_PACKAGES} specifies the packages on the process holding the media resource
3098 * granted.
3099 * </p>
3100 * <p class="note">
3101 * This is a protected intent that can only be sent by the system.
3102 * </p>
3103 * <p class="note">
Dongwon Kang32cb9ab2016-01-13 18:11:10 -08003104 * This requires {@link android.Manifest.permission#RECEIVE_MEDIA_RESOURCE_USAGE} permission.
Dongwon Kang2034a4c2015-12-14 21:57:34 +09003105 * </p>
3106 *
3107 * @hide
3108 */
3109 public static final String ACTION_MEDIA_RESOURCE_GRANTED =
3110 "android.intent.action.MEDIA_RESOURCE_GRANTED";
3111
3112 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003113 * Activity Action: Allow the user to select and return one or more existing
3114 * documents. When invoked, the system will display the various
3115 * {@link DocumentsProvider} instances installed on the device, letting the
3116 * user interactively navigate through them. These documents include local
3117 * media, such as photos and video, and documents provided by installed
3118 * cloud storage providers.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003119 * <p>
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003120 * Each document is represented as a {@code content://} URI backed by a
3121 * {@link DocumentsProvider}, which can be opened as a stream with
3122 * {@link ContentResolver#openFileDescriptor(Uri, String)}, or queried for
3123 * {@link android.provider.DocumentsContract.Document} metadata.
3124 * <p>
3125 * All selected documents are returned to the calling application with
3126 * persistable read and write permission grants. If you want to maintain
3127 * access to the documents across device reboots, you need to explicitly
3128 * take the persistable permissions using
3129 * {@link ContentResolver#takePersistableUriPermission(Uri, int)}.
3130 * <p>
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003131 * Callers must indicate the acceptable document MIME types through
3132 * {@link #setType(String)}. For example, to select photos, use
3133 * {@code image/*}. If multiple disjoint MIME types are acceptable, define
3134 * them in {@link #EXTRA_MIME_TYPES} and {@link #setType(String)} to
3135 * {@literal *}/*.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003136 * <p>
3137 * If the caller can handle multiple returned items (the user performing
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003138 * multiple selection), then you can specify {@link #EXTRA_ALLOW_MULTIPLE}
3139 * to indicate this.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003140 * <p>
Tomasz Mikolajewskia8057a92015-11-16 11:41:28 +09003141 * Callers must include {@link #CATEGORY_OPENABLE} in the Intent to obtain
3142 * URIs that can be opened with
Jeff Sharkeybd3b9022013-08-20 15:20:04 -07003143 * {@link ContentResolver#openFileDescriptor(Uri, String)}.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003144 * <p>
Garfield Tanb44ae612016-11-07 16:46:37 -08003145 * Callers can set a document URI through
3146 * {@link DocumentsContract#EXTRA_INITIAL_URI} to indicate the initial
3147 * location of documents navigator. System will do its best to launch the
3148 * navigator in the specified document if it's a folder, or the folder that
3149 * contains the specified document if not.
Garfield Tan0b3cf662016-10-31 12:59:45 -07003150 * <p>
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003151 * Output: The URI of the item that was picked, returned in
3152 * {@link #getData()}. This must be a {@code content://} URI so that any
3153 * receiver can access it. If multiple documents were selected, they are
3154 * returned in {@link #getClipData()}.
Jeff Sharkeybd3b9022013-08-20 15:20:04 -07003155 *
3156 * @see DocumentsContract
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003157 * @see #ACTION_OPEN_DOCUMENT_TREE
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003158 * @see #ACTION_CREATE_DOCUMENT
3159 * @see #FLAG_GRANT_PERSISTABLE_URI_PERMISSION
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003160 */
3161 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
3162 public static final String ACTION_OPEN_DOCUMENT = "android.intent.action.OPEN_DOCUMENT";
3163
3164 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003165 * Activity Action: Allow the user to create a new document. When invoked,
3166 * the system will display the various {@link DocumentsProvider} instances
3167 * installed on the device, letting the user navigate through them. The
3168 * returned document may be a newly created document with no content, or it
3169 * may be an existing document with the requested MIME type.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003170 * <p>
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003171 * Each document is represented as a {@code content://} URI backed by a
3172 * {@link DocumentsProvider}, which can be opened as a stream with
3173 * {@link ContentResolver#openFileDescriptor(Uri, String)}, or queried for
3174 * {@link android.provider.DocumentsContract.Document} metadata.
3175 * <p>
3176 * Callers must indicate the concrete MIME type of the document being
3177 * created by setting {@link #setType(String)}. This MIME type cannot be
3178 * changed after the document is created.
3179 * <p>
3180 * Callers can provide an initial display name through {@link #EXTRA_TITLE},
3181 * but the user may change this value before creating the file.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003182 * <p>
Tomasz Mikolajewskia8057a92015-11-16 11:41:28 +09003183 * Callers must include {@link #CATEGORY_OPENABLE} in the Intent to obtain
3184 * URIs that can be opened with
Jeff Sharkeybd3b9022013-08-20 15:20:04 -07003185 * {@link ContentResolver#openFileDescriptor(Uri, String)}.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003186 * <p>
Garfield Tanb44ae612016-11-07 16:46:37 -08003187 * Callers can set a document URI through
3188 * {@link DocumentsContract#EXTRA_INITIAL_URI} to indicate the initial
3189 * location of documents navigator. System will do its best to launch the
3190 * navigator in the specified document if it's a folder, or the folder that
3191 * contains the specified document if not.
Garfield Tan0b3cf662016-10-31 12:59:45 -07003192 * <p>
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003193 * Output: The URI of the item that was created. This must be a
3194 * {@code content://} URI so that any receiver can access it.
Jeff Sharkeybd3b9022013-08-20 15:20:04 -07003195 *
3196 * @see DocumentsContract
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003197 * @see #ACTION_OPEN_DOCUMENT
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003198 * @see #ACTION_OPEN_DOCUMENT_TREE
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003199 * @see #FLAG_GRANT_PERSISTABLE_URI_PERMISSION
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003200 */
3201 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
3202 public static final String ACTION_CREATE_DOCUMENT = "android.intent.action.CREATE_DOCUMENT";
3203
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003204 /**
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003205 * Activity Action: Allow the user to pick a directory subtree. When
3206 * invoked, the system will display the various {@link DocumentsProvider}
3207 * instances installed on the device, letting the user navigate through
3208 * them. Apps can fully manage documents within the returned directory.
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003209 * <p>
3210 * To gain access to descendant (child, grandchild, etc) documents, use
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003211 * {@link DocumentsContract#buildDocumentUriUsingTree(Uri, String)} and
3212 * {@link DocumentsContract#buildChildDocumentsUriUsingTree(Uri, String)}
3213 * with the returned URI.
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003214 * <p>
Garfield Tanb44ae612016-11-07 16:46:37 -08003215 * Callers can set a document URI through
3216 * {@link DocumentsContract#EXTRA_INITIAL_URI} to indicate the initial
3217 * location of documents navigator. System will do its best to launch the
3218 * navigator in the specified document if it's a folder, or the folder that
3219 * contains the specified document if not.
Garfield Tan0b3cf662016-10-31 12:59:45 -07003220 * <p>
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003221 * Output: The URI representing the selected directory tree.
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003222 *
3223 * @see DocumentsContract
3224 */
3225 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003226 public static final String
3227 ACTION_OPEN_DOCUMENT_TREE = "android.intent.action.OPEN_DOCUMENT_TREE";
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003228
Felipe Lemec7b1f892016-01-15 15:02:31 -08003229 /**
Peng Xua35b5532016-01-20 00:05:45 -08003230 * Broadcast Action: List of dynamic sensor is changed due to new sensor being connected or
3231 * exisiting sensor being disconnected.
3232 *
3233 * <p class="note">This is a protected intent that can only be sent by the system.</p>
3234 *
3235 * {@hide}
3236 */
3237 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3238 public static final String
3239 ACTION_DYNAMIC_SENSOR_CHANGED = "android.intent.action.DYNAMIC_SENSOR_CHANGED";
3240
Lenka Trochtova73aeea22016-11-18 17:34:34 +01003241 /**
3242 * Deprecated - use {@link #ACTION_FACTORY_RESET} instead.
3243 *
3244 * {@hide}
3245 */
3246 @Deprecated
Jeff Sharkey004a4b22014-09-24 11:45:24 -07003247 public static final String ACTION_MASTER_CLEAR = "android.intent.action.MASTER_CLEAR";
3248
Christopher Tate6597e342015-02-17 12:15:25 -08003249 /**
Lenka Trochtova73aeea22016-11-18 17:34:34 +01003250 * Boolean intent extra to be used with {@link #ACTION_MASTER_CLEAR} in order to force a factory
3251 * reset even if {@link android.os.UserManager#DISALLOW_FACTORY_RESET} is set.
3252 *
3253 * <p>Deprecated - use {@link #EXTRA_FORCE_FACTORY_RESET} instead.
3254 *
Benjamin Franzf9d5e6a2016-05-26 14:24:29 +01003255 * @hide
3256 */
Lenka Trochtova73aeea22016-11-18 17:34:34 +01003257 @Deprecated
Benjamin Franzf9d5e6a2016-05-26 14:24:29 +01003258 public static final String EXTRA_FORCE_MASTER_CLEAR =
3259 "android.intent.extra.FORCE_MASTER_CLEAR";
3260
3261 /**
Lenka Trochtova73aeea22016-11-18 17:34:34 +01003262 * A broadcast action to trigger a factory reset.
3263 *
3264 * <p> The sender must hold the {@link android.Manifest.permission#MASTER_CLEAR} permission.
3265 *
3266 * <p>Not for use by third-party applications.
3267 *
3268 * @see #EXTRA_FORCE_MASTER_CLEAR
3269 *
3270 * {@hide}
3271 */
3272 @SystemApi
3273 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3274 public static final String ACTION_FACTORY_RESET = "android.intent.action.FACTORY_RESET";
3275
3276 /**
3277 * Boolean intent extra to be used with {@link #ACTION_MASTER_CLEAR} in order to force a factory
3278 * reset even if {@link android.os.UserManager#DISALLOW_FACTORY_RESET} is set.
3279 *
3280 * <p>Not for use by third-party applications.
3281 *
3282 * @hide
3283 */
3284 @SystemApi
3285 public static final String EXTRA_FORCE_FACTORY_RESET =
3286 "android.intent.extra.FORCE_FACTORY_RESET";
3287
3288 /**
Christopher Tate6597e342015-02-17 12:15:25 -08003289 * Broadcast action: report that a settings element is being restored from backup. The intent
3290 * contains three extras: EXTRA_SETTING_NAME is a string naming the restored setting,
3291 * EXTRA_SETTING_NEW_VALUE is the value being restored, and EXTRA_SETTING_PREVIOUS_VALUE
3292 * is the value of that settings entry prior to the restore operation. All of these values are
3293 * represented as strings.
3294 *
3295 * <p>This broadcast is sent only for settings provider entries known to require special handling
3296 * around restore time. These entries are found in the BROADCAST_ON_RESTORE table within
3297 * the provider's backup agent implementation.
3298 *
3299 * @see #EXTRA_SETTING_NAME
3300 * @see #EXTRA_SETTING_PREVIOUS_VALUE
3301 * @see #EXTRA_SETTING_NEW_VALUE
3302 * {@hide}
3303 */
3304 public static final String ACTION_SETTING_RESTORED = "android.os.action.SETTING_RESTORED";
3305
3306 /** {@hide} */
3307 public static final String EXTRA_SETTING_NAME = "setting_name";
3308 /** {@hide} */
3309 public static final String EXTRA_SETTING_PREVIOUS_VALUE = "previous_value";
3310 /** {@hide} */
3311 public static final String EXTRA_SETTING_NEW_VALUE = "new_value";
3312
Clara Bayarri0a26157a2015-03-26 18:38:55 +00003313 /**
3314 * Activity Action: Process a piece of text.
3315 * <p>Input: {@link #EXTRA_PROCESS_TEXT} contains the text to be processed.
3316 * {@link #EXTRA_PROCESS_TEXT_READONLY} states if the resulting text will be read-only.</p>
3317 * <p>Output: {@link #EXTRA_PROCESS_TEXT} contains the processed text.</p>
3318 */
3319 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
3320 public static final String ACTION_PROCESS_TEXT = "android.intent.action.PROCESS_TEXT";
3321 /**
Clara Bayarri92c8e6f2015-05-21 17:50:08 +01003322 * The name of the extra used to define the text to be processed, as a
3323 * CharSequence. Note that this may be a styled CharSequence, so you must use
3324 * {@link Bundle#getCharSequence(String) Bundle.getCharSequence()} to retrieve it.
Clara Bayarri0a26157a2015-03-26 18:38:55 +00003325 */
3326 public static final String EXTRA_PROCESS_TEXT = "android.intent.extra.PROCESS_TEXT";
3327 /**
Clara Bayarri92c8e6f2015-05-21 17:50:08 +01003328 * 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 +00003329 */
3330 public static final String EXTRA_PROCESS_TEXT_READONLY =
3331 "android.intent.extra.PROCESS_TEXT_READONLY";
3332
Bryce Leebc58f592015-09-25 16:43:01 -07003333 /**
3334 * Broadcast action: reports when a new thermal event has been reached. When the device
3335 * is reaching its maximum temperatue, the thermal level reported
3336 * {@hide}
3337 */
3338 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
3339 public static final String ACTION_THERMAL_EVENT = "android.intent.action.THERMAL_EVENT";
3340
3341 /** {@hide} */
3342 public static final String EXTRA_THERMAL_STATE = "android.intent.extra.THERMAL_STATE";
3343
3344 /**
3345 * Thermal state when the device is normal. This state is sent in the
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08003346 * {@link #ACTION_THERMAL_EVENT} broadcast as {@link #EXTRA_THERMAL_STATE}.
Bryce Leebc58f592015-09-25 16:43:01 -07003347 * {@hide}
3348 */
3349 public static final int EXTRA_THERMAL_STATE_NORMAL = 0;
3350
3351 /**
3352 * Thermal state where the device is approaching its maximum threshold. This state is sent in
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08003353 * the {@link #ACTION_THERMAL_EVENT} broadcast as {@link #EXTRA_THERMAL_STATE}.
Bryce Leebc58f592015-09-25 16:43:01 -07003354 * {@hide}
3355 */
3356 public static final int EXTRA_THERMAL_STATE_WARNING = 1;
3357
3358 /**
3359 * Thermal state where the device has reached its maximum threshold. This state is sent in the
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08003360 * {@link #ACTION_THERMAL_EVENT} broadcast as {@link #EXTRA_THERMAL_STATE}.
Bryce Leebc58f592015-09-25 16:43:01 -07003361 * {@hide}
3362 */
3363 public static final int EXTRA_THERMAL_STATE_EXCEEDED = 2;
3364
3365
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003366 // ---------------------------------------------------------------------
3367 // ---------------------------------------------------------------------
3368 // Standard intent categories (see addCategory()).
3369
3370 /**
3371 * Set if the activity should be an option for the default action
3372 * (center press) to perform on a piece of data. Setting this will
3373 * hide from the user any activities without it set when performing an
John Spurlock6098c5d2013-06-17 10:32:46 -04003374 * action on some data. Note that this is normally -not- set in the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003375 * Intent when initiating an action -- it is for use in intent filters
3376 * specified in packages.
3377 */
3378 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3379 public static final String CATEGORY_DEFAULT = "android.intent.category.DEFAULT";
3380 /**
3381 * Activities that can be safely invoked from a browser must support this
3382 * category. For example, if the user is viewing a web page or an e-mail
3383 * and clicks on a link in the text, the Intent generated execute that
3384 * link will require the BROWSABLE category, so that only activities
3385 * supporting this category will be considered as possible actions. By
3386 * supporting this category, you are promising that there is nothing
3387 * damaging (without user intervention) that can happen by invoking any
3388 * matching Intent.
3389 */
3390 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3391 public static final String CATEGORY_BROWSABLE = "android.intent.category.BROWSABLE";
3392 /**
Dianne Hackborn91097de2014-04-04 18:02:06 -07003393 * Categories for activities that can participate in voice interaction.
3394 * An activity that supports this category must be prepared to run with
3395 * no UI shown at all (though in some case it may have a UI shown), and
3396 * rely on {@link android.app.VoiceInteractor} to interact with the user.
3397 */
3398 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3399 public static final String CATEGORY_VOICE = "android.intent.category.VOICE";
3400 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003401 * Set if the activity should be considered as an alternative action to
3402 * the data the user is currently viewing. See also
3403 * {@link #CATEGORY_SELECTED_ALTERNATIVE} for an alternative action that
3404 * applies to the selection in a list of items.
3405 *
3406 * <p>Supporting this category means that you would like your activity to be
3407 * displayed in the set of alternative things the user can do, usually as
3408 * part of the current activity's options menu. You will usually want to
3409 * include a specific label in the &lt;intent-filter&gt; of this action
3410 * describing to the user what it does.
3411 *
3412 * <p>The action of IntentFilter with this category is important in that it
3413 * describes the specific action the target will perform. This generally
3414 * should not be a generic action (such as {@link #ACTION_VIEW}, but rather
3415 * a specific name such as "com.android.camera.action.CROP. Only one
3416 * alternative of any particular action will be shown to the user, so using
3417 * a specific action like this makes sure that your alternative will be
3418 * displayed while also allowing other applications to provide their own
3419 * overrides of that particular action.
3420 */
3421 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3422 public static final String CATEGORY_ALTERNATIVE = "android.intent.category.ALTERNATIVE";
3423 /**
3424 * Set if the activity should be considered as an alternative selection
3425 * action to the data the user has currently selected. This is like
3426 * {@link #CATEGORY_ALTERNATIVE}, but is used in activities showing a list
3427 * of items from which the user can select, giving them alternatives to the
3428 * default action that will be performed on it.
3429 */
3430 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3431 public static final String CATEGORY_SELECTED_ALTERNATIVE = "android.intent.category.SELECTED_ALTERNATIVE";
3432 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09003433 * Intended to be used as a tab inside of a containing TabActivity.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003434 */
3435 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3436 public static final String CATEGORY_TAB = "android.intent.category.TAB";
3437 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003438 * Should be displayed in the top-level launcher.
3439 */
3440 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3441 public static final String CATEGORY_LAUNCHER = "android.intent.category.LAUNCHER";
3442 /**
Jose Lima38b75b62014-03-11 10:41:39 -07003443 * Indicates an activity optimized for Leanback mode, and that should
3444 * be displayed in the Leanback launcher.
3445 */
3446 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3447 public static final String CATEGORY_LEANBACK_LAUNCHER = "android.intent.category.LEANBACK_LAUNCHER";
3448 /**
Jose Lima73915cf2014-07-29 17:16:31 -07003449 * Indicates a Leanback settings activity to be displayed in the Leanback launcher.
3450 * @hide
3451 */
3452 @SystemApi
3453 public static final String CATEGORY_LEANBACK_SETTINGS = "android.intent.category.LEANBACK_SETTINGS";
3454 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003455 * Provides information about the package it is in; typically used if
3456 * a package does not contain a {@link #CATEGORY_LAUNCHER} to provide
3457 * a front-door to the user without having to be shown in the all apps list.
3458 */
3459 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3460 public static final String CATEGORY_INFO = "android.intent.category.INFO";
3461 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003462 * This is the home activity, that is the first activity that is displayed
3463 * when the device boots.
3464 */
3465 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3466 public static final String CATEGORY_HOME = "android.intent.category.HOME";
3467 /**
Anthony Hugh979b81a2015-09-29 16:50:35 -07003468 * This is the home activity that is displayed when the device is finished setting up and ready
3469 * for use.
3470 * @hide
3471 */
3472 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3473 public static final String CATEGORY_HOME_MAIN = "android.intent.category.HOME_MAIN";
3474 /**
Svet Ganov50a8bf42015-07-15 11:04:18 -07003475 * This is the setup wizard activity, that is the first activity that is displayed
3476 * when the user sets up the device for the first time.
3477 * @hide
3478 */
3479 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3480 public static final String CATEGORY_SETUP_WIZARD = "android.intent.category.SETUP_WIZARD";
3481 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003482 * This activity is a preference panel.
3483 */
3484 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3485 public static final String CATEGORY_PREFERENCE = "android.intent.category.PREFERENCE";
3486 /**
3487 * This activity is a development preference panel.
3488 */
3489 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3490 public static final String CATEGORY_DEVELOPMENT_PREFERENCE = "android.intent.category.DEVELOPMENT_PREFERENCE";
3491 /**
3492 * Capable of running inside a parent activity container.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003493 */
3494 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3495 public static final String CATEGORY_EMBED = "android.intent.category.EMBED";
3496 /**
Patrick Dubroy6dabe242010-08-30 10:43:47 -07003497 * This activity allows the user to browse and download new applications.
3498 */
3499 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3500 public static final String CATEGORY_APP_MARKET = "android.intent.category.APP_MARKET";
3501 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003502 * This activity may be exercised by the monkey or other automated test tools.
3503 */
3504 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3505 public static final String CATEGORY_MONKEY = "android.intent.category.MONKEY";
3506 /**
3507 * To be used as a test (not part of the normal user experience).
3508 */
3509 public static final String CATEGORY_TEST = "android.intent.category.TEST";
3510 /**
3511 * To be used as a unit test (run through the Test Harness).
3512 */
3513 public static final String CATEGORY_UNIT_TEST = "android.intent.category.UNIT_TEST";
3514 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09003515 * To be used as a sample code example (not part of the normal user
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003516 * experience).
3517 */
3518 public static final String CATEGORY_SAMPLE_CODE = "android.intent.category.SAMPLE_CODE";
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003519
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003520 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003521 * Used to indicate that an intent only wants URIs that can be opened with
3522 * {@link ContentResolver#openFileDescriptor(Uri, String)}. Openable URIs
3523 * must support at least the columns defined in {@link OpenableColumns} when
3524 * queried.
3525 *
3526 * @see #ACTION_GET_CONTENT
3527 * @see #ACTION_OPEN_DOCUMENT
3528 * @see #ACTION_CREATE_DOCUMENT
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003529 */
3530 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3531 public static final String CATEGORY_OPENABLE = "android.intent.category.OPENABLE";
3532
3533 /**
Tomasz Mikolajewski28a815c2016-10-28 15:54:11 +09003534 * Used to indicate that an intent filter can accept files which are not necessarily
3535 * openable by {@link ContentResolver#openFileDescriptor(Uri, String)}, but
3536 * at least streamable via
3537 * {@link ContentResolver#openTypedAssetFileDescriptor(Uri, String, Bundle)}
3538 * using one of the stream types exposed via
3539 * {@link ContentResolver#getStreamTypes(Uri, String)}.
3540 *
3541 * @see #ACTION_SEND
3542 * @see #ACTION_SEND_MULTIPLE
3543 */
3544 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3545 public static final String CATEGORY_TYPED_OPENABLE =
3546 "android.intent.category.TYPED_OPENABLE";
3547
3548 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003549 * To be used as code under test for framework instrumentation tests.
3550 */
3551 public static final String CATEGORY_FRAMEWORK_INSTRUMENTATION_TEST =
3552 "android.intent.category.FRAMEWORK_INSTRUMENTATION_TEST";
Mike Lockwood9092ab42009-09-16 13:01:32 -04003553 /**
3554 * An activity to run when device is inserted into a car dock.
Dianne Hackborn7299c412010-03-04 18:41:49 -08003555 * Used with {@link #ACTION_MAIN} to launch an activity. For more
3556 * information, see {@link android.app.UiModeManager}.
Mike Lockwood9092ab42009-09-16 13:01:32 -04003557 */
3558 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3559 public static final String CATEGORY_CAR_DOCK = "android.intent.category.CAR_DOCK";
3560 /**
3561 * An activity to run when device is inserted into a car dock.
Dianne Hackborn7299c412010-03-04 18:41:49 -08003562 * Used with {@link #ACTION_MAIN} to launch an activity. For more
3563 * information, see {@link android.app.UiModeManager}.
Mike Lockwood9092ab42009-09-16 13:01:32 -04003564 */
3565 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3566 public static final String CATEGORY_DESK_DOCK = "android.intent.category.DESK_DOCK";
Praveen Bharathi21e941b2010-10-06 15:23:14 -05003567 /**
3568 * An activity to run when device is inserted into a analog (low end) dock.
3569 * Used with {@link #ACTION_MAIN} to launch an activity. For more
3570 * information, see {@link android.app.UiModeManager}.
3571 */
3572 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3573 public static final String CATEGORY_LE_DESK_DOCK = "android.intent.category.LE_DESK_DOCK";
3574
3575 /**
3576 * An activity to run when device is inserted into a digital (high end) dock.
3577 * Used with {@link #ACTION_MAIN} to launch an activity. For more
3578 * information, see {@link android.app.UiModeManager}.
3579 */
3580 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3581 public static final String CATEGORY_HE_DESK_DOCK = "android.intent.category.HE_DESK_DOCK";
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05003582
Bernd Holzheyaea4b672010-03-31 09:46:13 +02003583 /**
3584 * Used to indicate that the activity can be used in a car environment.
3585 */
3586 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3587 public static final String CATEGORY_CAR_MODE = "android.intent.category.CAR_MODE";
3588
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003589 // ---------------------------------------------------------------------
3590 // ---------------------------------------------------------------------
Jeff Brown6651a632011-11-28 12:59:11 -08003591 // Application launch intent categories (see addCategory()).
3592
3593 /**
3594 * Used with {@link #ACTION_MAIN} to launch the browser application.
3595 * The activity should be able to browse the Internet.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003596 * <p>NOTE: This should not be used as the primary key of an Intent,
3597 * since it will not result in the app launching with the correct
3598 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003599 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003600 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003601 */
3602 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3603 public static final String CATEGORY_APP_BROWSER = "android.intent.category.APP_BROWSER";
3604
3605 /**
3606 * Used with {@link #ACTION_MAIN} to launch the calculator application.
3607 * The activity should be able to perform standard arithmetic operations.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003608 * <p>NOTE: This should not be used as the primary key of an Intent,
3609 * since it will not result in the app launching with the correct
3610 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003611 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003612 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003613 */
3614 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3615 public static final String CATEGORY_APP_CALCULATOR = "android.intent.category.APP_CALCULATOR";
3616
3617 /**
3618 * Used with {@link #ACTION_MAIN} to launch the calendar application.
3619 * The activity should be able to view and manipulate calendar entries.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003620 * <p>NOTE: This should not be used as the primary key of an Intent,
3621 * since it will not result in the app launching with the correct
3622 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003623 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003624 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003625 */
3626 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3627 public static final String CATEGORY_APP_CALENDAR = "android.intent.category.APP_CALENDAR";
3628
3629 /**
3630 * Used with {@link #ACTION_MAIN} to launch the contacts application.
3631 * The activity should be able to view and manipulate address book entries.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003632 * <p>NOTE: This should not be used as the primary key of an Intent,
3633 * since it will not result in the app launching with the correct
3634 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003635 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003636 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003637 */
3638 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3639 public static final String CATEGORY_APP_CONTACTS = "android.intent.category.APP_CONTACTS";
3640
3641 /**
3642 * Used with {@link #ACTION_MAIN} to launch the email application.
3643 * The activity should be able to send and receive email.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003644 * <p>NOTE: This should not be used as the primary key of an Intent,
3645 * since it will not result in the app launching with the correct
3646 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003647 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003648 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003649 */
3650 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3651 public static final String CATEGORY_APP_EMAIL = "android.intent.category.APP_EMAIL";
3652
3653 /**
3654 * Used with {@link #ACTION_MAIN} to launch the gallery application.
3655 * The activity should be able to view and manipulate image and video files
3656 * stored on the device.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003657 * <p>NOTE: This should not be used as the primary key of an Intent,
3658 * since it will not result in the app launching with the correct
3659 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003660 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003661 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003662 */
3663 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3664 public static final String CATEGORY_APP_GALLERY = "android.intent.category.APP_GALLERY";
3665
3666 /**
3667 * Used with {@link #ACTION_MAIN} to launch the maps application.
3668 * The activity should be able to show the user's current location and surroundings.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003669 * <p>NOTE: This should not be used as the primary key of an Intent,
3670 * since it will not result in the app launching with the correct
3671 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003672 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003673 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003674 */
3675 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3676 public static final String CATEGORY_APP_MAPS = "android.intent.category.APP_MAPS";
3677
3678 /**
3679 * Used with {@link #ACTION_MAIN} to launch the messaging application.
3680 * The activity should be able to send and receive text messages.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003681 * <p>NOTE: This should not be used as the primary key of an Intent,
3682 * since it will not result in the app launching with the correct
3683 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003684 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003685 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003686 */
3687 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3688 public static final String CATEGORY_APP_MESSAGING = "android.intent.category.APP_MESSAGING";
3689
3690 /**
3691 * Used with {@link #ACTION_MAIN} to launch the music application.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003692 * The activity should be able to play, browse, or manipulate music files
3693 * stored on the device.
3694 * <p>NOTE: This should not be used as the primary key of an Intent,
3695 * since it will not result in the app launching with the correct
3696 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003697 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003698 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003699 */
3700 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3701 public static final String CATEGORY_APP_MUSIC = "android.intent.category.APP_MUSIC";
3702
3703 // ---------------------------------------------------------------------
3704 // ---------------------------------------------------------------------
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003705 // Standard extra data keys.
3706
3707 /**
3708 * The initial data to place in a newly created record. Use with
3709 * {@link #ACTION_INSERT}. The data here is a Map containing the same
3710 * fields as would be given to the underlying ContentProvider.insert()
3711 * call.
3712 */
3713 public static final String EXTRA_TEMPLATE = "android.intent.extra.TEMPLATE";
3714
3715 /**
3716 * A constant CharSequence that is associated with the Intent, used with
3717 * {@link #ACTION_SEND} to supply the literal data to be sent. Note that
3718 * this may be a styled CharSequence, so you must use
3719 * {@link Bundle#getCharSequence(String) Bundle.getCharSequence()} to
3720 * retrieve it.
3721 */
3722 public static final String EXTRA_TEXT = "android.intent.extra.TEXT";
3723
3724 /**
Dianne Hackbornacb69bb2012-04-13 15:36:06 -07003725 * A constant String that is associated with the Intent, used with
3726 * {@link #ACTION_SEND} to supply an alternative to {@link #EXTRA_TEXT}
3727 * as HTML formatted text. Note that you <em>must</em> also supply
3728 * {@link #EXTRA_TEXT}.
3729 */
3730 public static final String EXTRA_HTML_TEXT = "android.intent.extra.HTML_TEXT";
3731
3732 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003733 * A content: URI holding a stream of data associated with the Intent,
3734 * used with {@link #ACTION_SEND} to supply the data being sent.
3735 */
3736 public static final String EXTRA_STREAM = "android.intent.extra.STREAM";
3737
3738 /**
3739 * A String[] holding e-mail addresses that should be delivered to.
3740 */
3741 public static final String EXTRA_EMAIL = "android.intent.extra.EMAIL";
3742
3743 /**
3744 * A String[] holding e-mail addresses that should be carbon copied.
3745 */
3746 public static final String EXTRA_CC = "android.intent.extra.CC";
3747
3748 /**
3749 * A String[] holding e-mail addresses that should be blind carbon copied.
3750 */
3751 public static final String EXTRA_BCC = "android.intent.extra.BCC";
3752
3753 /**
3754 * A constant string holding the desired subject line of a message.
3755 */
3756 public static final String EXTRA_SUBJECT = "android.intent.extra.SUBJECT";
3757
3758 /**
3759 * An Intent describing the choices you would like shown with
Adam Powell2ed547e2015-04-29 18:45:04 -07003760 * {@link #ACTION_PICK_ACTIVITY} or {@link #ACTION_CHOOSER}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003761 */
3762 public static final String EXTRA_INTENT = "android.intent.extra.INTENT";
3763
3764 /**
Clara Bayarrif7fea162015-10-22 16:09:52 +01003765 * An int representing the user id to be used.
3766 *
3767 * @hide
3768 */
3769 public static final String EXTRA_USER_ID = "android.intent.extra.USER_ID";
3770
3771 /**
Clara Bayarriea9b10e2015-12-04 15:36:26 +00003772 * An int representing the task id to be retrieved. This is used when a launch from recents is
3773 * intercepted by another action such as credentials confirmation to remember which task should
3774 * be resumed when complete.
3775 *
3776 * @hide
3777 */
3778 public static final String EXTRA_TASK_ID = "android.intent.extra.TASK_ID";
3779
3780 /**
Adam Powell2ed547e2015-04-29 18:45:04 -07003781 * An Intent[] describing additional, alternate choices you would like shown with
3782 * {@link #ACTION_CHOOSER}.
3783 *
3784 * <p>An app may be capable of providing several different payload types to complete a
3785 * user's intended action. For example, an app invoking {@link #ACTION_SEND} to share photos
3786 * with another app may use EXTRA_ALTERNATE_INTENTS to have the chooser transparently offer
3787 * several different supported sending mechanisms for sharing, such as the actual "image/*"
3788 * photo data or a hosted link where the photos can be viewed.</p>
3789 *
3790 * <p>The intent present in {@link #EXTRA_INTENT} will be treated as the
3791 * first/primary/preferred intent in the set. Additional intents specified in
3792 * this extra are ordered; by default intents that appear earlier in the array will be
3793 * preferred over intents that appear later in the array as matches for the same
3794 * target component. To alter this preference, a calling app may also supply
3795 * {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER}.</p>
3796 */
3797 public static final String EXTRA_ALTERNATE_INTENTS = "android.intent.extra.ALTERNATE_INTENTS";
3798
3799 /**
Adam Powell52c39212016-04-07 15:14:18 -07003800 * A {@link ComponentName ComponentName[]} describing components that should be filtered out
3801 * and omitted from a list of components presented to the user.
3802 *
3803 * <p>When used with {@link #ACTION_CHOOSER}, the chooser will omit any of the components
3804 * in this array if it otherwise would have shown them. Useful for omitting specific targets
3805 * from your own package or other apps from your organization if the idea of sending to those
3806 * targets would be redundant with other app functionality. Filtered components will not
3807 * be able to present targets from an associated <code>ChooserTargetService</code>.</p>
3808 */
3809 public static final String EXTRA_EXCLUDE_COMPONENTS
3810 = "android.intent.extra.EXCLUDE_COMPONENTS";
3811
3812 /**
3813 * A {@link android.service.chooser.ChooserTarget ChooserTarget[]} for {@link #ACTION_CHOOSER}
3814 * describing additional high-priority deep-link targets for the chooser to present to the user.
3815 *
3816 * <p>Targets provided in this way will be presented inline with all other targets provided
3817 * by services from other apps. They will be prioritized before other service targets, but
3818 * after those targets provided by sources that the user has manually pinned to the front.</p>
3819 *
3820 * @see #ACTION_CHOOSER
3821 */
3822 public static final String EXTRA_CHOOSER_TARGETS = "android.intent.extra.CHOOSER_TARGETS";
3823
3824 /**
Adam Powell2ed547e2015-04-29 18:45:04 -07003825 * An {@link IntentSender} for an Activity that will be invoked when the user makes a selection
3826 * from the chooser activity presented by {@link #ACTION_CHOOSER}.
3827 *
3828 * <p>An app preparing an action for another app to complete may wish to allow the user to
3829 * disambiguate between several options for completing the action based on the chosen target
3830 * or otherwise refine the action before it is invoked.
3831 * </p>
3832 *
3833 * <p>When sent, this IntentSender may be filled in with the following extras:</p>
3834 * <ul>
3835 * <li>{@link #EXTRA_INTENT} The first intent that matched the user's chosen target</li>
3836 * <li>{@link #EXTRA_ALTERNATE_INTENTS} Any additional intents that also matched the user's
3837 * chosen target beyond the first</li>
3838 * <li>{@link #EXTRA_RESULT_RECEIVER} A {@link ResultReceiver} that the refinement activity
3839 * should fill in and send once the disambiguation is complete</li>
3840 * </ul>
3841 */
3842 public static final String EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER
3843 = "android.intent.extra.CHOOSER_REFINEMENT_INTENT_SENDER";
3844
3845 /**
3846 * A {@link ResultReceiver} used to return data back to the sender.
3847 *
3848 * <p>Used to complete an app-specific
3849 * {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER refinement} for {@link #ACTION_CHOOSER}.</p>
3850 *
3851 * <p>If {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER} is present in the intent
3852 * used to start a {@link #ACTION_CHOOSER} activity this extra will be
3853 * {@link #fillIn(Intent, int) filled in} to that {@link IntentSender} and sent
3854 * when the user selects a target component from the chooser. It is up to the recipient
3855 * to send a result to this ResultReceiver to signal that disambiguation is complete
3856 * and that the chooser should invoke the user's choice.</p>
3857 *
3858 * <p>The disambiguator should provide a Bundle to the ResultReceiver with an intent
3859 * assigned to the key {@link #EXTRA_INTENT}. This supplied intent will be used by the chooser
3860 * to match and fill in the final Intent or ChooserTarget before starting it.
3861 * The supplied intent must {@link #filterEquals(Intent) match} one of the intents from
3862 * {@link #EXTRA_INTENT} or {@link #EXTRA_ALTERNATE_INTENTS} passed to
3863 * {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER} to be accepted.</p>
3864 *
3865 * <p>The result code passed to the ResultReceiver should be
3866 * {@link android.app.Activity#RESULT_OK} if the refinement succeeded and the supplied intent's
3867 * target in the chooser should be started, or {@link android.app.Activity#RESULT_CANCELED} if
3868 * the chooser should finish without starting a target.</p>
3869 */
3870 public static final String EXTRA_RESULT_RECEIVER
3871 = "android.intent.extra.RESULT_RECEIVER";
3872
3873 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003874 * A CharSequence dialog title to provide to the user when used with a
Jim Miller4d64746d2014-08-13 21:08:41 +00003875 * {@link #ACTION_CHOOSER}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003876 */
3877 public static final String EXTRA_TITLE = "android.intent.extra.TITLE";
3878
3879 /**
Dianne Hackborneb034652009-09-07 00:49:58 -07003880 * A Parcelable[] of {@link Intent} or
3881 * {@link android.content.pm.LabeledIntent} objects as set with
3882 * {@link #putExtra(String, Parcelable[])} of additional activities to place
3883 * a the front of the list of choices, when shown to the user with a
3884 * {@link #ACTION_CHOOSER}.
3885 */
3886 public static final String EXTRA_INITIAL_INTENTS = "android.intent.extra.INITIAL_INTENTS";
3887
3888 /**
Todd Kennedy7440f172015-12-09 14:31:22 -08003889 * A {@link IntentSender} to start after ephemeral installation success.
3890 * @hide
3891 */
Todd Kennedy7440f172015-12-09 14:31:22 -08003892 public static final String EXTRA_EPHEMERAL_SUCCESS = "android.intent.extra.EPHEMERAL_SUCCESS";
3893
3894 /**
3895 * A {@link IntentSender} to start after ephemeral installation failure.
3896 * @hide
3897 */
Todd Kennedy7440f172015-12-09 14:31:22 -08003898 public static final String EXTRA_EPHEMERAL_FAILURE = "android.intent.extra.EPHEMERAL_FAILURE";
3899
3900 /**
Todd Kennedy01ad0c72016-11-11 15:33:12 -08003901 * The host name that triggered an ephemeral resolution.
3902 * @hide
3903 */
3904 public static final String EXTRA_EPHEMERAL_HOSTNAME = "android.intent.extra.EPHEMERAL_HOSTNAME";
3905
3906 /**
3907 * An opaque token to track ephemeral resolution.
3908 * @hide
3909 */
3910 public static final String EXTRA_EPHEMERAL_TOKEN = "android.intent.extra.EPHEMERAL_TOKEN";
3911
3912 /**
Adam Powelle49d9392014-07-17 18:45:19 -07003913 * A Bundle forming a mapping of potential target package names to different extras Bundles
3914 * to add to the default intent extras in {@link #EXTRA_INTENT} when used with
3915 * {@link #ACTION_CHOOSER}. Each key should be a package name. The package need not
3916 * be currently installed on the device.
3917 *
3918 * <p>An application may choose to provide alternate extras for the case where a user
3919 * selects an activity from a predetermined set of target packages. If the activity
3920 * the user selects from the chooser belongs to a package with its package name as
3921 * a key in this bundle, the corresponding extras for that package will be merged with
3922 * the extras already present in the intent at {@link #EXTRA_INTENT}. If a replacement
3923 * extra has the same key as an extra already present in the intent it will overwrite
3924 * the extra from the intent.</p>
3925 *
3926 * <p><em>Examples:</em>
3927 * <ul>
3928 * <li>An application may offer different {@link #EXTRA_TEXT} to an application
3929 * when sharing with it via {@link #ACTION_SEND}, augmenting a link with additional query
3930 * parameters for that target.</li>
3931 * <li>An application may offer additional metadata for known targets of a given intent
3932 * to pass along information only relevant to that target such as account or content
3933 * identifiers already known to that application.</li>
3934 * </ul></p>
3935 */
3936 public static final String EXTRA_REPLACEMENT_EXTRAS =
3937 "android.intent.extra.REPLACEMENT_EXTRAS";
3938
3939 /**
Adam Powell0b3c1122014-10-09 12:50:14 -07003940 * An {@link IntentSender} that will be notified if a user successfully chooses a target
3941 * component to handle an action in an {@link #ACTION_CHOOSER} activity. The IntentSender
3942 * will have the extra {@link #EXTRA_CHOSEN_COMPONENT} appended to it containing the
3943 * {@link ComponentName} of the chosen component.
3944 *
3945 * <p>In some situations this callback may never come, for example if the user abandons
3946 * the chooser, switches to another task or any number of other reasons. Apps should not
3947 * be written assuming that this callback will always occur.</p>
3948 */
3949 public static final String EXTRA_CHOSEN_COMPONENT_INTENT_SENDER =
3950 "android.intent.extra.CHOSEN_COMPONENT_INTENT_SENDER";
3951
3952 /**
3953 * The {@link ComponentName} chosen by the user to complete an action.
3954 *
3955 * @see #EXTRA_CHOSEN_COMPONENT_INTENT_SENDER
3956 */
3957 public static final String EXTRA_CHOSEN_COMPONENT = "android.intent.extra.CHOSEN_COMPONENT";
3958
3959 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003960 * A {@link android.view.KeyEvent} object containing the event that
3961 * triggered the creation of the Intent it is in.
3962 */
3963 public static final String EXTRA_KEY_EVENT = "android.intent.extra.KEY_EVENT";
3964
3965 /**
Mike Lockwoodbad80e02009-07-30 01:21:08 -07003966 * Set to true in {@link #ACTION_REQUEST_SHUTDOWN} to request confirmation from the user
3967 * before shutting down.
3968 *
3969 * {@hide}
3970 */
3971 public static final String EXTRA_KEY_CONFIRM = "android.intent.extra.KEY_CONFIRM";
3972
3973 /**
Yusuke Sato705ffd12015-07-21 15:52:11 -07003974 * Set to true in {@link #ACTION_REQUEST_SHUTDOWN} to indicate that the shutdown is
3975 * requested by the user.
3976 *
3977 * {@hide}
3978 */
3979 public static final String EXTRA_USER_REQUESTED_SHUTDOWN =
3980 "android.intent.extra.USER_REQUESTED_SHUTDOWN";
3981
3982 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09003983 * 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 -07003984 * {@link android.content.Intent#ACTION_PACKAGE_CHANGED} intents to override the default action
3985 * of restarting the application.
3986 */
3987 public static final String EXTRA_DONT_KILL_APP = "android.intent.extra.DONT_KILL_APP";
3988
3989 /**
3990 * A String holding the phone number originally entered in
3991 * {@link android.content.Intent#ACTION_NEW_OUTGOING_CALL}, or the actual
3992 * number to call in a {@link android.content.Intent#ACTION_CALL}.
3993 */
3994 public static final String EXTRA_PHONE_NUMBER = "android.intent.extra.PHONE_NUMBER";
Bernd Holzheyaea4b672010-03-31 09:46:13 +02003995
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003996 /**
3997 * Used as an int extra field in {@link android.content.Intent#ACTION_UID_REMOVED}
3998 * intents to supply the uid the package had been assigned. Also an optional
3999 * extra in {@link android.content.Intent#ACTION_PACKAGE_REMOVED} or
4000 * {@link android.content.Intent#ACTION_PACKAGE_CHANGED} for the same
4001 * purpose.
4002 */
4003 public static final String EXTRA_UID = "android.intent.extra.UID";
4004
4005 /**
Dianne Hackborn21f1bd12010-02-19 17:02:21 -08004006 * @hide String array of package names.
4007 */
Soonil Nagarkar0e8fd092015-02-10 10:37:36 -08004008 @SystemApi
Dianne Hackborn21f1bd12010-02-19 17:02:21 -08004009 public static final String EXTRA_PACKAGES = "android.intent.extra.PACKAGES";
4010
4011 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004012 * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED}
4013 * intents to indicate whether this represents a full uninstall (removing
4014 * both the code and its data) or a partial uninstall (leaving its data,
4015 * implying that this is an update).
4016 */
4017 public static final String EXTRA_DATA_REMOVED = "android.intent.extra.DATA_REMOVED";
The Android Open Source Project10592532009-03-18 17:39:46 -07004018
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004019 /**
Dianne Hackbornc72fc672012-09-20 13:12:03 -07004020 * @hide
4021 * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED}
4022 * intents to indicate that at this point the package has been removed for
4023 * all users on the device.
4024 */
4025 public static final String EXTRA_REMOVED_FOR_ALL_USERS
4026 = "android.intent.extra.REMOVED_FOR_ALL_USERS";
4027
4028 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004029 * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED}
4030 * intents to indicate that this is a replacement of the package, so this
4031 * broadcast will immediately be followed by an add broadcast for a
4032 * different version of the same package.
4033 */
4034 public static final String EXTRA_REPLACING = "android.intent.extra.REPLACING";
The Android Open Source Project10592532009-03-18 17:39:46 -07004035
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004036 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004037 * Used as an int extra field in {@link android.app.AlarmManager} intents
4038 * to tell the application being invoked how many pending alarms are being
4039 * delievered with the intent. For one-shot alarms this will always be 1.
4040 * For recurring alarms, this might be greater than 1 if the device was
4041 * asleep or powered off at the time an earlier alarm would have been
4042 * delivered.
4043 */
4044 public static final String EXTRA_ALARM_COUNT = "android.intent.extra.ALARM_COUNT";
Romain Guy4969af72009-06-17 10:53:19 -07004045
Jacek Surazski86b6c532009-05-13 14:38:28 +02004046 /**
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05004047 * Used as an int extra field in {@link android.content.Intent#ACTION_DOCK_EVENT}
4048 * intents to request the dock state. Possible values are
Mike Lockwood725fcbf2009-08-24 13:09:20 -07004049 * {@link android.content.Intent#EXTRA_DOCK_STATE_UNDOCKED},
4050 * {@link android.content.Intent#EXTRA_DOCK_STATE_DESK}, or
Praveen Bharathi21e941b2010-10-06 15:23:14 -05004051 * {@link android.content.Intent#EXTRA_DOCK_STATE_CAR}, or
4052 * {@link android.content.Intent#EXTRA_DOCK_STATE_LE_DESK}, or
4053 * {@link android.content.Intent#EXTRA_DOCK_STATE_HE_DESK}.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05004054 */
4055 public static final String EXTRA_DOCK_STATE = "android.intent.extra.DOCK_STATE";
4056
4057 /**
4058 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
4059 * to represent that the phone is not in any dock.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05004060 */
4061 public static final int EXTRA_DOCK_STATE_UNDOCKED = 0;
4062
4063 /**
4064 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
4065 * to represent that the phone is in a desk dock.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05004066 */
4067 public static final int EXTRA_DOCK_STATE_DESK = 1;
4068
4069 /**
4070 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
4071 * to represent that the phone is in a car dock.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05004072 */
4073 public static final int EXTRA_DOCK_STATE_CAR = 2;
4074
4075 /**
Praveen Bharathi21e941b2010-10-06 15:23:14 -05004076 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
4077 * to represent that the phone is in a analog (low end) dock.
4078 */
4079 public static final int EXTRA_DOCK_STATE_LE_DESK = 3;
4080
4081 /**
4082 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
4083 * to represent that the phone is in a digital (high end) dock.
4084 */
4085 public static final int EXTRA_DOCK_STATE_HE_DESK = 4;
4086
4087 /**
Dianne Hackborn9bfb7072009-09-22 11:37:40 -07004088 * Boolean that can be supplied as meta-data with a dock activity, to
4089 * indicate that the dock should take over the home key when it is active.
4090 */
4091 public static final String METADATA_DOCK_HOME = "android.dock_home";
Tom Taylord4a47292009-12-21 13:59:18 -08004092
Dianne Hackborn9bfb7072009-09-22 11:37:40 -07004093 /**
Jacek Surazski86b6c532009-05-13 14:38:28 +02004094 * Used as a parcelable extra field in {@link #ACTION_APP_ERROR}, containing
4095 * the bug report.
Jacek Surazski86b6c532009-05-13 14:38:28 +02004096 */
4097 public static final String EXTRA_BUG_REPORT = "android.intent.extra.BUG_REPORT";
4098
4099 /**
Wei Huang97ecc9c2009-05-11 17:44:20 -07004100 * Used in the extra field in the remote intent. It's astring token passed with the
4101 * remote intent.
4102 */
4103 public static final String EXTRA_REMOTE_INTENT_TOKEN =
4104 "android.intent.extra.remote_intent_token";
4105
Suchi Amalapurapu0214e942009-09-02 11:03:18 -07004106 /**
Dianne Hackborn1d62ea92009-11-17 12:49:50 -08004107 * @deprecated See {@link #EXTRA_CHANGED_COMPONENT_NAME_LIST}; this field
Dianne Hackborn86a72da2009-11-11 20:12:41 -08004108 * will contain only the first name in the list.
Suchi Amalapurapu0214e942009-09-02 11:03:18 -07004109 */
Dianne Hackborn1d62ea92009-11-17 12:49:50 -08004110 @Deprecated public static final String EXTRA_CHANGED_COMPONENT_NAME =
Suchi Amalapurapu0214e942009-09-02 11:03:18 -07004111 "android.intent.extra.changed_component_name";
4112
Dianne Hackborndd9b82c2009-09-03 00:18:47 -07004113 /**
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08004114 * This field is part of {@link android.content.Intent#ACTION_PACKAGE_CHANGED},
Dianne Hackbornfd7aded2013-01-22 17:10:23 -08004115 * and contains a string array of all of the components that have changed. If
4116 * the state of the overall package has changed, then it will contain an entry
4117 * with the package name itself.
Dianne Hackborn86a72da2009-11-11 20:12:41 -08004118 */
4119 public static final String EXTRA_CHANGED_COMPONENT_NAME_LIST =
4120 "android.intent.extra.changed_component_name_list";
4121
4122 /**
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08004123 * This field is part of
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08004124 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_AVAILABLE},
Andrei Stingaceanu69d5ebc2016-01-14 12:59:03 +00004125 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE},
4126 * {@link android.content.Intent#ACTION_PACKAGES_SUSPENDED},
4127 * {@link android.content.Intent#ACTION_PACKAGES_UNSUSPENDED}
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08004128 * and contains a string array of all of the components that have changed.
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08004129 */
4130 public static final String EXTRA_CHANGED_PACKAGE_LIST =
4131 "android.intent.extra.changed_package_list";
4132
4133 /**
4134 * This field is part of
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08004135 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_AVAILABLE},
4136 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE}
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08004137 * and contains an integer array of uids of all of the components
4138 * that have changed.
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08004139 */
4140 public static final String EXTRA_CHANGED_UID_LIST =
4141 "android.intent.extra.changed_uid_list";
4142
4143 /**
Dianne Hackborndd9b82c2009-09-03 00:18:47 -07004144 * @hide
4145 * Magic extra system code can use when binding, to give a label for
4146 * who it is that has bound to a service. This is an integer giving
4147 * a framework string resource that can be displayed to the user.
4148 */
4149 public static final String EXTRA_CLIENT_LABEL =
4150 "android.intent.extra.client_label";
4151
4152 /**
4153 * @hide
4154 * Magic extra system code can use when binding, to give a PendingIntent object
4155 * that can be launched for the user to disable the system's use of this
4156 * service.
4157 */
4158 public static final String EXTRA_CLIENT_INTENT =
4159 "android.intent.extra.client_intent";
4160
Dianne Hackbornc4d0e6f2011-01-25 14:55:06 -08004161 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004162 * Extra used to indicate that an intent should only return data that is on
4163 * the local device. This is a boolean extra; the default is false. If true,
4164 * an implementation should only allow the user to select data that is
4165 * already on the device, not requiring it be downloaded from a remote
4166 * service when opened.
4167 *
4168 * @see #ACTION_GET_CONTENT
4169 * @see #ACTION_OPEN_DOCUMENT
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07004170 * @see #ACTION_OPEN_DOCUMENT_TREE
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004171 * @see #ACTION_CREATE_DOCUMENT
Dianne Hackbornc4d0e6f2011-01-25 14:55:06 -08004172 */
4173 public static final String EXTRA_LOCAL_ONLY =
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004174 "android.intent.extra.LOCAL_ONLY";
Daniel Lehmanna5b58df2011-10-12 16:24:22 -07004175
Amith Yamasani13593602012-03-22 16:16:17 -07004176 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004177 * Extra used to indicate that an intent can allow the user to select and
4178 * return multiple items. This is a boolean extra; the default is false. If
4179 * true, an implementation is allowed to present the user with a UI where
4180 * they can pick multiple items that are all returned to the caller. When
4181 * this happens, they should be returned as the {@link #getClipData()} part
4182 * of the result Intent.
4183 *
4184 * @see #ACTION_GET_CONTENT
4185 * @see #ACTION_OPEN_DOCUMENT
Dianne Hackbornfdb3f092013-01-28 15:10:48 -08004186 */
4187 public static final String EXTRA_ALLOW_MULTIPLE =
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004188 "android.intent.extra.ALLOW_MULTIPLE";
Dianne Hackbornfdb3f092013-01-28 15:10:48 -08004189
4190 /**
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01004191 * The integer userHandle carried with broadcast intents related to addition, removal and
4192 * switching of users and managed profiles - {@link #ACTION_USER_ADDED},
4193 * {@link #ACTION_USER_REMOVED} and {@link #ACTION_USER_SWITCHED}.
4194 *
Amith Yamasani13593602012-03-22 16:16:17 -07004195 * @hide
4196 */
Amith Yamasani2a003292012-08-14 18:25:45 -07004197 public static final String EXTRA_USER_HANDLE =
4198 "android.intent.extra.user_handle";
Jean-Michel Trivi3114ce32012-06-11 15:03:52 -07004199
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08004200 /**
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01004201 * The UserHandle carried with broadcasts intents related to addition and removal of managed
4202 * profiles - {@link #ACTION_MANAGED_PROFILE_ADDED} and {@link #ACTION_MANAGED_PROFILE_REMOVED}.
4203 */
4204 public static final String EXTRA_USER =
Alexandra Gherghina3315f6b2014-09-05 15:48:06 +01004205 "android.intent.extra.USER";
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01004206
4207 /**
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08004208 * Extra used in the response from a BroadcastReceiver that handles
Amith Yamasani7e99bc02013-04-16 18:24:51 -07004209 * {@link #ACTION_GET_RESTRICTION_ENTRIES}. The type of the extra is
4210 * <code>ArrayList&lt;RestrictionEntry&gt;</code>.
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08004211 */
Amith Yamasani7e99bc02013-04-16 18:24:51 -07004212 public static final String EXTRA_RESTRICTIONS_LIST = "android.intent.extra.restrictions_list";
4213
4214 /**
4215 * Extra sent in the intent to the BroadcastReceiver that handles
4216 * {@link #ACTION_GET_RESTRICTION_ENTRIES}. The type of the extra is a Bundle containing
4217 * the restrictions as key/value pairs.
4218 */
4219 public static final String EXTRA_RESTRICTIONS_BUNDLE =
4220 "android.intent.extra.restrictions_bundle";
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08004221
Amith Yamasani86118ba2013-03-28 14:33:16 -07004222 /**
4223 * Extra used in the response from a BroadcastReceiver that handles
4224 * {@link #ACTION_GET_RESTRICTION_ENTRIES}.
4225 */
4226 public static final String EXTRA_RESTRICTIONS_INTENT =
4227 "android.intent.extra.restrictions_intent";
4228
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07004229 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004230 * Extra used to communicate a set of acceptable MIME types. The type of the
4231 * extra is {@code String[]}. Values may be a combination of concrete MIME
4232 * types (such as "image/png") and/or partial MIME types (such as
4233 * "audio/*").
4234 *
4235 * @see #ACTION_GET_CONTENT
4236 * @see #ACTION_OPEN_DOCUMENT
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07004237 */
4238 public static final String EXTRA_MIME_TYPES = "android.intent.extra.MIME_TYPES";
4239
Dianne Hackborn57a7f592013-07-22 18:21:32 -07004240 /**
4241 * Optional extra for {@link #ACTION_SHUTDOWN} that allows the sender to qualify that
4242 * this shutdown is only for the user space of the system, not a complete shutdown.
Dianne Hackbornd318e0b2013-09-03 14:34:12 -07004243 * When this is true, hardware devices can use this information to determine that
4244 * they shouldn't do a complete shutdown of their device since this is not a
4245 * complete shutdown down to the kernel, but only user space restarting.
4246 * The default if not supplied is false.
Dianne Hackborn57a7f592013-07-22 18:21:32 -07004247 */
4248 public static final String EXTRA_SHUTDOWN_USERSPACE_ONLY
4249 = "android.intent.extra.SHUTDOWN_USERSPACE_ONLY";
4250
Narayan Kamathccb2a0862013-12-19 14:49:36 +00004251 /**
Neil Fullerb7146fe2016-11-15 16:52:15 +00004252 * Optional int extra for {@link #ACTION_TIME_CHANGED} that indicates the
4253 * user has set their time format preference. See {@link #EXTRA_TIME_PREF_VALUE_USE_12_HOUR},
4254 * {@link #EXTRA_TIME_PREF_VALUE_USE_24_HOUR} and
4255 * {@link #EXTRA_TIME_PREF_VALUE_USE_LOCALE_DEFAULT}. The value must not be negative.
Narayan Kamathccb2a0862013-12-19 14:49:36 +00004256 *
4257 * @hide for internal use only.
4258 */
4259 public static final String EXTRA_TIME_PREF_24_HOUR_FORMAT =
4260 "android.intent.extra.TIME_PREF_24_HOUR_FORMAT";
Neil Fullerb7146fe2016-11-15 16:52:15 +00004261 /** @hide */
4262 public static final int EXTRA_TIME_PREF_VALUE_USE_12_HOUR = 0;
4263 /** @hide */
4264 public static final int EXTRA_TIME_PREF_VALUE_USE_24_HOUR = 1;
4265 /** @hide */
4266 public static final int EXTRA_TIME_PREF_VALUE_USE_LOCALE_DEFAULT = 2;
Narayan Kamathccb2a0862013-12-19 14:49:36 +00004267
Jeff Sharkey004a4b22014-09-24 11:45:24 -07004268 /** {@hide} */
4269 public static final String EXTRA_REASON = "android.intent.extra.REASON";
4270
Rubin Xue8490f12015-06-25 12:17:48 +01004271 /** {@hide} */
4272 public static final String EXTRA_WIPE_EXTERNAL_STORAGE = "android.intent.extra.WIPE_EXTERNAL_STORAGE";
4273
Santos Cordon15a13782015-03-31 18:32:31 -07004274 /**
4275 * Optional {@link android.app.PendingIntent} extra used to deliver the result of the SIM
4276 * activation request.
4277 * TODO: Add information about the structure and response data used with the pending intent.
4278 * @hide
4279 */
4280 public static final String EXTRA_SIM_ACTIVATION_RESPONSE =
4281 "android.intent.extra.SIM_ACTIVATION_RESPONSE";
4282
Tomasz Mikolajewski319fb492016-01-20 12:24:01 +09004283 /**
4284 * Optional index with semantics depending on the intent action.
Tomasz Mikolajewskife023132016-03-10 17:42:35 +09004285 *
4286 * <p>The value must be an integer greater or equal to 0.
Tomasz Mikolajewski319fb492016-01-20 12:24:01 +09004287 */
Steve McKay6eaf38632015-08-04 10:11:01 -07004288 public static final String EXTRA_INDEX = "android.intent.extra.INDEX";
4289
Rubin Xu0a29ecd2015-11-04 15:11:48 +00004290 /**
4291 * Optional boolean extra indicating whether quiet mode has been switched on or off.
Rubin Xue95057a2016-04-01 16:49:25 +01004292 * When a profile goes into quiet mode, all apps in the profile are killed and the
4293 * profile user is stopped. Widgets originating from the profile are masked, and app
4294 * launcher icons are grayed out.
Rubin Xu0a29ecd2015-11-04 15:11:48 +00004295 */
4296 public static final String EXTRA_QUIET_MODE = "android.intent.extra.QUIET_MODE";
Dongwon Kang2034a4c2015-12-14 21:57:34 +09004297
4298 /**
Dongwon Kang32cb9ab2016-01-13 18:11:10 -08004299 * Used as an int extra field in {@link #ACTION_MEDIA_RESOURCE_GRANTED}
Dongwon Kang2034a4c2015-12-14 21:57:34 +09004300 * intents to specify the resource type granted. Possible values are
Dongwon Kang32cb9ab2016-01-13 18:11:10 -08004301 * {@link #EXTRA_MEDIA_RESOURCE_TYPE_VIDEO_CODEC} or
4302 * {@link #EXTRA_MEDIA_RESOURCE_TYPE_AUDIO_CODEC}.
Dongwon Kang2034a4c2015-12-14 21:57:34 +09004303 *
4304 * @hide
4305 */
4306 public static final String EXTRA_MEDIA_RESOURCE_TYPE =
4307 "android.intent.extra.MEDIA_RESOURCE_TYPE";
4308
4309 /**
Ben Lin145b0ca2016-10-14 14:23:40 -07004310 * Used as a boolean extra field in {@link #ACTION_CHOOSER} intents to specify
4311 * whether to show the chooser or not when there is only one application available
4312 * to choose from.
4313 *
4314 * @hide
4315 */
4316 public static final String EXTRA_AUTO_LAUNCH_SINGLE_CHOICE =
4317 "android.intent.extra.AUTO_LAUNCH_SINGLE_CHOICE";
4318
4319 /**
Dongwon Kang32cb9ab2016-01-13 18:11:10 -08004320 * Used as an int value for {@link #EXTRA_MEDIA_RESOURCE_TYPE}
Dongwon Kang2034a4c2015-12-14 21:57:34 +09004321 * to represent that a video codec is allowed to use.
4322 *
4323 * @hide
4324 */
4325 public static final int EXTRA_MEDIA_RESOURCE_TYPE_VIDEO_CODEC = 0;
4326
4327 /**
Dongwon Kang32cb9ab2016-01-13 18:11:10 -08004328 * Used as an int value for {@link #EXTRA_MEDIA_RESOURCE_TYPE}
Dongwon Kang2034a4c2015-12-14 21:57:34 +09004329 * to represent that a audio codec is allowed to use.
4330 *
4331 * @hide
4332 */
4333 public static final int EXTRA_MEDIA_RESOURCE_TYPE_AUDIO_CODEC = 1;
4334
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004335 // ---------------------------------------------------------------------
4336 // ---------------------------------------------------------------------
4337 // Intent flags (see mFlags variable).
4338
Tor Norbyed9273d62013-05-30 15:59:53 -07004339 /** @hide */
Jeff Sharkey846318a2014-04-04 12:12:41 -07004340 @IntDef(flag = true, value = {
4341 FLAG_GRANT_READ_URI_PERMISSION, FLAG_GRANT_WRITE_URI_PERMISSION,
4342 FLAG_GRANT_PERSISTABLE_URI_PERMISSION, FLAG_GRANT_PREFIX_URI_PERMISSION })
Tor Norbyed9273d62013-05-30 15:59:53 -07004343 @Retention(RetentionPolicy.SOURCE)
4344 public @interface GrantUriMode {}
4345
Jeff Sharkey846318a2014-04-04 12:12:41 -07004346 /** @hide */
4347 @IntDef(flag = true, value = {
4348 FLAG_GRANT_READ_URI_PERMISSION, FLAG_GRANT_WRITE_URI_PERMISSION })
4349 @Retention(RetentionPolicy.SOURCE)
4350 public @interface AccessUriMode {}
4351
4352 /**
4353 * Test if given mode flags specify an access mode, which must be at least
4354 * read and/or write.
4355 *
4356 * @hide
4357 */
4358 public static boolean isAccessUriMode(int modeFlags) {
4359 return (modeFlags & (Intent.FLAG_GRANT_READ_URI_PERMISSION
4360 | Intent.FLAG_GRANT_WRITE_URI_PERMISSION)) != 0;
4361 }
4362
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004363 /**
4364 * If set, the recipient of this Intent will be granted permission to
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004365 * perform read operations on the URI in the Intent's data and any URIs
Dianne Hackborn21c241e2012-03-08 13:57:23 -08004366 * specified in its ClipData. When applying to an Intent's ClipData,
4367 * all URIs as well as recursive traversals through data or other ClipData
4368 * in Intent items will be granted; only the grant flags of the top-level
4369 * Intent are used.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004370 */
4371 public static final int FLAG_GRANT_READ_URI_PERMISSION = 0x00000001;
4372 /**
4373 * If set, the recipient of this Intent will be granted permission to
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004374 * perform write operations on the URI in the Intent's data and any URIs
Dianne Hackborn21c241e2012-03-08 13:57:23 -08004375 * specified in its ClipData. When applying to an Intent's ClipData,
4376 * all URIs as well as recursive traversals through data or other ClipData
4377 * in Intent items will be granted; only the grant flags of the top-level
4378 * Intent are used.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004379 */
4380 public static final int FLAG_GRANT_WRITE_URI_PERMISSION = 0x00000002;
4381 /**
4382 * Can be set by the caller to indicate that this Intent is coming from
4383 * a background operation, not from direct user interaction.
4384 */
4385 public static final int FLAG_FROM_BACKGROUND = 0x00000004;
4386 /**
4387 * A flag you can enable for debugging: when set, log messages will be
4388 * printed during the resolution of this intent to show you what has
4389 * been found to create the final resolved list.
4390 */
4391 public static final int FLAG_DEBUG_LOG_RESOLUTION = 0x00000008;
Dianne Hackborne7f97212011-02-24 14:40:20 -08004392 /**
4393 * If set, this intent will not match any components in packages that
4394 * are currently stopped. If this is not set, then the default behavior
4395 * is to include such applications in the result.
4396 */
4397 public static final int FLAG_EXCLUDE_STOPPED_PACKAGES = 0x00000010;
4398 /**
4399 * If set, this intent will always match any components in packages that
4400 * are currently stopped. This is the default behavior when
4401 * {@link #FLAG_EXCLUDE_STOPPED_PACKAGES} is not set. If both of these
4402 * flags are set, this one wins (it allows overriding of exclude for
4403 * places where the framework may automatically set the exclude flag).
4404 */
4405 public static final int FLAG_INCLUDE_STOPPED_PACKAGES = 0x00000020;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004406
4407 /**
Jeff Sharkey328ebf22013-03-21 18:09:39 -07004408 * When combined with {@link #FLAG_GRANT_READ_URI_PERMISSION} and/or
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004409 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, the URI permission grant can be
Jeff Sharkeye66c1772013-09-20 14:30:59 -07004410 * persisted across device reboots until explicitly revoked with
4411 * {@link Context#revokeUriPermission(Uri, int)}. This flag only offers the
4412 * grant for possible persisting; the receiving application must call
4413 * {@link ContentResolver#takePersistableUriPermission(Uri, int)} to
4414 * actually persist.
4415 *
4416 * @see ContentResolver#takePersistableUriPermission(Uri, int)
4417 * @see ContentResolver#releasePersistableUriPermission(Uri, int)
4418 * @see ContentResolver#getPersistedUriPermissions()
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004419 * @see ContentResolver#getOutgoingPersistedUriPermissions()
Jeff Sharkey328ebf22013-03-21 18:09:39 -07004420 */
Jeff Sharkeye66c1772013-09-20 14:30:59 -07004421 public static final int FLAG_GRANT_PERSISTABLE_URI_PERMISSION = 0x00000040;
Jeff Sharkey328ebf22013-03-21 18:09:39 -07004422
4423 /**
Jeff Sharkey846318a2014-04-04 12:12:41 -07004424 * When combined with {@link #FLAG_GRANT_READ_URI_PERMISSION} and/or
4425 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, the URI permission grant
4426 * applies to any URI that is a prefix match against the original granted
4427 * URI. (Without this flag, the URI must match exactly for access to be
4428 * granted.) Another URI is considered a prefix match only when scheme,
4429 * authority, and all path segments defined by the prefix are an exact
4430 * match.
4431 */
4432 public static final int FLAG_GRANT_PREFIX_URI_PERMISSION = 0x00000080;
4433
4434 /**
Jeff Sharkey2a9e3f82015-12-18 10:57:58 -07004435 * Internal flag used to indicate that a system component has done their
Jeff Sharkey2f3e3532015-12-21 14:16:43 -07004436 * homework and verified that they correctly handle packages and components
4437 * that come and go over time. In particular:
4438 * <ul>
4439 * <li>Apps installed on external storage, which will appear to be
4440 * uninstalled while the the device is ejected.
4441 * <li>Apps with encryption unaware components, which will appear to not
4442 * exist while the device is locked.
4443 * </ul>
Jeff Sharkey2a9e3f82015-12-18 10:57:58 -07004444 *
4445 * @hide
4446 */
Jeff Sharkey2f3e3532015-12-21 14:16:43 -07004447 public static final int FLAG_DEBUG_TRIAGED_MISSING = 0x00000100;
Jeff Sharkey2a9e3f82015-12-18 10:57:58 -07004448
4449 /**
Todd Kennedy8e2d9d12016-06-28 14:09:55 -07004450 * Internal flag used to indicate ephemeral applications should not be
4451 * considered when resolving the intent.
4452 *
4453 * @hide
4454 */
4455 public static final int FLAG_IGNORE_EPHEMERAL = 0x00000200;
4456
4457 /**
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08004458 * If set, the new activity is not kept in the history stack. As soon as
4459 * the user navigates away from it, the activity is finished. This may also
4460 * be set with the {@link android.R.styleable#AndroidManifestActivity_noHistory
4461 * noHistory} attribute.
Ricardo Cervera92f6a742014-04-04 11:17:06 -07004462 *
4463 * <p>If set, {@link android.app.Activity#onActivityResult onActivityResult()}
4464 * is never invoked when the current activity starts a new activity which
4465 * sets a result and finishes.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004466 */
4467 public static final int FLAG_ACTIVITY_NO_HISTORY = 0x40000000;
4468 /**
4469 * If set, the activity will not be launched if it is already running
4470 * at the top of the history stack.
4471 */
4472 public static final int FLAG_ACTIVITY_SINGLE_TOP = 0x20000000;
4473 /**
4474 * If set, this activity will become the start of a new task on this
4475 * history stack. A task (from the activity that started it to the
4476 * next task activity) defines an atomic group of activities that the
4477 * user can move to. Tasks can be moved to the foreground and background;
4478 * all of the activities inside of a particular task always remain in
The Android Open Source Project10592532009-03-18 17:39:46 -07004479 * the same order. See
Scott Main7aee61f2011-02-08 11:25:01 -08004480 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
4481 * Stack</a> for more information about tasks.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004482 *
4483 * <p>This flag is generally used by activities that want
4484 * to present a "launcher" style behavior: they give the user a list of
4485 * separate things that can be done, which otherwise run completely
4486 * independently of the activity launching them.
4487 *
4488 * <p>When using this flag, if a task is already running for the activity
4489 * you are now starting, then a new activity will not be started; instead,
4490 * the current task will simply be brought to the front of the screen with
4491 * the state it was last in. See {@link #FLAG_ACTIVITY_MULTIPLE_TASK} for a flag
4492 * to disable this behavior.
4493 *
4494 * <p>This flag can not be used when the caller is requesting a result from
4495 * the activity being launched.
4496 */
4497 public static final int FLAG_ACTIVITY_NEW_TASK = 0x10000000;
4498 /**
Craig Mautnerd00f4742014-03-12 14:17:26 -07004499 * This flag is used to create a new task and launch an activity into it.
4500 * This flag is always paired with either {@link #FLAG_ACTIVITY_NEW_DOCUMENT}
4501 * or {@link #FLAG_ACTIVITY_NEW_TASK}. In both cases these flags alone would
4502 * search through existing tasks for ones matching this Intent. Only if no such
4503 * task is found would a new task be created. When paired with
4504 * FLAG_ACTIVITY_MULTIPLE_TASK both of these behaviors are modified to skip
4505 * the search for a matching task and unconditionally start a new task.
4506 *
4507 * <strong>When used with {@link #FLAG_ACTIVITY_NEW_TASK} do not use this
4508 * flag unless you are implementing your own
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004509 * top-level application launcher.</strong> Used in conjunction with
4510 * {@link #FLAG_ACTIVITY_NEW_TASK} to disable the
4511 * behavior of bringing an existing task to the foreground. When set,
4512 * a new task is <em>always</em> started to host the Activity for the
4513 * Intent, regardless of whether there is already an existing task running
4514 * the same thing.
4515 *
4516 * <p><strong>Because the default system does not include graphical task management,
4517 * you should not use this flag unless you provide some way for a user to
4518 * return back to the tasks you have launched.</strong>
The Android Open Source Project10592532009-03-18 17:39:46 -07004519 *
Craig Mautnerd00f4742014-03-12 14:17:26 -07004520 * See {@link #FLAG_ACTIVITY_NEW_DOCUMENT} for details of this flag's use for
4521 * creating new document tasks.
4522 *
4523 * <p>This flag is ignored if one of {@link #FLAG_ACTIVITY_NEW_TASK} or
Paul Soulos628cb742014-09-19 11:00:52 -07004524 * {@link #FLAG_ACTIVITY_NEW_DOCUMENT} is not also set.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004525 *
Scott Main7aee61f2011-02-08 11:25:01 -08004526 * <p>See
4527 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
4528 * Stack</a> for more information about tasks.
Craig Mautnerd00f4742014-03-12 14:17:26 -07004529 *
4530 * @see #FLAG_ACTIVITY_NEW_DOCUMENT
4531 * @see #FLAG_ACTIVITY_NEW_TASK
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004532 */
4533 public static final int FLAG_ACTIVITY_MULTIPLE_TASK = 0x08000000;
4534 /**
4535 * If set, and the activity being launched is already running in the
4536 * current task, then instead of launching a new instance of that activity,
4537 * all of the other activities on top of it will be closed and this Intent
4538 * will be delivered to the (now on top) old activity as a new Intent.
4539 *
4540 * <p>For example, consider a task consisting of the activities: A, B, C, D.
4541 * If D calls startActivity() with an Intent that resolves to the component
4542 * of activity B, then C and D will be finished and B receive the given
4543 * Intent, resulting in the stack now being: A, B.
4544 *
Dianne Hackbornaa52f9a2009-08-25 16:01:15 -07004545 * <p>The currently running instance of activity B in the above example will
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004546 * either receive the new intent you are starting here in its
4547 * onNewIntent() method, or be itself finished and restarted with the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004548 * new intent. If it has declared its launch mode to be "multiple" (the
Dianne Hackbornaa52f9a2009-08-25 16:01:15 -07004549 * default) and you have not set {@link #FLAG_ACTIVITY_SINGLE_TOP} in
4550 * the same intent, then it will be finished and re-created; for all other
4551 * launch modes or if {@link #FLAG_ACTIVITY_SINGLE_TOP} is set then this
4552 * Intent will be delivered to the current instance's onNewIntent().
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004553 *
4554 * <p>This launch mode can also be used to good effect in conjunction with
4555 * {@link #FLAG_ACTIVITY_NEW_TASK}: if used to start the root activity
4556 * of a task, it will bring any currently running instance of that task
4557 * to the foreground, and then clear it to its root state. This is
4558 * especially useful, for example, when launching an activity from the
4559 * notification manager.
4560 *
Scott Main7aee61f2011-02-08 11:25:01 -08004561 * <p>See
4562 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
4563 * Stack</a> for more information about tasks.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004564 */
4565 public static final int FLAG_ACTIVITY_CLEAR_TOP = 0x04000000;
4566 /**
4567 * If set and this intent is being used to launch a new activity from an
4568 * existing one, then the reply target of the existing activity will be
4569 * transfered to the new activity. This way the new activity can call
4570 * {@link android.app.Activity#setResult} and have that result sent back to
4571 * the reply target of the original activity.
4572 */
4573 public static final int FLAG_ACTIVITY_FORWARD_RESULT = 0x02000000;
4574 /**
4575 * If set and this intent is being used to launch a new activity from an
4576 * existing one, the current activity will not be counted as the top
4577 * activity for deciding whether the new intent should be delivered to
4578 * the top instead of starting a new one. The previous activity will
4579 * be used as the top, with the assumption being that the current activity
4580 * will finish itself immediately.
4581 */
4582 public static final int FLAG_ACTIVITY_PREVIOUS_IS_TOP = 0x01000000;
4583 /**
4584 * If set, the new activity is not kept in the list of recently launched
4585 * activities.
4586 */
4587 public static final int FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS = 0x00800000;
4588 /**
4589 * This flag is not normally set by application code, but set for you by
4590 * the system as described in the
4591 * {@link android.R.styleable#AndroidManifestActivity_launchMode
4592 * launchMode} documentation for the singleTask mode.
4593 */
4594 public static final int FLAG_ACTIVITY_BROUGHT_TO_FRONT = 0x00400000;
4595 /**
4596 * If set, and this activity is either being started in a new task or
4597 * bringing to the top an existing task, then it will be launched as
4598 * the front door of the task. This will result in the application of
4599 * any affinities needed to have that task in the proper state (either
4600 * moving activities to or from it), or simply resetting that task to
4601 * its initial state if needed.
4602 */
4603 public static final int FLAG_ACTIVITY_RESET_TASK_IF_NEEDED = 0x00200000;
4604 /**
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08004605 * This flag is not normally set by application code, but set for you by
4606 * the system if this activity is being launched from history
4607 * (longpress home key).
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004608 */
4609 public static final int FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY = 0x00100000;
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08004610 /**
Craig Mautnerf357c0c2014-06-09 09:23:27 -07004611 * @deprecated As of API 21 this performs identically to
4612 * {@link #FLAG_ACTIVITY_NEW_DOCUMENT} which should be used instead of this.
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08004613 */
Aurimas Liutikas514c5ef2016-05-24 15:22:55 -07004614 @Deprecated
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08004615 public static final int FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET = 0x00080000;
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08004616 /**
Craig Mautner026596b2014-05-21 15:35:44 -07004617 * This flag is used to open a document into a new task rooted at the activity launched
4618 * by this Intent. Through the use of this flag, or its equivalent attribute,
4619 * {@link android.R.attr#documentLaunchMode} multiple instances of the same activity
Chet Haase0d1c27a2014-11-03 18:35:16 +00004620 * containing different documents will appear in the recent tasks list.
Craig Mautnerd00f4742014-03-12 14:17:26 -07004621 *
Craig Mautner026596b2014-05-21 15:35:44 -07004622 * <p>The use of the activity attribute form of this,
4623 * {@link android.R.attr#documentLaunchMode}, is
4624 * preferred over the Intent flag described here. The attribute form allows the
4625 * Activity to specify multiple document behavior for all launchers of the Activity
4626 * whereas using this flag requires each Intent that launches the Activity to specify it.
Craig Mautnerd00f4742014-03-12 14:17:26 -07004627 *
Dianne Hackborn13420f22014-07-18 15:43:56 -07004628 * <p>Note that the default semantics of this flag w.r.t. whether the recents entry for
4629 * it is kept after the activity is finished is different than the use of
4630 * {@link #FLAG_ACTIVITY_NEW_TASK} and {@link android.R.attr#documentLaunchMode} -- if
4631 * this flag is being used to create a new recents entry, then by default that entry
4632 * will be removed once the activity is finished. You can modify this behavior with
4633 * {@link #FLAG_ACTIVITY_RETAIN_IN_RECENTS}.
4634 *
Craig Mautner026596b2014-05-21 15:35:44 -07004635 * <p>FLAG_ACTIVITY_NEW_DOCUMENT may be used in conjunction with {@link
4636 * #FLAG_ACTIVITY_MULTIPLE_TASK}. When used alone it is the
4637 * equivalent of the Activity manifest specifying {@link
4638 * android.R.attr#documentLaunchMode}="intoExisting". When used with
4639 * FLAG_ACTIVITY_MULTIPLE_TASK it is the equivalent of the Activity manifest specifying
4640 * {@link android.R.attr#documentLaunchMode}="always".
Craig Mautnerd00f4742014-03-12 14:17:26 -07004641 *
Craig Mautner026596b2014-05-21 15:35:44 -07004642 * Refer to {@link android.R.attr#documentLaunchMode} for more information.
Craig Mautnerd00f4742014-03-12 14:17:26 -07004643 *
Craig Mautner026596b2014-05-21 15:35:44 -07004644 * @see android.R.attr#documentLaunchMode
Craig Mautnerd00f4742014-03-12 14:17:26 -07004645 * @see #FLAG_ACTIVITY_MULTIPLE_TASK
4646 */
Craig Mautnerf357c0c2014-06-09 09:23:27 -07004647 public static final int FLAG_ACTIVITY_NEW_DOCUMENT = FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET;
Craig Mautnerd00f4742014-03-12 14:17:26 -07004648 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004649 * If set, this flag will prevent the normal {@link android.app.Activity#onUserLeaveHint}
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08004650 * callback from occurring on the current frontmost activity before it is
4651 * paused as the newly-started activity is brought to the front.
The Android Open Source Project10592532009-03-18 17:39:46 -07004652 *
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08004653 * <p>Typically, an activity can rely on that callback to indicate that an
4654 * explicit user action has caused their activity to be moved out of the
4655 * foreground. The callback marks an appropriate point in the activity's
4656 * lifecycle for it to dismiss any notifications that it intends to display
4657 * "until the user has seen them," such as a blinking LED.
The Android Open Source Project10592532009-03-18 17:39:46 -07004658 *
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08004659 * <p>If an activity is ever started via any non-user-driven events such as
4660 * phone-call receipt or an alarm handler, this flag should be passed to {@link
4661 * Context#startActivity Context.startActivity}, ensuring that the pausing
The Android Open Source Project10592532009-03-18 17:39:46 -07004662 * activity does not think the user has acknowledged its notification.
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08004663 */
4664 public static final int FLAG_ACTIVITY_NO_USER_ACTION = 0x00040000;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004665 /**
4666 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
4667 * this flag will cause the launched activity to be brought to the front of its
4668 * task's history stack if it is already running.
The Android Open Source Project10592532009-03-18 17:39:46 -07004669 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004670 * <p>For example, consider a task consisting of four activities: A, B, C, D.
4671 * If D calls startActivity() with an Intent that resolves to the component
4672 * of activity B, then B will be brought to the front of the history stack,
4673 * with this resulting order: A, C, D, B.
The Android Open Source Project10592532009-03-18 17:39:46 -07004674 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004675 * This flag will be ignored if {@link #FLAG_ACTIVITY_CLEAR_TOP} is also
The Android Open Source Project10592532009-03-18 17:39:46 -07004676 * specified.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004677 */
4678 public static final int FLAG_ACTIVITY_REORDER_TO_FRONT = 0X00020000;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004679 /**
Dianne Hackbornbfe319e2009-09-21 00:34:05 -07004680 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
4681 * this flag will prevent the system from applying an activity transition
4682 * animation to go to the next activity state. This doesn't mean an
4683 * animation will never run -- if another activity change happens that doesn't
4684 * specify this flag before the activity started here is displayed, then
Dianne Hackborn621e17d2010-11-22 15:59:56 -08004685 * that transition will be used. This flag can be put to good use
Dianne Hackbornbfe319e2009-09-21 00:34:05 -07004686 * when you are going to do a series of activity operations but the
4687 * animation seen by the user shouldn't be driven by the first activity
4688 * change but rather a later one.
4689 */
4690 public static final int FLAG_ACTIVITY_NO_ANIMATION = 0X00010000;
4691 /**
Dianne Hackborn621e17d2010-11-22 15:59:56 -08004692 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
4693 * this flag will cause any existing task that would be associated with the
4694 * activity to be cleared before the activity is started. That is, the activity
4695 * becomes the new root of an otherwise empty task, and any old activities
4696 * are finished. This can only be used in conjunction with {@link #FLAG_ACTIVITY_NEW_TASK}.
4697 */
4698 public static final int FLAG_ACTIVITY_CLEAR_TASK = 0X00008000;
4699 /**
4700 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
4701 * this flag will cause a newly launching task to be placed on top of the current
4702 * home activity task (if there is one). That is, pressing back from the task
4703 * will always return the user to home even if that was not the last activity they
4704 * saw. This can only be used in conjunction with {@link #FLAG_ACTIVITY_NEW_TASK}.
4705 */
4706 public static final int FLAG_ACTIVITY_TASK_ON_HOME = 0X00004000;
4707 /**
Dianne Hackborn13420f22014-07-18 15:43:56 -07004708 * By default a document created by {@link #FLAG_ACTIVITY_NEW_DOCUMENT} will
4709 * have its entry in recent tasks removed when the user closes it (with back
Jeff Sharkey9f991a22014-08-13 11:37:41 -07004710 * or however else it may finish()). If you would like to instead allow the
Dianne Hackborn13420f22014-07-18 15:43:56 -07004711 * document to be kept in recents so that it can be re-launched, you can use
Jeff Sharkey9f991a22014-08-13 11:37:41 -07004712 * this flag. When set and the task's activity is finished, the recents
4713 * entry will remain in the interface for the user to re-launch it, like a
4714 * recents entry for a top-level application.
4715 * <p>
4716 * The receiving activity can override this request with
4717 * {@link android.R.attr#autoRemoveFromRecents} or by explcitly calling
4718 * {@link android.app.Activity#finishAndRemoveTask()
Dianne Hackborn13420f22014-07-18 15:43:56 -07004719 * Activity.finishAndRemoveTask()}.
Craig Mautner2dac0562014-05-06 09:06:44 -07004720 */
Dianne Hackborn13420f22014-07-18 15:43:56 -07004721 public static final int FLAG_ACTIVITY_RETAIN_IN_RECENTS = 0x00002000;
Craig Mautnera228ae92014-07-09 05:44:55 -07004722
4723 /**
Wale Ogunwale2a25a622016-01-30 11:27:21 -08004724 * This flag is only used in split-screen multi-window mode. The new activity will be displayed
4725 * adjacent to the one launching it. This can only be used in conjunction with
Wale Ogunwale6bdf2572016-03-11 15:22:38 -08004726 * {@link #FLAG_ACTIVITY_NEW_TASK}. Also, setting {@link #FLAG_ACTIVITY_MULTIPLE_TASK} is
4727 * required if you want a new instance of an existing activity to be created.
Filip Gruszczynski80e29f12015-12-14 14:58:30 -08004728 */
Wale Ogunwale2a25a622016-01-30 11:27:21 -08004729 public static final int FLAG_ACTIVITY_LAUNCH_ADJACENT = 0x00001000;
Filip Gruszczynski80e29f12015-12-14 14:58:30 -08004730
4731 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004732 * If set, when sending a broadcast only registered receivers will be
4733 * called -- no BroadcastReceiver components will be launched.
4734 */
4735 public static final int FLAG_RECEIVER_REGISTERED_ONLY = 0x40000000;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004736 /**
Dianne Hackborn1c633fc2009-12-08 19:45:14 -08004737 * If set, when sending a broadcast the new broadcast will replace
4738 * any existing pending broadcast that matches it. Matching is defined
4739 * by {@link Intent#filterEquals(Intent) Intent.filterEquals} returning
4740 * true for the intents of the two broadcasts. When a match is found,
4741 * the new broadcast (and receivers associated with it) will replace the
4742 * existing one in the pending broadcast list, remaining at the same
4743 * position in the list.
Tom Taylord4a47292009-12-21 13:59:18 -08004744 *
Dianne Hackborn1c633fc2009-12-08 19:45:14 -08004745 * <p>This flag is most typically used with sticky broadcasts, which
4746 * only care about delivering the most recent values of the broadcast
4747 * to their receivers.
4748 */
4749 public static final int FLAG_RECEIVER_REPLACE_PENDING = 0x20000000;
4750 /**
Christopher Tatef46723b2012-01-26 14:19:24 -08004751 * If set, when sending a broadcast the recipient is allowed to run at
4752 * foreground priority, with a shorter timeout interval. During normal
4753 * broadcasts the receivers are not automatically hoisted out of the
4754 * background priority class.
4755 */
4756 public static final int FLAG_RECEIVER_FOREGROUND = 0x10000000;
4757 /**
Dianne Hackborn6285a322013-09-18 12:09:47 -07004758 * If this is an ordered broadcast, don't allow receivers to abort the broadcast.
4759 * They can still propagate results through to later receivers, but they can not prevent
4760 * later receivers from seeing the broadcast.
4761 */
4762 public static final int FLAG_RECEIVER_NO_ABORT = 0x08000000;
4763 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004764 * If set, when sending a broadcast <i>before boot has completed</i> only
4765 * registered receivers will be called -- no BroadcastReceiver components
4766 * will be launched. Sticky intent state will be recorded properly even
4767 * if no receivers wind up being called. If {@link #FLAG_RECEIVER_REGISTERED_ONLY}
4768 * is specified in the broadcast intent, this flag is unnecessary.
The Android Open Source Project10592532009-03-18 17:39:46 -07004769 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004770 * <p>This flag is only for use by system sevices as a convenience to
4771 * avoid having to implement a more complex mechanism around detection
4772 * of boot completion.
The Android Open Source Project10592532009-03-18 17:39:46 -07004773 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004774 * @hide
4775 */
Dianne Hackborn6285a322013-09-18 12:09:47 -07004776 public static final int FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT = 0x04000000;
Dianne Hackborn9acc0302009-08-25 00:27:12 -07004777 /**
4778 * Set when this broadcast is for a boot upgrade, a special mode that
4779 * allows the broadcast to be sent before the system is ready and launches
4780 * the app process with no providers running in it.
4781 * @hide
4782 */
Dianne Hackborn6285a322013-09-18 12:09:47 -07004783 public static final int FLAG_RECEIVER_BOOT_UPGRADE = 0x02000000;
Dianne Hackborn6ac42ae2015-12-08 17:22:10 -08004784 /**
4785 * If set, the broadcast will always go to manifest receivers in background (cached
4786 * or not running) apps, regardless of whether that would be done by default. By
4787 * default they will only receive broadcasts if the broadcast has specified an
4788 * explicit component or package name.
4789 * @hide
4790 */
4791 public static final int FLAG_RECEIVER_INCLUDE_BACKGROUND = 0x01000000;
4792 /**
4793 * If set, the broadcast will never go to manifest receivers in background (cached
4794 * or not running) apps, regardless of whether that would be done by default. By
4795 * default they will receive broadcasts if the broadcast has specified an
4796 * explicit component or package name.
4797 * @hide
4798 */
4799 public static final int FLAG_RECEIVER_EXCLUDE_BACKGROUND = 0x00800000;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004800
Dianne Hackbornfa82f222009-09-17 15:14:12 -07004801 /**
4802 * @hide Flags that can't be changed with PendingIntent.
4803 */
Jeff Sharkey846318a2014-04-04 12:12:41 -07004804 public static final int IMMUTABLE_FLAGS = FLAG_GRANT_READ_URI_PERMISSION
4805 | FLAG_GRANT_WRITE_URI_PERMISSION | FLAG_GRANT_PERSISTABLE_URI_PERMISSION
4806 | FLAG_GRANT_PREFIX_URI_PERMISSION;
Tom Taylord4a47292009-12-21 13:59:18 -08004807
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004808 // ---------------------------------------------------------------------
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004809 // ---------------------------------------------------------------------
4810 // toUri() and parseUri() options.
4811
4812 /**
4813 * Flag for use with {@link #toUri} and {@link #parseUri}: the URI string
4814 * always has the "intent:" scheme. This syntax can be used when you want
4815 * to later disambiguate between URIs that are intended to describe an
4816 * Intent vs. all others that should be treated as raw URIs. When used
4817 * with {@link #parseUri}, any other scheme will result in a generic
4818 * VIEW action for that raw URI.
4819 */
4820 public static final int URI_INTENT_SCHEME = 1<<0;
Tom Taylord4a47292009-12-21 13:59:18 -08004821
Dianne Hackborn85d558c2014-11-04 10:31:54 -08004822 /**
4823 * Flag for use with {@link #toUri} and {@link #parseUri}: the URI string
4824 * always has the "android-app:" scheme. This is a variation of
4825 * {@link #URI_INTENT_SCHEME} whose format is simpler for the case of an
4826 * http/https URI being delivered to a specific package name. The format
4827 * is:
4828 *
4829 * <pre class="prettyprint">
Dianne Hackborn0ee10f62015-01-14 16:16:13 -08004830 * android-app://{package_id}[/{scheme}[/{host}[/{path}]]][#Intent;{...}]</pre>
Dianne Hackborn85d558c2014-11-04 10:31:54 -08004831 *
Dianne Hackborn0ee10f62015-01-14 16:16:13 -08004832 * <p>In this scheme, only the <code>package_id</code> is required. If you include a host,
4833 * you must also include a scheme; including a path also requires both a host and a scheme.
4834 * The final #Intent; fragment can be used without a scheme, host, or path.
4835 * Note that this can not be
Dianne Hackborn85d558c2014-11-04 10:31:54 -08004836 * used with intents that have a {@link #setSelector}, since the base intent
4837 * will always have an explicit package name.</p>
4838 *
4839 * <p>Some examples of how this scheme maps to Intent objects:</p>
4840 * <table border="2" width="85%" align="center" frame="hsides" rules="rows">
4841 * <colgroup align="left" />
4842 * <colgroup align="left" />
4843 * <thead>
4844 * <tr><th>URI</th> <th>Intent</th></tr>
4845 * </thead>
4846 *
4847 * <tbody>
4848 * <tr><td><code>android-app://com.example.app</code></td>
4849 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
4850 * <tr><td>Action: </td><td>{@link #ACTION_MAIN}</td></tr>
4851 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
4852 * </table></td>
4853 * </tr>
4854 * <tr><td><code>android-app://com.example.app/http/example.com</code></td>
4855 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
4856 * <tr><td>Action: </td><td>{@link #ACTION_VIEW}</td></tr>
4857 * <tr><td>Data: </td><td><code>http://example.com/</code></td></tr>
4858 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
4859 * </table></td>
4860 * </tr>
4861 * <tr><td><code>android-app://com.example.app/http/example.com/foo?1234</code></td>
4862 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
4863 * <tr><td>Action: </td><td>{@link #ACTION_VIEW}</td></tr>
4864 * <tr><td>Data: </td><td><code>http://example.com/foo?1234</code></td></tr>
4865 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
4866 * </table></td>
4867 * </tr>
4868 * <tr><td><code>android-app://com.example.app/<br />#Intent;action=com.example.MY_ACTION;end</code></td>
4869 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
4870 * <tr><td>Action: </td><td><code>com.example.MY_ACTION</code></td></tr>
4871 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
4872 * </table></td>
4873 * </tr>
4874 * <tr><td><code>android-app://com.example.app/http/example.com/foo?1234<br />#Intent;action=com.example.MY_ACTION;end</code></td>
4875 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
4876 * <tr><td>Action: </td><td><code>com.example.MY_ACTION</code></td></tr>
4877 * <tr><td>Data: </td><td><code>http://example.com/foo?1234</code></td></tr>
4878 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
4879 * </table></td>
4880 * </tr>
4881 * <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>
4882 * <td><table border="" style="margin:0" >
4883 * <tr><td>Action: </td><td><code>com.example.MY_ACTION</code></td></tr>
4884 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
4885 * <tr><td>Extras: </td><td><code>some_int=(int)100<br />some_str=(String)hello</code></td></tr>
4886 * </table></td>
4887 * </tr>
4888 * </tbody>
4889 * </table>
4890 */
4891 public static final int URI_ANDROID_APP_SCHEME = 1<<1;
4892
Dianne Hackborn24b1c232014-11-20 17:17:39 -08004893 /**
4894 * Flag for use with {@link #toUri} and {@link #parseUri}: allow parsing
4895 * of unsafe information. In particular, the flags {@link #FLAG_GRANT_READ_URI_PERMISSION},
4896 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, {@link #FLAG_GRANT_PERSISTABLE_URI_PERMISSION},
4897 * and {@link #FLAG_GRANT_PREFIX_URI_PERMISSION} flags can not be set, so that the
4898 * generated Intent can not cause unexpected data access to happen.
4899 *
4900 * <p>If you do not trust the source of the URI being parsed, you should still do further
4901 * processing to protect yourself from it. In particular, when using it to start an
4902 * activity you should usually add in {@link #CATEGORY_BROWSABLE} to limit the activities
4903 * that can handle it.</p>
4904 */
4905 public static final int URI_ALLOW_UNSAFE = 1<<2;
4906
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004907 // ---------------------------------------------------------------------
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004908
4909 private String mAction;
4910 private Uri mData;
4911 private String mType;
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004912 private String mPackage;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004913 private ComponentName mComponent;
4914 private int mFlags;
Dianne Hackbornadd005c2013-07-17 18:43:12 -07004915 private ArraySet<String> mCategories;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004916 private Bundle mExtras;
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08004917 private Rect mSourceBounds;
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004918 private Intent mSelector;
Dianne Hackborn21c241e2012-03-08 13:57:23 -08004919 private ClipData mClipData;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01004920 private int mContentUserHint = UserHandle.USER_CURRENT;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004921
4922 // ---------------------------------------------------------------------
4923
4924 /**
4925 * Create an empty intent.
4926 */
4927 public Intent() {
4928 }
4929
4930 /**
4931 * Copy constructor.
4932 */
4933 public Intent(Intent o) {
4934 this.mAction = o.mAction;
4935 this.mData = o.mData;
4936 this.mType = o.mType;
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004937 this.mPackage = o.mPackage;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004938 this.mComponent = o.mComponent;
4939 this.mFlags = o.mFlags;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01004940 this.mContentUserHint = o.mContentUserHint;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004941 if (o.mCategories != null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07004942 this.mCategories = new ArraySet<String>(o.mCategories);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004943 }
4944 if (o.mExtras != null) {
4945 this.mExtras = new Bundle(o.mExtras);
4946 }
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08004947 if (o.mSourceBounds != null) {
4948 this.mSourceBounds = new Rect(o.mSourceBounds);
4949 }
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004950 if (o.mSelector != null) {
4951 this.mSelector = new Intent(o.mSelector);
4952 }
Dianne Hackborn21c241e2012-03-08 13:57:23 -08004953 if (o.mClipData != null) {
4954 this.mClipData = new ClipData(o.mClipData);
4955 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004956 }
4957
4958 @Override
4959 public Object clone() {
4960 return new Intent(this);
4961 }
4962
4963 private Intent(Intent o, boolean all) {
4964 this.mAction = o.mAction;
4965 this.mData = o.mData;
4966 this.mType = o.mType;
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004967 this.mPackage = o.mPackage;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004968 this.mComponent = o.mComponent;
4969 if (o.mCategories != null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07004970 this.mCategories = new ArraySet<String>(o.mCategories);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004971 }
4972 }
4973
4974 /**
4975 * Make a clone of only the parts of the Intent that are relevant for
4976 * filter matching: the action, data, type, component, and categories.
4977 */
4978 public Intent cloneFilter() {
4979 return new Intent(this, false);
4980 }
4981
4982 /**
4983 * Create an intent with a given action. All other fields (data, type,
4984 * class) are null. Note that the action <em>must</em> be in a
4985 * namespace because Intents are used globally in the system -- for
4986 * example the system VIEW action is android.intent.action.VIEW; an
4987 * application's custom action would be something like
4988 * com.google.app.myapp.CUSTOM_ACTION.
4989 *
4990 * @param action The Intent action, such as ACTION_VIEW.
4991 */
4992 public Intent(String action) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08004993 setAction(action);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004994 }
4995
4996 /**
4997 * Create an intent with a given action and for a given data url. Note
4998 * that the action <em>must</em> be in a namespace because Intents are
4999 * used globally in the system -- for example the system VIEW action is
5000 * android.intent.action.VIEW; an application's custom action would be
5001 * something like com.google.app.myapp.CUSTOM_ACTION.
5002 *
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07005003 * <p><em>Note: scheme and host name matching in the Android framework is
5004 * case-sensitive, unlike the formal RFC. As a result,
5005 * you should always ensure that you write your Uri with these elements
5006 * using lower case letters, and normalize any Uris you receive from
5007 * outside of Android to ensure the scheme and host is lower case.</em></p>
5008 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005009 * @param action The Intent action, such as ACTION_VIEW.
5010 * @param uri The Intent data URI.
5011 */
5012 public Intent(String action, Uri uri) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08005013 setAction(action);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005014 mData = uri;
5015 }
5016
5017 /**
5018 * Create an intent for a specific component. All other fields (action, data,
5019 * type, class) are null, though they can be modified later with explicit
5020 * calls. This provides a convenient way to create an intent that is
5021 * intended to execute a hard-coded class name, rather than relying on the
5022 * system to find an appropriate class for you; see {@link #setComponent}
5023 * for more information on the repercussions of this.
5024 *
5025 * @param packageContext A Context of the application package implementing
5026 * this class.
5027 * @param cls The component class that is to be used for the intent.
5028 *
5029 * @see #setClass
5030 * @see #setComponent
5031 * @see #Intent(String, android.net.Uri , Context, Class)
5032 */
5033 public Intent(Context packageContext, Class<?> cls) {
5034 mComponent = new ComponentName(packageContext, cls);
5035 }
5036
5037 /**
5038 * Create an intent for a specific component with a specified action and data.
Craig Mautner2dac0562014-05-06 09:06:44 -07005039 * This is equivalent to using {@link #Intent(String, android.net.Uri)} to
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005040 * construct the Intent and then calling {@link #setClass} to set its
5041 * class.
5042 *
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07005043 * <p><em>Note: scheme and host name matching in the Android framework is
5044 * case-sensitive, unlike the formal RFC. As a result,
5045 * you should always ensure that you write your Uri with these elements
5046 * using lower case letters, and normalize any Uris you receive from
5047 * outside of Android to ensure the scheme and host is lower case.</em></p>
5048 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005049 * @param action The Intent action, such as ACTION_VIEW.
5050 * @param uri The Intent data URI.
5051 * @param packageContext A Context of the application package implementing
5052 * this class.
5053 * @param cls The component class that is to be used for the intent.
5054 *
5055 * @see #Intent(String, android.net.Uri)
5056 * @see #Intent(Context, Class)
5057 * @see #setClass
5058 * @see #setComponent
5059 */
5060 public Intent(String action, Uri uri,
5061 Context packageContext, Class<?> cls) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08005062 setAction(action);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005063 mData = uri;
5064 mComponent = new ComponentName(packageContext, cls);
5065 }
5066
5067 /**
Dianne Hackborn30d71892010-12-11 10:37:55 -08005068 * Create an intent to launch the main (root) activity of a task. This
5069 * is the Intent that is started when the application's is launched from
5070 * Home. For anything else that wants to launch an application in the
5071 * same way, it is important that they use an Intent structured the same
5072 * way, and can use this function to ensure this is the case.
5073 *
5074 * <p>The returned Intent has the given Activity component as its explicit
5075 * component, {@link #ACTION_MAIN} as its action, and includes the
5076 * category {@link #CATEGORY_LAUNCHER}. This does <em>not</em> have
5077 * {@link #FLAG_ACTIVITY_NEW_TASK} set, though typically you will want
5078 * to do that through {@link #addFlags(int)} on the returned Intent.
5079 *
5080 * @param mainActivity The main activity component that this Intent will
5081 * launch.
5082 * @return Returns a newly created Intent that can be used to launch the
5083 * activity as a main application entry.
5084 *
5085 * @see #setClass
5086 * @see #setComponent
5087 */
5088 public static Intent makeMainActivity(ComponentName mainActivity) {
5089 Intent intent = new Intent(ACTION_MAIN);
5090 intent.setComponent(mainActivity);
5091 intent.addCategory(CATEGORY_LAUNCHER);
5092 return intent;
5093 }
5094
5095 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005096 * Make an Intent for the main activity of an application, without
5097 * specifying a specific activity to run but giving a selector to find
5098 * the activity. This results in a final Intent that is structured
5099 * the same as when the application is launched from
5100 * Home. For anything else that wants to launch an application in the
5101 * same way, it is important that they use an Intent structured the same
5102 * way, and can use this function to ensure this is the case.
5103 *
5104 * <p>The returned Intent has {@link #ACTION_MAIN} as its action, and includes the
5105 * category {@link #CATEGORY_LAUNCHER}. This does <em>not</em> have
5106 * {@link #FLAG_ACTIVITY_NEW_TASK} set, though typically you will want
5107 * to do that through {@link #addFlags(int)} on the returned Intent.
5108 *
5109 * @param selectorAction The action name of the Intent's selector.
5110 * @param selectorCategory The name of a category to add to the Intent's
5111 * selector.
5112 * @return Returns a newly created Intent that can be used to launch the
5113 * activity as a main application entry.
5114 *
5115 * @see #setSelector(Intent)
5116 */
5117 public static Intent makeMainSelectorActivity(String selectorAction,
5118 String selectorCategory) {
5119 Intent intent = new Intent(ACTION_MAIN);
5120 intent.addCategory(CATEGORY_LAUNCHER);
5121 Intent selector = new Intent();
5122 selector.setAction(selectorAction);
5123 selector.addCategory(selectorCategory);
5124 intent.setSelector(selector);
5125 return intent;
5126 }
5127
5128 /**
Dianne Hackborn30d71892010-12-11 10:37:55 -08005129 * Make an Intent that can be used to re-launch an application's task
5130 * in its base state. This is like {@link #makeMainActivity(ComponentName)},
5131 * but also sets the flags {@link #FLAG_ACTIVITY_NEW_TASK} and
5132 * {@link #FLAG_ACTIVITY_CLEAR_TASK}.
5133 *
5134 * @param mainActivity The activity component that is the root of the
5135 * task; this is the activity that has been published in the application's
5136 * manifest as the main launcher icon.
5137 *
5138 * @return Returns a newly created Intent that can be used to relaunch the
5139 * activity's task in its root state.
5140 */
5141 public static Intent makeRestartActivityTask(ComponentName mainActivity) {
5142 Intent intent = makeMainActivity(mainActivity);
5143 intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK
5144 | Intent.FLAG_ACTIVITY_CLEAR_TASK);
5145 return intent;
5146 }
5147
5148 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005149 * Call {@link #parseUri} with 0 flags.
5150 * @deprecated Use {@link #parseUri} instead.
5151 */
5152 @Deprecated
5153 public static Intent getIntent(String uri) throws URISyntaxException {
5154 return parseUri(uri, 0);
5155 }
Tom Taylord4a47292009-12-21 13:59:18 -08005156
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005157 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005158 * Create an intent from a URI. This URI may encode the action,
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005159 * category, and other intent fields, if it was returned by
Dianne Hackborn7f205432009-07-28 00:13:47 -07005160 * {@link #toUri}. If the Intent was not generate by toUri(), its data
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005161 * will be the entire URI and its action will be ACTION_VIEW.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005162 *
5163 * <p>The URI given here must not be relative -- that is, it must include
5164 * the scheme and full path.
5165 *
5166 * @param uri The URI to turn into an Intent.
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005167 * @param flags Additional processing flags. Either 0,
5168 * {@link #URI_INTENT_SCHEME}, or {@link #URI_ANDROID_APP_SCHEME}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005169 *
5170 * @return Intent The newly created Intent object.
5171 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005172 * @throws URISyntaxException Throws URISyntaxError if the basic URI syntax
5173 * it bad (as parsed by the Uri class) or the Intent data within the
5174 * URI is invalid.
Tom Taylord4a47292009-12-21 13:59:18 -08005175 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005176 * @see #toUri
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005177 */
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005178 public static Intent parseUri(String uri, int flags) throws URISyntaxException {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005179 int i = 0;
5180 try {
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005181 final boolean androidApp = uri.startsWith("android-app:");
5182
5183 // Validate intent scheme if requested.
5184 if ((flags&(URI_INTENT_SCHEME|URI_ANDROID_APP_SCHEME)) != 0) {
5185 if (!uri.startsWith("intent:") && !androidApp) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005186 Intent intent = new Intent(ACTION_VIEW);
5187 try {
5188 intent.setData(Uri.parse(uri));
5189 } catch (IllegalArgumentException e) {
5190 throw new URISyntaxException(uri, e.getMessage());
5191 }
5192 return intent;
5193 }
5194 }
Tom Taylord4a47292009-12-21 13:59:18 -08005195
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005196 i = uri.lastIndexOf("#");
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005197 // simple case
5198 if (i == -1) {
5199 if (!androidApp) {
5200 return new Intent(ACTION_VIEW, Uri.parse(uri));
5201 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005202
5203 // old format Intent URI
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005204 } else if (!uri.startsWith("#Intent;", i)) {
5205 if (!androidApp) {
Dianne Hackborn24b1c232014-11-20 17:17:39 -08005206 return getIntentOld(uri, flags);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005207 } else {
5208 i = -1;
5209 }
5210 }
The Android Open Source Project10592532009-03-18 17:39:46 -07005211
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005212 // new format
5213 Intent intent = new Intent(ACTION_VIEW);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005214 Intent baseIntent = intent;
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005215 boolean explicitAction = false;
5216 boolean inSelector = false;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005217
5218 // fetch data part, if present
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005219 String scheme = null;
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005220 String data;
5221 if (i >= 0) {
5222 data = uri.substring(0, i);
5223 i += 8; // length of "#Intent;"
5224 } else {
5225 data = uri;
5226 }
The Android Open Source Project10592532009-03-18 17:39:46 -07005227
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005228 // loop over contents of Intent, all name=value;
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005229 while (i >= 0 && !uri.startsWith("end", i)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005230 int eq = uri.indexOf('=', i);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005231 if (eq < 0) eq = i-1;
5232 int semi = uri.indexOf(';', i);
5233 String value = eq < semi ? Uri.decode(uri.substring(eq + 1, semi)) : "";
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005234
5235 // action
5236 if (uri.startsWith("action=", i)) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08005237 intent.setAction(value);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005238 if (!inSelector) {
5239 explicitAction = true;
5240 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005241 }
5242
5243 // categories
5244 else if (uri.startsWith("category=", i)) {
5245 intent.addCategory(value);
5246 }
5247
5248 // type
5249 else if (uri.startsWith("type=", i)) {
5250 intent.mType = value;
5251 }
5252
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08005253 // launch flags
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005254 else if (uri.startsWith("launchFlags=", i)) {
5255 intent.mFlags = Integer.decode(value).intValue();
Dianne Hackborn24b1c232014-11-20 17:17:39 -08005256 if ((flags& URI_ALLOW_UNSAFE) == 0) {
5257 intent.mFlags &= ~IMMUTABLE_FLAGS;
5258 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005259 }
5260
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005261 // package
5262 else if (uri.startsWith("package=", i)) {
5263 intent.mPackage = value;
5264 }
5265
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005266 // component
5267 else if (uri.startsWith("component=", i)) {
5268 intent.mComponent = ComponentName.unflattenFromString(value);
5269 }
The Android Open Source Project10592532009-03-18 17:39:46 -07005270
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005271 // scheme
5272 else if (uri.startsWith("scheme=", i)) {
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005273 if (inSelector) {
Dianne Hackborn80b1c562014-12-09 20:22:08 -08005274 intent.mData = Uri.parse(value + ":");
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005275 } else {
5276 scheme = value;
5277 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005278 }
5279
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08005280 // source bounds
5281 else if (uri.startsWith("sourceBounds=", i)) {
5282 intent.mSourceBounds = Rect.unflattenFromString(value);
5283 }
5284
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005285 // selector
5286 else if (semi == (i+3) && uri.startsWith("SEL", i)) {
5287 intent = new Intent();
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005288 inSelector = true;
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005289 }
5290
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005291 // extra
5292 else {
5293 String key = Uri.decode(uri.substring(i + 2, eq));
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005294 // create Bundle if it doesn't already exist
5295 if (intent.mExtras == null) intent.mExtras = new Bundle();
5296 Bundle b = intent.mExtras;
5297 // add EXTRA
5298 if (uri.startsWith("S.", i)) b.putString(key, value);
5299 else if (uri.startsWith("B.", i)) b.putBoolean(key, Boolean.parseBoolean(value));
5300 else if (uri.startsWith("b.", i)) b.putByte(key, Byte.parseByte(value));
5301 else if (uri.startsWith("c.", i)) b.putChar(key, value.charAt(0));
5302 else if (uri.startsWith("d.", i)) b.putDouble(key, Double.parseDouble(value));
5303 else if (uri.startsWith("f.", i)) b.putFloat(key, Float.parseFloat(value));
5304 else if (uri.startsWith("i.", i)) b.putInt(key, Integer.parseInt(value));
5305 else if (uri.startsWith("l.", i)) b.putLong(key, Long.parseLong(value));
5306 else if (uri.startsWith("s.", i)) b.putShort(key, Short.parseShort(value));
5307 else throw new URISyntaxException(uri, "unknown EXTRA type", i);
5308 }
The Android Open Source Project10592532009-03-18 17:39:46 -07005309
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005310 // move to the next item
5311 i = semi + 1;
5312 }
5313
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005314 if (inSelector) {
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005315 // The Intent had a selector; fix it up.
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005316 if (baseIntent.mPackage == null) {
5317 baseIntent.setSelector(intent);
5318 }
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005319 intent = baseIntent;
5320 }
5321
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005322 if (data != null) {
5323 if (data.startsWith("intent:")) {
5324 data = data.substring(7);
5325 if (scheme != null) {
5326 data = scheme + ':' + data;
5327 }
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005328 } else if (data.startsWith("android-app:")) {
5329 if (data.charAt(12) == '/' && data.charAt(13) == '/') {
5330 // Correctly formed android-app, first part is package name.
5331 int end = data.indexOf('/', 14);
5332 if (end < 0) {
5333 // All we have is a package name.
5334 intent.mPackage = data.substring(14);
5335 if (!explicitAction) {
5336 intent.setAction(ACTION_MAIN);
5337 }
5338 data = "";
5339 } else {
5340 // Target the Intent at the given package name always.
5341 String authority = null;
5342 intent.mPackage = data.substring(14, end);
5343 int newEnd;
Dianne Hackborn80b1c562014-12-09 20:22:08 -08005344 if ((end+1) < data.length()) {
5345 if ((newEnd=data.indexOf('/', end+1)) >= 0) {
5346 // Found a scheme, remember it.
5347 scheme = data.substring(end+1, newEnd);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005348 end = newEnd;
Dianne Hackborn80b1c562014-12-09 20:22:08 -08005349 if (end < data.length() && (newEnd=data.indexOf('/', end+1)) >= 0) {
5350 // Found a authority, remember it.
5351 authority = data.substring(end+1, newEnd);
5352 end = newEnd;
5353 }
5354 } else {
5355 // All we have is a scheme.
5356 scheme = data.substring(end+1);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005357 }
5358 }
5359 if (scheme == null) {
5360 // If there was no scheme, then this just targets the package.
5361 if (!explicitAction) {
5362 intent.setAction(ACTION_MAIN);
5363 }
5364 data = "";
5365 } else if (authority == null) {
5366 data = scheme + ":";
5367 } else {
5368 data = scheme + "://" + authority + data.substring(end);
5369 }
5370 }
5371 } else {
5372 data = "";
5373 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005374 }
Tom Taylord4a47292009-12-21 13:59:18 -08005375
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005376 if (data.length() > 0) {
5377 try {
5378 intent.mData = Uri.parse(data);
5379 } catch (IllegalArgumentException e) {
5380 throw new URISyntaxException(uri, e.getMessage());
5381 }
5382 }
5383 }
Tom Taylord4a47292009-12-21 13:59:18 -08005384
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005385 return intent;
The Android Open Source Project10592532009-03-18 17:39:46 -07005386
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005387 } catch (IndexOutOfBoundsException e) {
5388 throw new URISyntaxException(uri, "illegal Intent URI format", i);
5389 }
5390 }
The Android Open Source Project10592532009-03-18 17:39:46 -07005391
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005392 public static Intent getIntentOld(String uri) throws URISyntaxException {
Dianne Hackborn24b1c232014-11-20 17:17:39 -08005393 return getIntentOld(uri, 0);
5394 }
5395
5396 private static Intent getIntentOld(String uri, int flags) throws URISyntaxException {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005397 Intent intent;
5398
5399 int i = uri.lastIndexOf('#');
5400 if (i >= 0) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005401 String action = null;
Dianne Hackborn6cca1592009-09-20 12:40:03 -07005402 final int intentFragmentStart = i;
5403 boolean isIntentFragment = false;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005404
5405 i++;
5406
5407 if (uri.regionMatches(i, "action(", 0, 7)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07005408 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005409 i += 7;
5410 int j = uri.indexOf(')', i);
5411 action = uri.substring(i, j);
5412 i = j + 1;
5413 }
5414
Dianne Hackborn6cca1592009-09-20 12:40:03 -07005415 intent = new Intent(action);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005416
5417 if (uri.regionMatches(i, "categories(", 0, 11)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07005418 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005419 i += 11;
5420 int j = uri.indexOf(')', i);
5421 while (i < j) {
5422 int sep = uri.indexOf('!', i);
Alan Viverette0adf32b2014-09-18 12:53:16 -07005423 if (sep < 0 || sep > j) sep = j;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005424 if (i < sep) {
5425 intent.addCategory(uri.substring(i, sep));
5426 }
5427 i = sep + 1;
5428 }
5429 i = j + 1;
5430 }
5431
5432 if (uri.regionMatches(i, "type(", 0, 5)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07005433 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005434 i += 5;
5435 int j = uri.indexOf(')', i);
5436 intent.mType = uri.substring(i, j);
5437 i = j + 1;
5438 }
5439
5440 if (uri.regionMatches(i, "launchFlags(", 0, 12)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07005441 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005442 i += 12;
5443 int j = uri.indexOf(')', i);
5444 intent.mFlags = Integer.decode(uri.substring(i, j)).intValue();
Dianne Hackborn24b1c232014-11-20 17:17:39 -08005445 if ((flags& URI_ALLOW_UNSAFE) == 0) {
5446 intent.mFlags &= ~IMMUTABLE_FLAGS;
5447 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005448 i = j + 1;
5449 }
5450
5451 if (uri.regionMatches(i, "component(", 0, 10)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07005452 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005453 i += 10;
5454 int j = uri.indexOf(')', i);
5455 int sep = uri.indexOf('!', i);
5456 if (sep >= 0 && sep < j) {
5457 String pkg = uri.substring(i, sep);
5458 String cls = uri.substring(sep + 1, j);
5459 intent.mComponent = new ComponentName(pkg, cls);
5460 }
5461 i = j + 1;
5462 }
5463
5464 if (uri.regionMatches(i, "extras(", 0, 7)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07005465 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005466 i += 7;
The Android Open Source Project10592532009-03-18 17:39:46 -07005467
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005468 final int closeParen = uri.indexOf(')', i);
5469 if (closeParen == -1) throw new URISyntaxException(uri,
5470 "EXTRA missing trailing ')'", i);
5471
5472 while (i < closeParen) {
5473 // fetch the key value
5474 int j = uri.indexOf('=', i);
5475 if (j <= i + 1 || i >= closeParen) {
5476 throw new URISyntaxException(uri, "EXTRA missing '='", i);
5477 }
5478 char type = uri.charAt(i);
5479 i++;
5480 String key = uri.substring(i, j);
5481 i = j + 1;
The Android Open Source Project10592532009-03-18 17:39:46 -07005482
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005483 // get type-value
5484 j = uri.indexOf('!', i);
5485 if (j == -1 || j >= closeParen) j = closeParen;
5486 if (i >= j) throw new URISyntaxException(uri, "EXTRA missing '!'", i);
5487 String value = uri.substring(i, j);
5488 i = j;
5489
5490 // create Bundle if it doesn't already exist
5491 if (intent.mExtras == null) intent.mExtras = new Bundle();
The Android Open Source Project10592532009-03-18 17:39:46 -07005492
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005493 // add item to bundle
5494 try {
5495 switch (type) {
5496 case 'S':
5497 intent.mExtras.putString(key, Uri.decode(value));
5498 break;
5499 case 'B':
5500 intent.mExtras.putBoolean(key, Boolean.parseBoolean(value));
5501 break;
5502 case 'b':
5503 intent.mExtras.putByte(key, Byte.parseByte(value));
5504 break;
5505 case 'c':
5506 intent.mExtras.putChar(key, Uri.decode(value).charAt(0));
5507 break;
5508 case 'd':
5509 intent.mExtras.putDouble(key, Double.parseDouble(value));
5510 break;
5511 case 'f':
5512 intent.mExtras.putFloat(key, Float.parseFloat(value));
5513 break;
5514 case 'i':
5515 intent.mExtras.putInt(key, Integer.parseInt(value));
5516 break;
5517 case 'l':
5518 intent.mExtras.putLong(key, Long.parseLong(value));
5519 break;
5520 case 's':
5521 intent.mExtras.putShort(key, Short.parseShort(value));
5522 break;
5523 default:
5524 throw new URISyntaxException(uri, "EXTRA has unknown type", i);
5525 }
5526 } catch (NumberFormatException e) {
5527 throw new URISyntaxException(uri, "EXTRA value can't be parsed", i);
5528 }
The Android Open Source Project10592532009-03-18 17:39:46 -07005529
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005530 char ch = uri.charAt(i);
5531 if (ch == ')') break;
5532 if (ch != '!') throw new URISyntaxException(uri, "EXTRA missing '!'", i);
5533 i++;
5534 }
5535 }
5536
Dianne Hackborn6cca1592009-09-20 12:40:03 -07005537 if (isIntentFragment) {
5538 intent.mData = Uri.parse(uri.substring(0, intentFragmentStart));
5539 } else {
5540 intent.mData = Uri.parse(uri);
5541 }
Tom Taylord4a47292009-12-21 13:59:18 -08005542
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005543 if (intent.mAction == null) {
5544 // By default, if no action is specified, then use VIEW.
5545 intent.mAction = ACTION_VIEW;
5546 }
5547
5548 } else {
5549 intent = new Intent(ACTION_VIEW, Uri.parse(uri));
5550 }
5551
5552 return intent;
5553 }
5554
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08005555 /** @hide */
5556 public interface CommandOptionHandler {
5557 boolean handleOption(String opt, ShellCommand cmd);
5558 }
5559
5560 /** @hide */
5561 public static Intent parseCommandArgs(ShellCommand cmd, CommandOptionHandler optionHandler)
5562 throws URISyntaxException {
5563 Intent intent = new Intent();
5564 Intent baseIntent = intent;
5565 boolean hasIntentInfo = false;
5566
5567 Uri data = null;
5568 String type = null;
5569
5570 String opt;
5571 while ((opt=cmd.getNextOption()) != null) {
5572 switch (opt) {
5573 case "-a":
5574 intent.setAction(cmd.getNextArgRequired());
5575 if (intent == baseIntent) {
5576 hasIntentInfo = true;
5577 }
5578 break;
5579 case "-d":
5580 data = Uri.parse(cmd.getNextArgRequired());
5581 if (intent == baseIntent) {
5582 hasIntentInfo = true;
5583 }
5584 break;
5585 case "-t":
5586 type = cmd.getNextArgRequired();
5587 if (intent == baseIntent) {
5588 hasIntentInfo = true;
5589 }
5590 break;
5591 case "-c":
5592 intent.addCategory(cmd.getNextArgRequired());
5593 if (intent == baseIntent) {
5594 hasIntentInfo = true;
5595 }
5596 break;
5597 case "-e":
5598 case "--es": {
5599 String key = cmd.getNextArgRequired();
5600 String value = cmd.getNextArgRequired();
5601 intent.putExtra(key, value);
5602 }
5603 break;
5604 case "--esn": {
5605 String key = cmd.getNextArgRequired();
5606 intent.putExtra(key, (String) null);
5607 }
5608 break;
5609 case "--ei": {
5610 String key = cmd.getNextArgRequired();
5611 String value = cmd.getNextArgRequired();
5612 intent.putExtra(key, Integer.decode(value));
5613 }
5614 break;
5615 case "--eu": {
5616 String key = cmd.getNextArgRequired();
5617 String value = cmd.getNextArgRequired();
5618 intent.putExtra(key, Uri.parse(value));
5619 }
5620 break;
5621 case "--ecn": {
5622 String key = cmd.getNextArgRequired();
5623 String value = cmd.getNextArgRequired();
5624 ComponentName cn = ComponentName.unflattenFromString(value);
5625 if (cn == null)
5626 throw new IllegalArgumentException("Bad component name: " + value);
5627 intent.putExtra(key, cn);
5628 }
5629 break;
5630 case "--eia": {
5631 String key = cmd.getNextArgRequired();
5632 String value = cmd.getNextArgRequired();
5633 String[] strings = value.split(",");
5634 int[] list = new int[strings.length];
5635 for (int i = 0; i < strings.length; i++) {
5636 list[i] = Integer.decode(strings[i]);
5637 }
5638 intent.putExtra(key, list);
5639 }
5640 break;
5641 case "--eial": {
5642 String key = cmd.getNextArgRequired();
5643 String value = cmd.getNextArgRequired();
5644 String[] strings = value.split(",");
5645 ArrayList<Integer> list = new ArrayList<>(strings.length);
5646 for (int i = 0; i < strings.length; i++) {
5647 list.add(Integer.decode(strings[i]));
5648 }
5649 intent.putExtra(key, list);
5650 }
5651 break;
5652 case "--el": {
5653 String key = cmd.getNextArgRequired();
5654 String value = cmd.getNextArgRequired();
5655 intent.putExtra(key, Long.valueOf(value));
5656 }
5657 break;
5658 case "--ela": {
5659 String key = cmd.getNextArgRequired();
5660 String value = cmd.getNextArgRequired();
5661 String[] strings = value.split(",");
5662 long[] list = new long[strings.length];
5663 for (int i = 0; i < strings.length; i++) {
5664 list[i] = Long.valueOf(strings[i]);
5665 }
5666 intent.putExtra(key, list);
5667 hasIntentInfo = true;
5668 }
5669 break;
5670 case "--elal": {
5671 String key = cmd.getNextArgRequired();
5672 String value = cmd.getNextArgRequired();
5673 String[] strings = value.split(",");
5674 ArrayList<Long> list = new ArrayList<>(strings.length);
5675 for (int i = 0; i < strings.length; i++) {
5676 list.add(Long.valueOf(strings[i]));
5677 }
5678 intent.putExtra(key, list);
5679 hasIntentInfo = true;
5680 }
5681 break;
5682 case "--ef": {
5683 String key = cmd.getNextArgRequired();
5684 String value = cmd.getNextArgRequired();
5685 intent.putExtra(key, Float.valueOf(value));
5686 hasIntentInfo = true;
5687 }
5688 break;
5689 case "--efa": {
5690 String key = cmd.getNextArgRequired();
5691 String value = cmd.getNextArgRequired();
5692 String[] strings = value.split(",");
5693 float[] list = new float[strings.length];
5694 for (int i = 0; i < strings.length; i++) {
5695 list[i] = Float.valueOf(strings[i]);
5696 }
5697 intent.putExtra(key, list);
5698 hasIntentInfo = true;
5699 }
5700 break;
5701 case "--efal": {
5702 String key = cmd.getNextArgRequired();
5703 String value = cmd.getNextArgRequired();
5704 String[] strings = value.split(",");
5705 ArrayList<Float> list = new ArrayList<>(strings.length);
5706 for (int i = 0; i < strings.length; i++) {
5707 list.add(Float.valueOf(strings[i]));
5708 }
5709 intent.putExtra(key, list);
5710 hasIntentInfo = true;
5711 }
5712 break;
5713 case "--esa": {
5714 String key = cmd.getNextArgRequired();
5715 String value = cmd.getNextArgRequired();
5716 // Split on commas unless they are preceeded by an escape.
5717 // The escape character must be escaped for the string and
5718 // again for the regex, thus four escape characters become one.
5719 String[] strings = value.split("(?<!\\\\),");
5720 intent.putExtra(key, strings);
5721 hasIntentInfo = true;
5722 }
5723 break;
5724 case "--esal": {
5725 String key = cmd.getNextArgRequired();
5726 String value = cmd.getNextArgRequired();
5727 // Split on commas unless they are preceeded by an escape.
5728 // The escape character must be escaped for the string and
5729 // again for the regex, thus four escape characters become one.
5730 String[] strings = value.split("(?<!\\\\),");
5731 ArrayList<String> list = new ArrayList<>(strings.length);
5732 for (int i = 0; i < strings.length; i++) {
5733 list.add(strings[i]);
5734 }
5735 intent.putExtra(key, list);
5736 hasIntentInfo = true;
5737 }
5738 break;
5739 case "--ez": {
5740 String key = cmd.getNextArgRequired();
5741 String value = cmd.getNextArgRequired().toLowerCase();
5742 // Boolean.valueOf() results in false for anything that is not "true", which is
5743 // error-prone in shell commands
5744 boolean arg;
5745 if ("true".equals(value) || "t".equals(value)) {
5746 arg = true;
5747 } else if ("false".equals(value) || "f".equals(value)) {
5748 arg = false;
5749 } else {
5750 try {
5751 arg = Integer.decode(value) != 0;
5752 } catch (NumberFormatException ex) {
5753 throw new IllegalArgumentException("Invalid boolean value: " + value);
5754 }
5755 }
5756
5757 intent.putExtra(key, arg);
5758 }
5759 break;
5760 case "-n": {
5761 String str = cmd.getNextArgRequired();
5762 ComponentName cn = ComponentName.unflattenFromString(str);
5763 if (cn == null)
5764 throw new IllegalArgumentException("Bad component name: " + str);
5765 intent.setComponent(cn);
5766 if (intent == baseIntent) {
5767 hasIntentInfo = true;
5768 }
5769 }
5770 break;
5771 case "-p": {
5772 String str = cmd.getNextArgRequired();
5773 intent.setPackage(str);
5774 if (intent == baseIntent) {
5775 hasIntentInfo = true;
5776 }
5777 }
5778 break;
5779 case "-f":
5780 String str = cmd.getNextArgRequired();
5781 intent.setFlags(Integer.decode(str).intValue());
5782 break;
5783 case "--grant-read-uri-permission":
5784 intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
5785 break;
5786 case "--grant-write-uri-permission":
5787 intent.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
5788 break;
5789 case "--grant-persistable-uri-permission":
5790 intent.addFlags(Intent.FLAG_GRANT_PERSISTABLE_URI_PERMISSION);
5791 break;
5792 case "--grant-prefix-uri-permission":
5793 intent.addFlags(Intent.FLAG_GRANT_PREFIX_URI_PERMISSION);
5794 break;
5795 case "--exclude-stopped-packages":
5796 intent.addFlags(Intent.FLAG_EXCLUDE_STOPPED_PACKAGES);
5797 break;
5798 case "--include-stopped-packages":
5799 intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
5800 break;
5801 case "--debug-log-resolution":
5802 intent.addFlags(Intent.FLAG_DEBUG_LOG_RESOLUTION);
5803 break;
5804 case "--activity-brought-to-front":
5805 intent.addFlags(Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT);
5806 break;
5807 case "--activity-clear-top":
5808 intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
5809 break;
5810 case "--activity-clear-when-task-reset":
5811 intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
5812 break;
5813 case "--activity-exclude-from-recents":
5814 intent.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
5815 break;
5816 case "--activity-launched-from-history":
5817 intent.addFlags(Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY);
5818 break;
5819 case "--activity-multiple-task":
5820 intent.addFlags(Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
5821 break;
5822 case "--activity-no-animation":
5823 intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
5824 break;
5825 case "--activity-no-history":
5826 intent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
5827 break;
5828 case "--activity-no-user-action":
5829 intent.addFlags(Intent.FLAG_ACTIVITY_NO_USER_ACTION);
5830 break;
5831 case "--activity-previous-is-top":
5832 intent.addFlags(Intent.FLAG_ACTIVITY_PREVIOUS_IS_TOP);
5833 break;
5834 case "--activity-reorder-to-front":
5835 intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
5836 break;
5837 case "--activity-reset-task-if-needed":
5838 intent.addFlags(Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
5839 break;
5840 case "--activity-single-top":
5841 intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
5842 break;
5843 case "--activity-clear-task":
5844 intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
5845 break;
5846 case "--activity-task-on-home":
5847 intent.addFlags(Intent.FLAG_ACTIVITY_TASK_ON_HOME);
5848 break;
5849 case "--receiver-registered-only":
5850 intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY);
5851 break;
5852 case "--receiver-replace-pending":
5853 intent.addFlags(Intent.FLAG_RECEIVER_REPLACE_PENDING);
5854 break;
Felipe Leme3cb48cd2016-01-27 08:39:09 -08005855 case "--receiver-foreground":
5856 intent.addFlags(Intent.FLAG_RECEIVER_FOREGROUND);
5857 break;
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08005858 case "--selector":
5859 intent.setDataAndType(data, type);
5860 intent = new Intent();
5861 break;
5862 default:
5863 if (optionHandler != null && optionHandler.handleOption(opt, cmd)) {
5864 // Okay, caller handled this option.
5865 } else {
5866 throw new IllegalArgumentException("Unknown option: " + opt);
5867 }
5868 break;
5869 }
5870 }
5871 intent.setDataAndType(data, type);
5872
5873 final boolean hasSelector = intent != baseIntent;
5874 if (hasSelector) {
5875 // A selector was specified; fix up.
5876 baseIntent.setSelector(intent);
5877 intent = baseIntent;
5878 }
5879
5880 String arg = cmd.getNextArg();
5881 baseIntent = null;
5882 if (arg == null) {
5883 if (hasSelector) {
5884 // If a selector has been specified, and no arguments
5885 // have been supplied for the main Intent, then we can
5886 // assume it is ACTION_MAIN CATEGORY_LAUNCHER; we don't
5887 // need to have a component name specified yet, the
5888 // selector will take care of that.
5889 baseIntent = new Intent(Intent.ACTION_MAIN);
5890 baseIntent.addCategory(Intent.CATEGORY_LAUNCHER);
5891 }
5892 } else if (arg.indexOf(':') >= 0) {
5893 // The argument is a URI. Fully parse it, and use that result
5894 // to fill in any data not specified so far.
5895 baseIntent = Intent.parseUri(arg, Intent.URI_INTENT_SCHEME
5896 | Intent.URI_ANDROID_APP_SCHEME | Intent.URI_ALLOW_UNSAFE);
5897 } else if (arg.indexOf('/') >= 0) {
5898 // The argument is a component name. Build an Intent to launch
5899 // it.
5900 baseIntent = new Intent(Intent.ACTION_MAIN);
5901 baseIntent.addCategory(Intent.CATEGORY_LAUNCHER);
5902 baseIntent.setComponent(ComponentName.unflattenFromString(arg));
5903 } else {
5904 // Assume the argument is a package name.
5905 baseIntent = new Intent(Intent.ACTION_MAIN);
5906 baseIntent.addCategory(Intent.CATEGORY_LAUNCHER);
5907 baseIntent.setPackage(arg);
5908 }
5909 if (baseIntent != null) {
5910 Bundle extras = intent.getExtras();
5911 intent.replaceExtras((Bundle)null);
5912 Bundle uriExtras = baseIntent.getExtras();
5913 baseIntent.replaceExtras((Bundle)null);
5914 if (intent.getAction() != null && baseIntent.getCategories() != null) {
5915 HashSet<String> cats = new HashSet<String>(baseIntent.getCategories());
5916 for (String c : cats) {
5917 baseIntent.removeCategory(c);
5918 }
5919 }
5920 intent.fillIn(baseIntent, Intent.FILL_IN_COMPONENT | Intent.FILL_IN_SELECTOR);
5921 if (extras == null) {
5922 extras = uriExtras;
5923 } else if (uriExtras != null) {
5924 uriExtras.putAll(extras);
5925 extras = uriExtras;
5926 }
5927 intent.replaceExtras(extras);
5928 hasIntentInfo = true;
5929 }
5930
5931 if (!hasIntentInfo) throw new IllegalArgumentException("No intent supplied");
5932 return intent;
5933 }
5934
5935 /** @hide */
5936 public static void printIntentArgsHelp(PrintWriter pw, String prefix) {
5937 final String[] lines = new String[] {
5938 "<INTENT> specifications include these flags and arguments:",
5939 " [-a <ACTION>] [-d <DATA_URI>] [-t <MIME_TYPE>]",
5940 " [-c <CATEGORY> [-c <CATEGORY>] ...]",
5941 " [-e|--es <EXTRA_KEY> <EXTRA_STRING_VALUE> ...]",
5942 " [--esn <EXTRA_KEY> ...]",
5943 " [--ez <EXTRA_KEY> <EXTRA_BOOLEAN_VALUE> ...]",
5944 " [--ei <EXTRA_KEY> <EXTRA_INT_VALUE> ...]",
5945 " [--el <EXTRA_KEY> <EXTRA_LONG_VALUE> ...]",
5946 " [--ef <EXTRA_KEY> <EXTRA_FLOAT_VALUE> ...]",
5947 " [--eu <EXTRA_KEY> <EXTRA_URI_VALUE> ...]",
5948 " [--ecn <EXTRA_KEY> <EXTRA_COMPONENT_NAME_VALUE>]",
5949 " [--eia <EXTRA_KEY> <EXTRA_INT_VALUE>[,<EXTRA_INT_VALUE...]]",
5950 " (mutiple extras passed as Integer[])",
5951 " [--eial <EXTRA_KEY> <EXTRA_INT_VALUE>[,<EXTRA_INT_VALUE...]]",
5952 " (mutiple extras passed as List<Integer>)",
5953 " [--ela <EXTRA_KEY> <EXTRA_LONG_VALUE>[,<EXTRA_LONG_VALUE...]]",
5954 " (mutiple extras passed as Long[])",
5955 " [--elal <EXTRA_KEY> <EXTRA_LONG_VALUE>[,<EXTRA_LONG_VALUE...]]",
5956 " (mutiple extras passed as List<Long>)",
5957 " [--efa <EXTRA_KEY> <EXTRA_FLOAT_VALUE>[,<EXTRA_FLOAT_VALUE...]]",
5958 " (mutiple extras passed as Float[])",
5959 " [--efal <EXTRA_KEY> <EXTRA_FLOAT_VALUE>[,<EXTRA_FLOAT_VALUE...]]",
5960 " (mutiple extras passed as List<Float>)",
5961 " [--esa <EXTRA_KEY> <EXTRA_STRING_VALUE>[,<EXTRA_STRING_VALUE...]]",
5962 " (mutiple extras passed as String[]; to embed a comma into a string,",
5963 " escape it using \"\\,\")",
5964 " [--esal <EXTRA_KEY> <EXTRA_STRING_VALUE>[,<EXTRA_STRING_VALUE...]]",
5965 " (mutiple extras passed as List<String>; to embed a comma into a string,",
5966 " escape it using \"\\,\")",
Felipe Leme545569d2016-01-11 16:27:58 -08005967 " [-f <FLAG>]",
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08005968 " [--grant-read-uri-permission] [--grant-write-uri-permission]",
5969 " [--grant-persistable-uri-permission] [--grant-prefix-uri-permission]",
5970 " [--debug-log-resolution] [--exclude-stopped-packages]",
5971 " [--include-stopped-packages]",
5972 " [--activity-brought-to-front] [--activity-clear-top]",
5973 " [--activity-clear-when-task-reset] [--activity-exclude-from-recents]",
5974 " [--activity-launched-from-history] [--activity-multiple-task]",
5975 " [--activity-no-animation] [--activity-no-history]",
5976 " [--activity-no-user-action] [--activity-previous-is-top]",
5977 " [--activity-reorder-to-front] [--activity-reset-task-if-needed]",
5978 " [--activity-single-top] [--activity-clear-task]",
5979 " [--activity-task-on-home]",
5980 " [--receiver-registered-only] [--receiver-replace-pending]",
Felipe Leme3cb48cd2016-01-27 08:39:09 -08005981 " [--receiver-foreground]",
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08005982 " [--selector]",
5983 " [<URI> | <PACKAGE> | <COMPONENT>]"
5984 };
5985 for (String line : lines) {
5986 pw.print(prefix);
5987 pw.println(line);
5988 }
5989 }
5990
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005991 /**
5992 * Retrieve the general action to be performed, such as
5993 * {@link #ACTION_VIEW}. The action describes the general way the rest of
5994 * the information in the intent should be interpreted -- most importantly,
5995 * what to do with the data returned by {@link #getData}.
5996 *
5997 * @return The action of this intent or null if none is specified.
5998 *
5999 * @see #setAction
6000 */
6001 public String getAction() {
6002 return mAction;
6003 }
6004
6005 /**
6006 * Retrieve data this intent is operating on. This URI specifies the name
6007 * of the data; often it uses the content: scheme, specifying data in a
6008 * content provider. Other schemes may be handled by specific activities,
6009 * such as http: by the web browser.
6010 *
6011 * @return The URI of the data this intent is targeting or null.
6012 *
6013 * @see #getScheme
6014 * @see #setData
6015 */
6016 public Uri getData() {
6017 return mData;
6018 }
6019
6020 /**
6021 * The same as {@link #getData()}, but returns the URI as an encoded
6022 * String.
6023 */
6024 public String getDataString() {
6025 return mData != null ? mData.toString() : null;
6026 }
6027
6028 /**
6029 * Return the scheme portion of the intent's data. If the data is null or
6030 * does not include a scheme, null is returned. Otherwise, the scheme
6031 * prefix without the final ':' is returned, i.e. "http".
6032 *
6033 * <p>This is the same as calling getData().getScheme() (and checking for
6034 * null data).
6035 *
6036 * @return The scheme of this intent.
6037 *
6038 * @see #getData
6039 */
6040 public String getScheme() {
6041 return mData != null ? mData.getScheme() : null;
6042 }
6043
6044 /**
6045 * Retrieve any explicit MIME type included in the intent. This is usually
6046 * null, as the type is determined by the intent data.
6047 *
6048 * @return If a type was manually set, it is returned; else null is
6049 * returned.
6050 *
6051 * @see #resolveType(ContentResolver)
6052 * @see #setType
6053 */
6054 public String getType() {
6055 return mType;
6056 }
6057
6058 /**
6059 * Return the MIME data type of this intent. If the type field is
6060 * explicitly set, that is simply returned. Otherwise, if the data is set,
6061 * the type of that data is returned. If neither fields are set, a null is
6062 * returned.
6063 *
6064 * @return The MIME type of this intent.
6065 *
6066 * @see #getType
6067 * @see #resolveType(ContentResolver)
6068 */
6069 public String resolveType(Context context) {
6070 return resolveType(context.getContentResolver());
6071 }
6072
6073 /**
6074 * Return the MIME data type of this intent. If the type field is
6075 * explicitly set, that is simply returned. Otherwise, if the data is set,
6076 * the type of that data is returned. If neither fields are set, a null is
6077 * returned.
6078 *
6079 * @param resolver A ContentResolver that can be used to determine the MIME
6080 * type of the intent's data.
6081 *
6082 * @return The MIME type of this intent.
6083 *
6084 * @see #getType
6085 * @see #resolveType(Context)
6086 */
6087 public String resolveType(ContentResolver resolver) {
6088 if (mType != null) {
6089 return mType;
6090 }
6091 if (mData != null) {
6092 if ("content".equals(mData.getScheme())) {
6093 return resolver.getType(mData);
6094 }
6095 }
6096 return null;
6097 }
6098
6099 /**
6100 * Return the MIME data type of this intent, only if it will be needed for
6101 * intent resolution. This is not generally useful for application code;
6102 * it is used by the frameworks for communicating with back-end system
6103 * services.
6104 *
6105 * @param resolver A ContentResolver that can be used to determine the MIME
6106 * type of the intent's data.
6107 *
6108 * @return The MIME type of this intent, or null if it is unknown or not
6109 * needed.
6110 */
6111 public String resolveTypeIfNeeded(ContentResolver resolver) {
6112 if (mComponent != null) {
6113 return mType;
6114 }
6115 return resolveType(resolver);
6116 }
6117
6118 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09006119 * Check if a category exists in the intent.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006120 *
6121 * @param category The category to check.
6122 *
6123 * @return boolean True if the intent contains the category, else false.
6124 *
6125 * @see #getCategories
6126 * @see #addCategory
6127 */
6128 public boolean hasCategory(String category) {
6129 return mCategories != null && mCategories.contains(category);
6130 }
6131
6132 /**
6133 * Return the set of all categories in the intent. If there are no categories,
6134 * returns NULL.
6135 *
Dianne Hackbornf5b86712011-12-05 17:42:41 -08006136 * @return The set of categories you can examine. Do not modify!
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006137 *
6138 * @see #hasCategory
6139 * @see #addCategory
6140 */
6141 public Set<String> getCategories() {
6142 return mCategories;
6143 }
6144
6145 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08006146 * Return the specific selector associated with this Intent. If there is
6147 * none, returns null. See {@link #setSelector} for more information.
6148 *
6149 * @see #setSelector
6150 */
6151 public Intent getSelector() {
6152 return mSelector;
6153 }
6154
6155 /**
Dianne Hackborn21c241e2012-03-08 13:57:23 -08006156 * Return the {@link ClipData} associated with this Intent. If there is
6157 * none, returns null. See {@link #setClipData} for more information.
6158 *
John Spurlock125d1332013-11-25 11:58:37 -05006159 * @see #setClipData
Dianne Hackborn21c241e2012-03-08 13:57:23 -08006160 */
6161 public ClipData getClipData() {
6162 return mClipData;
6163 }
6164
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01006165 /** @hide */
6166 public int getContentUserHint() {
6167 return mContentUserHint;
6168 }
6169
Dianne Hackborn21c241e2012-03-08 13:57:23 -08006170 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006171 * Sets the ClassLoader that will be used when unmarshalling
6172 * any Parcelable values from the extras of this Intent.
6173 *
6174 * @param loader a ClassLoader, or null to use the default loader
6175 * at the time of unmarshalling.
6176 */
6177 public void setExtrasClassLoader(ClassLoader loader) {
6178 if (mExtras != null) {
6179 mExtras.setClassLoader(loader);
6180 }
6181 }
6182
6183 /**
6184 * Returns true if an extra value is associated with the given name.
6185 * @param name the extra's name
6186 * @return true if the given extra is present.
6187 */
6188 public boolean hasExtra(String name) {
6189 return mExtras != null && mExtras.containsKey(name);
6190 }
6191
6192 /**
6193 * Returns true if the Intent's extras contain a parcelled file descriptor.
6194 * @return true if the Intent contains a parcelled file descriptor.
6195 */
6196 public boolean hasFileDescriptors() {
6197 return mExtras != null && mExtras.hasFileDescriptors();
6198 }
The Android Open Source Project10592532009-03-18 17:39:46 -07006199
Jeff Sharkeyd136e512016-03-09 22:30:56 -07006200 /** {@hide} */
Dianne Hackborn9ecebbf2011-09-28 23:19:47 -04006201 public void setAllowFds(boolean allowFds) {
6202 if (mExtras != null) {
6203 mExtras.setAllowFds(allowFds);
6204 }
6205 }
6206
Jeff Sharkeyd136e512016-03-09 22:30:56 -07006207 /** {@hide} */
6208 public void setDefusable(boolean defusable) {
6209 if (mExtras != null) {
6210 mExtras.setDefusable(defusable);
6211 }
6212 }
6213
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006214 /**
6215 * Retrieve extended data from the intent.
6216 *
6217 * @param name The name of the desired item.
6218 *
6219 * @return the value of an item that previously added with putExtra()
6220 * or null if none was found.
6221 *
6222 * @deprecated
6223 * @hide
6224 */
6225 @Deprecated
6226 public Object getExtra(String name) {
6227 return getExtra(name, null);
6228 }
6229
6230 /**
6231 * Retrieve extended data from the intent.
6232 *
6233 * @param name The name of the desired item.
6234 * @param defaultValue the value to be returned if no value of the desired
6235 * type is stored with the given name.
6236 *
6237 * @return the value of an item that previously added with putExtra()
6238 * or the default value if none was found.
6239 *
6240 * @see #putExtra(String, boolean)
6241 */
6242 public boolean getBooleanExtra(String name, boolean defaultValue) {
6243 return mExtras == null ? defaultValue :
6244 mExtras.getBoolean(name, defaultValue);
6245 }
6246
6247 /**
6248 * Retrieve extended data from the intent.
6249 *
6250 * @param name The name of the desired item.
6251 * @param defaultValue the value to be returned if no value of the desired
6252 * type is stored with the given name.
6253 *
6254 * @return the value of an item that previously added with putExtra()
6255 * or the default value if none was found.
6256 *
6257 * @see #putExtra(String, byte)
6258 */
6259 public byte getByteExtra(String name, byte defaultValue) {
6260 return mExtras == null ? defaultValue :
6261 mExtras.getByte(name, defaultValue);
6262 }
6263
6264 /**
6265 * Retrieve extended data from the intent.
6266 *
6267 * @param name The name of the desired item.
6268 * @param defaultValue the value to be returned if no value of the desired
6269 * type is stored with the given name.
6270 *
6271 * @return the value of an item that previously added with putExtra()
6272 * or the default value if none was found.
6273 *
6274 * @see #putExtra(String, short)
6275 */
6276 public short getShortExtra(String name, short defaultValue) {
6277 return mExtras == null ? defaultValue :
6278 mExtras.getShort(name, defaultValue);
6279 }
6280
6281 /**
6282 * Retrieve extended data from the intent.
6283 *
6284 * @param name The name of the desired item.
6285 * @param defaultValue the value to be returned if no value of the desired
6286 * type is stored with the given name.
6287 *
6288 * @return the value of an item that previously added with putExtra()
6289 * or the default value if none was found.
6290 *
6291 * @see #putExtra(String, char)
6292 */
6293 public char getCharExtra(String name, char defaultValue) {
6294 return mExtras == null ? defaultValue :
6295 mExtras.getChar(name, defaultValue);
6296 }
6297
6298 /**
6299 * Retrieve extended data from the intent.
6300 *
6301 * @param name The name of the desired item.
6302 * @param defaultValue the value to be returned if no value of the desired
6303 * type is stored with the given name.
6304 *
6305 * @return the value of an item that previously added with putExtra()
6306 * or the default value if none was found.
6307 *
6308 * @see #putExtra(String, int)
6309 */
6310 public int getIntExtra(String name, int defaultValue) {
6311 return mExtras == null ? defaultValue :
6312 mExtras.getInt(name, defaultValue);
6313 }
6314
6315 /**
6316 * Retrieve extended data from the intent.
6317 *
6318 * @param name The name of the desired item.
6319 * @param defaultValue the value to be returned if no value of the desired
6320 * type is stored with the given name.
6321 *
6322 * @return the value of an item that previously added with putExtra()
6323 * or the default value if none was found.
6324 *
6325 * @see #putExtra(String, long)
6326 */
6327 public long getLongExtra(String name, long defaultValue) {
6328 return mExtras == null ? defaultValue :
6329 mExtras.getLong(name, defaultValue);
6330 }
6331
6332 /**
6333 * Retrieve extended data from the intent.
6334 *
6335 * @param name The name of the desired item.
6336 * @param defaultValue the value to be returned if no value of the desired
6337 * type is stored with the given name.
6338 *
6339 * @return the value of an item that previously added with putExtra(),
6340 * or the default value if no such item is present
6341 *
6342 * @see #putExtra(String, float)
6343 */
6344 public float getFloatExtra(String name, float defaultValue) {
6345 return mExtras == null ? defaultValue :
6346 mExtras.getFloat(name, defaultValue);
6347 }
6348
6349 /**
6350 * Retrieve extended data from the intent.
6351 *
6352 * @param name The name of the desired item.
6353 * @param defaultValue the value to be returned if no value of the desired
6354 * type is stored with the given name.
6355 *
6356 * @return the value of an item that previously added with putExtra()
6357 * or the default value if none was found.
6358 *
6359 * @see #putExtra(String, double)
6360 */
6361 public double getDoubleExtra(String name, double defaultValue) {
6362 return mExtras == null ? defaultValue :
6363 mExtras.getDouble(name, defaultValue);
6364 }
6365
6366 /**
6367 * Retrieve extended data from the intent.
6368 *
6369 * @param name The name of the desired item.
6370 *
6371 * @return the value of an item that previously added with putExtra()
6372 * or null if no String value was found.
6373 *
6374 * @see #putExtra(String, String)
6375 */
6376 public String getStringExtra(String name) {
6377 return mExtras == null ? null : mExtras.getString(name);
6378 }
6379
6380 /**
6381 * Retrieve extended data from the intent.
6382 *
6383 * @param name The name of the desired item.
6384 *
6385 * @return the value of an item that previously added with putExtra()
6386 * or null if no CharSequence value was found.
6387 *
6388 * @see #putExtra(String, CharSequence)
6389 */
6390 public CharSequence getCharSequenceExtra(String name) {
6391 return mExtras == null ? null : mExtras.getCharSequence(name);
6392 }
6393
6394 /**
6395 * Retrieve extended data from the intent.
6396 *
6397 * @param name The name of the desired item.
6398 *
6399 * @return the value of an item that previously added with putExtra()
6400 * or null if no Parcelable value was found.
6401 *
6402 * @see #putExtra(String, Parcelable)
6403 */
6404 public <T extends Parcelable> T getParcelableExtra(String name) {
6405 return mExtras == null ? null : mExtras.<T>getParcelable(name);
6406 }
6407
6408 /**
6409 * Retrieve extended data from the intent.
6410 *
6411 * @param name The name of the desired item.
6412 *
6413 * @return the value of an item that previously added with putExtra()
6414 * or null if no Parcelable[] value was found.
6415 *
6416 * @see #putExtra(String, Parcelable[])
6417 */
6418 public Parcelable[] getParcelableArrayExtra(String name) {
6419 return mExtras == null ? null : mExtras.getParcelableArray(name);
6420 }
6421
6422 /**
6423 * Retrieve extended data from the intent.
6424 *
6425 * @param name The name of the desired item.
6426 *
6427 * @return the value of an item that previously added with putExtra()
6428 * or null if no ArrayList<Parcelable> value was found.
6429 *
6430 * @see #putParcelableArrayListExtra(String, ArrayList)
6431 */
6432 public <T extends Parcelable> ArrayList<T> getParcelableArrayListExtra(String name) {
6433 return mExtras == null ? null : mExtras.<T>getParcelableArrayList(name);
6434 }
6435
6436 /**
6437 * Retrieve extended data from the intent.
6438 *
6439 * @param name The name of the desired item.
6440 *
6441 * @return the value of an item that previously added with putExtra()
6442 * or null if no Serializable value was found.
6443 *
6444 * @see #putExtra(String, Serializable)
6445 */
6446 public Serializable getSerializableExtra(String name) {
6447 return mExtras == null ? null : mExtras.getSerializable(name);
6448 }
6449
6450 /**
6451 * Retrieve extended data from the intent.
6452 *
6453 * @param name The name of the desired item.
6454 *
6455 * @return the value of an item that previously added with putExtra()
6456 * or null if no ArrayList<Integer> value was found.
6457 *
6458 * @see #putIntegerArrayListExtra(String, ArrayList)
6459 */
6460 public ArrayList<Integer> getIntegerArrayListExtra(String name) {
6461 return mExtras == null ? null : mExtras.getIntegerArrayList(name);
6462 }
6463
6464 /**
6465 * Retrieve extended data from the intent.
6466 *
6467 * @param name The name of the desired item.
6468 *
6469 * @return the value of an item that previously added with putExtra()
6470 * or null if no ArrayList<String> value was found.
6471 *
6472 * @see #putStringArrayListExtra(String, ArrayList)
6473 */
6474 public ArrayList<String> getStringArrayListExtra(String name) {
6475 return mExtras == null ? null : mExtras.getStringArrayList(name);
6476 }
6477
6478 /**
6479 * Retrieve extended data from the intent.
6480 *
6481 * @param name The name of the desired item.
6482 *
6483 * @return the value of an item that previously added with putExtra()
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00006484 * or null if no ArrayList<CharSequence> value was found.
6485 *
6486 * @see #putCharSequenceArrayListExtra(String, ArrayList)
6487 */
6488 public ArrayList<CharSequence> getCharSequenceArrayListExtra(String name) {
6489 return mExtras == null ? null : mExtras.getCharSequenceArrayList(name);
6490 }
6491
6492 /**
6493 * Retrieve extended data from the intent.
6494 *
6495 * @param name The name of the desired item.
6496 *
6497 * @return the value of an item that previously added with putExtra()
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006498 * or null if no boolean array value was found.
6499 *
6500 * @see #putExtra(String, boolean[])
6501 */
6502 public boolean[] getBooleanArrayExtra(String name) {
6503 return mExtras == null ? null : mExtras.getBooleanArray(name);
6504 }
6505
6506 /**
6507 * Retrieve extended data from the intent.
6508 *
6509 * @param name The name of the desired item.
6510 *
6511 * @return the value of an item that previously added with putExtra()
6512 * or null if no byte array value was found.
6513 *
6514 * @see #putExtra(String, byte[])
6515 */
6516 public byte[] getByteArrayExtra(String name) {
6517 return mExtras == null ? null : mExtras.getByteArray(name);
6518 }
6519
6520 /**
6521 * Retrieve extended data from the intent.
6522 *
6523 * @param name The name of the desired item.
6524 *
6525 * @return the value of an item that previously added with putExtra()
6526 * or null if no short array value was found.
6527 *
6528 * @see #putExtra(String, short[])
6529 */
6530 public short[] getShortArrayExtra(String name) {
6531 return mExtras == null ? null : mExtras.getShortArray(name);
6532 }
6533
6534 /**
6535 * Retrieve extended data from the intent.
6536 *
6537 * @param name The name of the desired item.
6538 *
6539 * @return the value of an item that previously added with putExtra()
6540 * or null if no char array value was found.
6541 *
6542 * @see #putExtra(String, char[])
6543 */
6544 public char[] getCharArrayExtra(String name) {
6545 return mExtras == null ? null : mExtras.getCharArray(name);
6546 }
6547
6548 /**
6549 * Retrieve extended data from the intent.
6550 *
6551 * @param name The name of the desired item.
6552 *
6553 * @return the value of an item that previously added with putExtra()
6554 * or null if no int array value was found.
6555 *
6556 * @see #putExtra(String, int[])
6557 */
6558 public int[] getIntArrayExtra(String name) {
6559 return mExtras == null ? null : mExtras.getIntArray(name);
6560 }
6561
6562 /**
6563 * Retrieve extended data from the intent.
6564 *
6565 * @param name The name of the desired item.
6566 *
6567 * @return the value of an item that previously added with putExtra()
6568 * or null if no long array value was found.
6569 *
6570 * @see #putExtra(String, long[])
6571 */
6572 public long[] getLongArrayExtra(String name) {
6573 return mExtras == null ? null : mExtras.getLongArray(name);
6574 }
6575
6576 /**
6577 * Retrieve extended data from the intent.
6578 *
6579 * @param name The name of the desired item.
6580 *
6581 * @return the value of an item that previously added with putExtra()
6582 * or null if no float array value was found.
6583 *
6584 * @see #putExtra(String, float[])
6585 */
6586 public float[] getFloatArrayExtra(String name) {
6587 return mExtras == null ? null : mExtras.getFloatArray(name);
6588 }
6589
6590 /**
6591 * Retrieve extended data from the intent.
6592 *
6593 * @param name The name of the desired item.
6594 *
6595 * @return the value of an item that previously added with putExtra()
6596 * or null if no double array value was found.
6597 *
6598 * @see #putExtra(String, double[])
6599 */
6600 public double[] getDoubleArrayExtra(String name) {
6601 return mExtras == null ? null : mExtras.getDoubleArray(name);
6602 }
6603
6604 /**
6605 * Retrieve extended data from the intent.
6606 *
6607 * @param name The name of the desired item.
6608 *
6609 * @return the value of an item that previously added with putExtra()
6610 * or null if no String array value was found.
6611 *
6612 * @see #putExtra(String, String[])
6613 */
6614 public String[] getStringArrayExtra(String name) {
6615 return mExtras == null ? null : mExtras.getStringArray(name);
6616 }
6617
6618 /**
6619 * Retrieve extended data from the intent.
6620 *
6621 * @param name The name of the desired item.
6622 *
6623 * @return the value of an item that previously added with putExtra()
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00006624 * or null if no CharSequence array value was found.
6625 *
6626 * @see #putExtra(String, CharSequence[])
6627 */
6628 public CharSequence[] getCharSequenceArrayExtra(String name) {
6629 return mExtras == null ? null : mExtras.getCharSequenceArray(name);
6630 }
6631
6632 /**
6633 * Retrieve extended data from the intent.
6634 *
6635 * @param name The name of the desired item.
6636 *
6637 * @return the value of an item that previously added with putExtra()
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006638 * or null if no Bundle value was found.
6639 *
6640 * @see #putExtra(String, Bundle)
6641 */
6642 public Bundle getBundleExtra(String name) {
6643 return mExtras == null ? null : mExtras.getBundle(name);
6644 }
6645
6646 /**
6647 * Retrieve extended data from the intent.
6648 *
6649 * @param name The name of the desired item.
6650 *
6651 * @return the value of an item that previously added with putExtra()
6652 * or null if no IBinder value was found.
6653 *
6654 * @see #putExtra(String, IBinder)
6655 *
6656 * @deprecated
6657 * @hide
6658 */
6659 @Deprecated
6660 public IBinder getIBinderExtra(String name) {
6661 return mExtras == null ? null : mExtras.getIBinder(name);
6662 }
6663
6664 /**
6665 * Retrieve extended data from the intent.
6666 *
6667 * @param name The name of the desired item.
6668 * @param defaultValue The default value to return in case no item is
6669 * associated with the key 'name'
6670 *
6671 * @return the value of an item that previously added with putExtra()
6672 * or defaultValue if none was found.
6673 *
6674 * @see #putExtra
6675 *
6676 * @deprecated
6677 * @hide
6678 */
6679 @Deprecated
6680 public Object getExtra(String name, Object defaultValue) {
6681 Object result = defaultValue;
6682 if (mExtras != null) {
6683 Object result2 = mExtras.get(name);
6684 if (result2 != null) {
6685 result = result2;
6686 }
6687 }
6688
6689 return result;
6690 }
6691
6692 /**
6693 * Retrieves a map of extended data from the intent.
6694 *
6695 * @return the map of all extras previously added with putExtra(),
6696 * or null if none have been added.
6697 */
6698 public Bundle getExtras() {
6699 return (mExtras != null)
6700 ? new Bundle(mExtras)
6701 : null;
6702 }
6703
6704 /**
Dianne Hackborna83ce1d2015-03-11 15:16:13 -07006705 * Filter extras to only basic types.
6706 * @hide
6707 */
6708 public void removeUnsafeExtras() {
6709 if (mExtras != null) {
Dianne Hackborn851ec492016-10-12 17:20:07 -07006710 mExtras = mExtras.filterValues();
Dianne Hackborna83ce1d2015-03-11 15:16:13 -07006711 }
6712 }
6713
6714 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006715 * Retrieve any special flags associated with this intent. You will
6716 * normally just set them with {@link #setFlags} and let the system
6717 * take the appropriate action with them.
6718 *
6719 * @return int The currently set flags.
6720 *
6721 * @see #setFlags
6722 */
6723 public int getFlags() {
6724 return mFlags;
6725 }
6726
Dianne Hackborne7f97212011-02-24 14:40:20 -08006727 /** @hide */
6728 public boolean isExcludingStopped() {
6729 return (mFlags&(FLAG_EXCLUDE_STOPPED_PACKAGES|FLAG_INCLUDE_STOPPED_PACKAGES))
6730 == FLAG_EXCLUDE_STOPPED_PACKAGES;
6731 }
6732
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006733 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006734 * Retrieve the application package name this Intent is limited to. When
6735 * resolving an Intent, if non-null this limits the resolution to only
6736 * components in the given application package.
6737 *
6738 * @return The name of the application package for the Intent.
6739 *
6740 * @see #resolveActivity
6741 * @see #setPackage
6742 */
6743 public String getPackage() {
6744 return mPackage;
6745 }
6746
6747 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006748 * Retrieve the concrete component associated with the intent. When receiving
6749 * an intent, this is the component that was found to best handle it (that is,
6750 * yourself) and will always be non-null; in all other cases it will be
6751 * null unless explicitly set.
6752 *
6753 * @return The name of the application component to handle the intent.
6754 *
6755 * @see #resolveActivity
6756 * @see #setComponent
6757 */
6758 public ComponentName getComponent() {
6759 return mComponent;
6760 }
6761
6762 /**
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08006763 * Get the bounds of the sender of this intent, in screen coordinates. This can be
6764 * used as a hint to the receiver for animations and the like. Null means that there
6765 * is no source bounds.
6766 */
6767 public Rect getSourceBounds() {
6768 return mSourceBounds;
6769 }
6770
6771 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006772 * Return the Activity component that should be used to handle this intent.
6773 * The appropriate component is determined based on the information in the
6774 * intent, evaluated as follows:
6775 *
6776 * <p>If {@link #getComponent} returns an explicit class, that is returned
6777 * without any further consideration.
6778 *
6779 * <p>The activity must handle the {@link Intent#CATEGORY_DEFAULT} Intent
6780 * category to be considered.
6781 *
6782 * <p>If {@link #getAction} is non-NULL, the activity must handle this
6783 * action.
6784 *
6785 * <p>If {@link #resolveType} returns non-NULL, the activity must handle
6786 * this type.
6787 *
6788 * <p>If {@link #addCategory} has added any categories, the activity must
6789 * handle ALL of the categories specified.
6790 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006791 * <p>If {@link #getPackage} is non-NULL, only activity components in
6792 * that application package will be considered.
6793 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006794 * <p>If there are no activities that satisfy all of these conditions, a
6795 * null string is returned.
6796 *
6797 * <p>If multiple activities are found to satisfy the intent, the one with
6798 * the highest priority will be used. If there are multiple activities
6799 * with the same priority, the system will either pick the best activity
6800 * based on user preference, or resolve to a system class that will allow
6801 * the user to pick an activity and forward from there.
6802 *
6803 * <p>This method is implemented simply by calling
6804 * {@link PackageManager#resolveActivity} with the "defaultOnly" parameter
6805 * true.</p>
6806 * <p> This API is called for you as part of starting an activity from an
6807 * intent. You do not normally need to call it yourself.</p>
6808 *
6809 * @param pm The package manager with which to resolve the Intent.
6810 *
6811 * @return Name of the component implementing an activity that can
6812 * display the intent.
6813 *
6814 * @see #setComponent
6815 * @see #getComponent
6816 * @see #resolveActivityInfo
6817 */
6818 public ComponentName resolveActivity(PackageManager pm) {
6819 if (mComponent != null) {
6820 return mComponent;
6821 }
6822
6823 ResolveInfo info = pm.resolveActivity(
6824 this, PackageManager.MATCH_DEFAULT_ONLY);
6825 if (info != null) {
6826 return new ComponentName(
6827 info.activityInfo.applicationInfo.packageName,
6828 info.activityInfo.name);
6829 }
6830
6831 return null;
6832 }
6833
6834 /**
6835 * Resolve the Intent into an {@link ActivityInfo}
6836 * describing the activity that should execute the intent. Resolution
6837 * follows the same rules as described for {@link #resolveActivity}, but
6838 * you get back the completely information about the resolved activity
6839 * instead of just its class name.
6840 *
6841 * @param pm The package manager with which to resolve the Intent.
6842 * @param flags Addition information to retrieve as per
6843 * {@link PackageManager#getActivityInfo(ComponentName, int)
6844 * PackageManager.getActivityInfo()}.
6845 *
6846 * @return PackageManager.ActivityInfo
6847 *
6848 * @see #resolveActivity
6849 */
6850 public ActivityInfo resolveActivityInfo(PackageManager pm, int flags) {
6851 ActivityInfo ai = null;
6852 if (mComponent != null) {
6853 try {
6854 ai = pm.getActivityInfo(mComponent, flags);
6855 } catch (PackageManager.NameNotFoundException e) {
6856 // ignore
6857 }
6858 } else {
6859 ResolveInfo info = pm.resolveActivity(
Dianne Hackborn9bfb7072009-09-22 11:37:40 -07006860 this, PackageManager.MATCH_DEFAULT_ONLY | flags);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006861 if (info != null) {
6862 ai = info.activityInfo;
6863 }
6864 }
6865
6866 return ai;
6867 }
6868
6869 /**
Dianne Hackborn221ea892013-08-04 16:50:16 -07006870 * Special function for use by the system to resolve service
6871 * intents to system apps. Throws an exception if there are
6872 * multiple potential matches to the Intent. Returns null if
6873 * there are no matches.
6874 * @hide
6875 */
6876 public ComponentName resolveSystemService(PackageManager pm, int flags) {
6877 if (mComponent != null) {
6878 return mComponent;
6879 }
6880
6881 List<ResolveInfo> results = pm.queryIntentServices(this, flags);
6882 if (results == null) {
6883 return null;
6884 }
6885 ComponentName comp = null;
6886 for (int i=0; i<results.size(); i++) {
6887 ResolveInfo ri = results.get(i);
6888 if ((ri.serviceInfo.applicationInfo.flags&ApplicationInfo.FLAG_SYSTEM) == 0) {
6889 continue;
6890 }
6891 ComponentName foundComp = new ComponentName(ri.serviceInfo.applicationInfo.packageName,
6892 ri.serviceInfo.name);
6893 if (comp != null) {
6894 throw new IllegalStateException("Multiple system services handle " + this
6895 + ": " + comp + ", " + foundComp);
6896 }
6897 comp = foundComp;
6898 }
6899 return comp;
6900 }
6901
6902 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006903 * Set the general action to be performed.
6904 *
6905 * @param action An action name, such as ACTION_VIEW. Application-specific
6906 * actions should be prefixed with the vendor's package name.
6907 *
6908 * @return Returns the same Intent object, for chaining multiple calls
6909 * into a single statement.
6910 *
6911 * @see #getAction
6912 */
6913 public Intent setAction(String action) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08006914 mAction = action != null ? action.intern() : null;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006915 return this;
6916 }
6917
6918 /**
6919 * Set the data this intent is operating on. This method automatically
Nick Pellyccae4122012-01-09 14:12:58 -08006920 * clears any type that was previously set by {@link #setType} or
6921 * {@link #setTypeAndNormalize}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006922 *
Nick Pellyccae4122012-01-09 14:12:58 -08006923 * <p><em>Note: scheme matching in the Android framework is
6924 * case-sensitive, unlike the formal RFC. As a result,
6925 * you should always write your Uri with a lower case scheme,
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04006926 * or use {@link Uri#normalizeScheme} or
Nick Pellyccae4122012-01-09 14:12:58 -08006927 * {@link #setDataAndNormalize}
6928 * to ensure that the scheme is converted to lower case.</em>
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07006929 *
Nick Pellyccae4122012-01-09 14:12:58 -08006930 * @param data The Uri of the data this intent is now targeting.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006931 *
6932 * @return Returns the same Intent object, for chaining multiple calls
6933 * into a single statement.
6934 *
6935 * @see #getData
Nick Pellyccae4122012-01-09 14:12:58 -08006936 * @see #setDataAndNormalize
Dianne Hackborn221ea892013-08-04 16:50:16 -07006937 * @see android.net.Uri#normalizeScheme()
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006938 */
6939 public Intent setData(Uri data) {
6940 mData = data;
6941 mType = null;
6942 return this;
6943 }
6944
6945 /**
Nick Pellyccae4122012-01-09 14:12:58 -08006946 * Normalize and set the data this intent is operating on.
6947 *
6948 * <p>This method automatically clears any type that was
6949 * previously set (for example, by {@link #setType}).
6950 *
6951 * <p>The data Uri is normalized using
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04006952 * {@link android.net.Uri#normalizeScheme} before it is set,
Nick Pellyccae4122012-01-09 14:12:58 -08006953 * so really this is just a convenience method for
6954 * <pre>
6955 * setData(data.normalize())
6956 * </pre>
6957 *
6958 * @param data The Uri of the data this intent is now targeting.
6959 *
6960 * @return Returns the same Intent object, for chaining multiple calls
6961 * into a single statement.
6962 *
6963 * @see #getData
6964 * @see #setType
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04006965 * @see android.net.Uri#normalizeScheme
Nick Pellyccae4122012-01-09 14:12:58 -08006966 */
6967 public Intent setDataAndNormalize(Uri data) {
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04006968 return setData(data.normalizeScheme());
Nick Pellyccae4122012-01-09 14:12:58 -08006969 }
6970
6971 /**
6972 * Set an explicit MIME data type.
6973 *
6974 * <p>This is used to create intents that only specify a type and not data,
6975 * for example to indicate the type of data to return.
6976 *
6977 * <p>This method automatically clears any data that was
6978 * previously set (for example by {@link #setData}).
Romain Guy4969af72009-06-17 10:53:19 -07006979 *
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07006980 * <p><em>Note: MIME type matching in the Android framework is
6981 * case-sensitive, unlike formal RFC MIME types. As a result,
6982 * you should always write your MIME types with lower case letters,
Nick Pellyccae4122012-01-09 14:12:58 -08006983 * or use {@link #normalizeMimeType} or {@link #setTypeAndNormalize}
6984 * to ensure that it is converted to lower case.</em>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006985 *
6986 * @param type The MIME type of the data being handled by this intent.
6987 *
6988 * @return Returns the same Intent object, for chaining multiple calls
6989 * into a single statement.
6990 *
6991 * @see #getType
Nick Pellyccae4122012-01-09 14:12:58 -08006992 * @see #setTypeAndNormalize
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006993 * @see #setDataAndType
Nick Pellyccae4122012-01-09 14:12:58 -08006994 * @see #normalizeMimeType
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006995 */
6996 public Intent setType(String type) {
6997 mData = null;
6998 mType = type;
6999 return this;
7000 }
7001
7002 /**
Nick Pellyccae4122012-01-09 14:12:58 -08007003 * Normalize and set an explicit MIME data type.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007004 *
Nick Pellyccae4122012-01-09 14:12:58 -08007005 * <p>This is used to create intents that only specify a type and not data,
7006 * for example to indicate the type of data to return.
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07007007 *
Nick Pellyccae4122012-01-09 14:12:58 -08007008 * <p>This method automatically clears any data that was
7009 * previously set (for example by {@link #setData}).
7010 *
7011 * <p>The MIME type is normalized using
7012 * {@link #normalizeMimeType} before it is set,
7013 * so really this is just a convenience method for
7014 * <pre>
7015 * setType(Intent.normalizeMimeType(type))
7016 * </pre>
7017 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007018 * @param type The MIME type of the data being handled by this intent.
7019 *
7020 * @return Returns the same Intent object, for chaining multiple calls
7021 * into a single statement.
7022 *
Nick Pellyccae4122012-01-09 14:12:58 -08007023 * @see #getType
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007024 * @see #setData
Nick Pellyccae4122012-01-09 14:12:58 -08007025 * @see #normalizeMimeType
7026 */
7027 public Intent setTypeAndNormalize(String type) {
7028 return setType(normalizeMimeType(type));
7029 }
7030
7031 /**
7032 * (Usually optional) Set the data for the intent along with an explicit
7033 * MIME data type. This method should very rarely be used -- it allows you
7034 * to override the MIME type that would ordinarily be inferred from the
7035 * data with your own type given here.
7036 *
7037 * <p><em>Note: MIME type and Uri scheme matching in the
7038 * Android framework is case-sensitive, unlike the formal RFC definitions.
7039 * As a result, you should always write these elements with lower case letters,
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04007040 * or use {@link #normalizeMimeType} or {@link android.net.Uri#normalizeScheme} or
Nick Pellyccae4122012-01-09 14:12:58 -08007041 * {@link #setDataAndTypeAndNormalize}
7042 * to ensure that they are converted to lower case.</em>
7043 *
7044 * @param data The Uri of the data this intent is now targeting.
7045 * @param type The MIME type of the data being handled by this intent.
7046 *
7047 * @return Returns the same Intent object, for chaining multiple calls
7048 * into a single statement.
7049 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007050 * @see #setType
Nick Pellyccae4122012-01-09 14:12:58 -08007051 * @see #setData
7052 * @see #normalizeMimeType
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04007053 * @see android.net.Uri#normalizeScheme
Nick Pellyccae4122012-01-09 14:12:58 -08007054 * @see #setDataAndTypeAndNormalize
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007055 */
7056 public Intent setDataAndType(Uri data, String type) {
7057 mData = data;
7058 mType = type;
7059 return this;
7060 }
7061
7062 /**
Nick Pellyccae4122012-01-09 14:12:58 -08007063 * (Usually optional) Normalize and set both the data Uri and an explicit
7064 * MIME data type. This method should very rarely be used -- it allows you
7065 * to override the MIME type that would ordinarily be inferred from the
7066 * data with your own type given here.
7067 *
7068 * <p>The data Uri and the MIME type are normalize using
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04007069 * {@link android.net.Uri#normalizeScheme} and {@link #normalizeMimeType}
Nick Pellyccae4122012-01-09 14:12:58 -08007070 * before they are set, so really this is just a convenience method for
7071 * <pre>
7072 * setDataAndType(data.normalize(), Intent.normalizeMimeType(type))
7073 * </pre>
7074 *
7075 * @param data The Uri of the data this intent is now targeting.
7076 * @param type The MIME type of the data being handled by this intent.
7077 *
7078 * @return Returns the same Intent object, for chaining multiple calls
7079 * into a single statement.
7080 *
7081 * @see #setType
7082 * @see #setData
7083 * @see #setDataAndType
7084 * @see #normalizeMimeType
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04007085 * @see android.net.Uri#normalizeScheme
Nick Pellyccae4122012-01-09 14:12:58 -08007086 */
7087 public Intent setDataAndTypeAndNormalize(Uri data, String type) {
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04007088 return setDataAndType(data.normalizeScheme(), normalizeMimeType(type));
Nick Pellyccae4122012-01-09 14:12:58 -08007089 }
7090
7091 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007092 * Add a new category to the intent. Categories provide additional detail
Ken Wakasaf76a50c2012-03-09 19:56:35 +09007093 * about the action the intent performs. When resolving an intent, only
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007094 * activities that provide <em>all</em> of the requested categories will be
7095 * used.
7096 *
7097 * @param category The desired category. This can be either one of the
7098 * predefined Intent categories, or a custom category in your own
7099 * namespace.
7100 *
7101 * @return Returns the same Intent object, for chaining multiple calls
7102 * into a single statement.
7103 *
7104 * @see #hasCategory
7105 * @see #removeCategory
7106 */
7107 public Intent addCategory(String category) {
7108 if (mCategories == null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07007109 mCategories = new ArraySet<String>();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007110 }
Jeff Brown2c376fc2011-01-28 17:34:01 -08007111 mCategories.add(category.intern());
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007112 return this;
7113 }
7114
7115 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09007116 * Remove a category from an intent.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007117 *
7118 * @param category The category to remove.
7119 *
7120 * @see #addCategory
7121 */
7122 public void removeCategory(String category) {
7123 if (mCategories != null) {
7124 mCategories.remove(category);
7125 if (mCategories.size() == 0) {
7126 mCategories = null;
7127 }
7128 }
7129 }
7130
7131 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08007132 * Set a selector for this Intent. This is a modification to the kinds of
7133 * things the Intent will match. If the selector is set, it will be used
7134 * when trying to find entities that can handle the Intent, instead of the
7135 * main contents of the Intent. This allows you build an Intent containing
7136 * a generic protocol while targeting it more specifically.
7137 *
7138 * <p>An example of where this may be used is with things like
7139 * {@link #CATEGORY_APP_BROWSER}. This category allows you to build an
7140 * Intent that will launch the Browser application. However, the correct
7141 * main entry point of an application is actually {@link #ACTION_MAIN}
7142 * {@link #CATEGORY_LAUNCHER} with {@link #setComponent(ComponentName)}
7143 * used to specify the actual Activity to launch. If you launch the browser
7144 * with something different, undesired behavior may happen if the user has
7145 * previously or later launches it the normal way, since they do not match.
7146 * Instead, you can build an Intent with the MAIN action (but no ComponentName
7147 * yet specified) and set a selector with {@link #ACTION_MAIN} and
7148 * {@link #CATEGORY_APP_BROWSER} to point it specifically to the browser activity.
7149 *
7150 * <p>Setting a selector does not impact the behavior of
7151 * {@link #filterEquals(Intent)} and {@link #filterHashCode()}. This is part of the
7152 * desired behavior of a selector -- it does not impact the base meaning
7153 * of the Intent, just what kinds of things will be matched against it
7154 * when determining who can handle it.</p>
7155 *
7156 * <p>You can not use both a selector and {@link #setPackage(String)} on
7157 * the same base Intent.</p>
7158 *
7159 * @param selector The desired selector Intent; set to null to not use
7160 * a special selector.
7161 */
7162 public void setSelector(Intent selector) {
7163 if (selector == this) {
7164 throw new IllegalArgumentException(
7165 "Intent being set as a selector of itself");
7166 }
7167 if (selector != null && mPackage != null) {
7168 throw new IllegalArgumentException(
7169 "Can't set selector when package name is already set");
7170 }
7171 mSelector = selector;
7172 }
7173
7174 /**
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007175 * Set a {@link ClipData} associated with this Intent. This replaces any
7176 * previously set ClipData.
7177 *
7178 * <p>The ClipData in an intent is not used for Intent matching or other
7179 * such operations. Semantically it is like extras, used to transmit
7180 * additional data with the Intent. The main feature of using this over
7181 * the extras for data is that {@link #FLAG_GRANT_READ_URI_PERMISSION}
7182 * and {@link #FLAG_GRANT_WRITE_URI_PERMISSION} will operate on any URI
7183 * items included in the clip data. This is useful, in particular, if
7184 * you want to transmit an Intent containing multiple <code>content:</code>
7185 * URIs for which the recipient may not have global permission to access the
7186 * content provider.
7187 *
7188 * <p>If the ClipData contains items that are themselves Intents, any
7189 * grant flags in those Intents will be ignored. Only the top-level flags
7190 * of the main Intent are respected, and will be applied to all Uri or
7191 * Intent items in the clip (or sub-items of the clip).
7192 *
7193 * <p>The MIME type, label, and icon in the ClipData object are not
7194 * directly used by Intent. Applications should generally rely on the
7195 * MIME type of the Intent itself, not what it may find in the ClipData.
7196 * A common practice is to construct a ClipData for use with an Intent
John Spurlock33900182014-01-02 11:04:18 -05007197 * with a MIME type of "*&#47;*".
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007198 *
7199 * @param clip The new clip to set. May be null to clear the current clip.
7200 */
7201 public void setClipData(ClipData clip) {
7202 mClipData = clip;
7203 }
7204
7205 /**
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01007206 * This is NOT a secure mechanism to identify the user who sent the intent.
7207 * When the intent is sent to a different user, it is used to fix uris by adding the userId
7208 * who sent the intent.
7209 * @hide
7210 */
Nicolas Prevot107f7b72015-07-01 16:31:48 +01007211 public void prepareToLeaveUser(int userId) {
7212 // If mContentUserHint is not UserHandle.USER_CURRENT, the intent has already left a user.
7213 // We want mContentUserHint to refer to the original user, so don't do anything.
7214 if (mContentUserHint == UserHandle.USER_CURRENT) {
7215 mContentUserHint = userId;
7216 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01007217 }
7218
7219 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007220 * Add extended data to the intent. The name must include a package
7221 * prefix, for example the app com.android.contacts would use names
7222 * like "com.android.contacts.ShowAll".
7223 *
7224 * @param name The name of the extra data, with package prefix.
7225 * @param value The boolean data value.
7226 *
7227 * @return Returns the same Intent object, for chaining multiple calls
7228 * into a single statement.
7229 *
7230 * @see #putExtras
7231 * @see #removeExtra
7232 * @see #getBooleanExtra(String, boolean)
7233 */
7234 public Intent putExtra(String name, boolean value) {
7235 if (mExtras == null) {
7236 mExtras = new Bundle();
7237 }
7238 mExtras.putBoolean(name, value);
7239 return this;
7240 }
7241
7242 /**
7243 * Add extended data to the intent. The name must include a package
7244 * prefix, for example the app com.android.contacts would use names
7245 * like "com.android.contacts.ShowAll".
7246 *
7247 * @param name The name of the extra data, with package prefix.
7248 * @param value The byte data value.
7249 *
7250 * @return Returns the same Intent object, for chaining multiple calls
7251 * into a single statement.
7252 *
7253 * @see #putExtras
7254 * @see #removeExtra
7255 * @see #getByteExtra(String, byte)
7256 */
7257 public Intent putExtra(String name, byte value) {
7258 if (mExtras == null) {
7259 mExtras = new Bundle();
7260 }
7261 mExtras.putByte(name, value);
7262 return this;
7263 }
7264
7265 /**
7266 * Add extended data to the intent. The name must include a package
7267 * prefix, for example the app com.android.contacts would use names
7268 * like "com.android.contacts.ShowAll".
7269 *
7270 * @param name The name of the extra data, with package prefix.
7271 * @param value The char data value.
7272 *
7273 * @return Returns the same Intent object, for chaining multiple calls
7274 * into a single statement.
7275 *
7276 * @see #putExtras
7277 * @see #removeExtra
7278 * @see #getCharExtra(String, char)
7279 */
7280 public Intent putExtra(String name, char value) {
7281 if (mExtras == null) {
7282 mExtras = new Bundle();
7283 }
7284 mExtras.putChar(name, value);
7285 return this;
7286 }
7287
7288 /**
7289 * Add extended data to the intent. The name must include a package
7290 * prefix, for example the app com.android.contacts would use names
7291 * like "com.android.contacts.ShowAll".
7292 *
7293 * @param name The name of the extra data, with package prefix.
7294 * @param value The short data value.
7295 *
7296 * @return Returns the same Intent object, for chaining multiple calls
7297 * into a single statement.
7298 *
7299 * @see #putExtras
7300 * @see #removeExtra
7301 * @see #getShortExtra(String, short)
7302 */
7303 public Intent putExtra(String name, short value) {
7304 if (mExtras == null) {
7305 mExtras = new Bundle();
7306 }
7307 mExtras.putShort(name, value);
7308 return this;
7309 }
7310
7311 /**
7312 * Add extended data to the intent. The name must include a package
7313 * prefix, for example the app com.android.contacts would use names
7314 * like "com.android.contacts.ShowAll".
7315 *
7316 * @param name The name of the extra data, with package prefix.
7317 * @param value The integer data value.
7318 *
7319 * @return Returns the same Intent object, for chaining multiple calls
7320 * into a single statement.
7321 *
7322 * @see #putExtras
7323 * @see #removeExtra
7324 * @see #getIntExtra(String, int)
7325 */
7326 public Intent putExtra(String name, int value) {
7327 if (mExtras == null) {
7328 mExtras = new Bundle();
7329 }
7330 mExtras.putInt(name, value);
7331 return this;
7332 }
7333
7334 /**
7335 * Add extended data to the intent. The name must include a package
7336 * prefix, for example the app com.android.contacts would use names
7337 * like "com.android.contacts.ShowAll".
7338 *
7339 * @param name The name of the extra data, with package prefix.
7340 * @param value The long data value.
7341 *
7342 * @return Returns the same Intent object, for chaining multiple calls
7343 * into a single statement.
7344 *
7345 * @see #putExtras
7346 * @see #removeExtra
7347 * @see #getLongExtra(String, long)
7348 */
7349 public Intent putExtra(String name, long value) {
7350 if (mExtras == null) {
7351 mExtras = new Bundle();
7352 }
7353 mExtras.putLong(name, value);
7354 return this;
7355 }
7356
7357 /**
7358 * Add extended data to the intent. The name must include a package
7359 * prefix, for example the app com.android.contacts would use names
7360 * like "com.android.contacts.ShowAll".
7361 *
7362 * @param name The name of the extra data, with package prefix.
7363 * @param value The float data value.
7364 *
7365 * @return Returns the same Intent object, for chaining multiple calls
7366 * into a single statement.
7367 *
7368 * @see #putExtras
7369 * @see #removeExtra
7370 * @see #getFloatExtra(String, float)
7371 */
7372 public Intent putExtra(String name, float value) {
7373 if (mExtras == null) {
7374 mExtras = new Bundle();
7375 }
7376 mExtras.putFloat(name, value);
7377 return this;
7378 }
7379
7380 /**
7381 * Add extended data to the intent. The name must include a package
7382 * prefix, for example the app com.android.contacts would use names
7383 * like "com.android.contacts.ShowAll".
7384 *
7385 * @param name The name of the extra data, with package prefix.
7386 * @param value The double data value.
7387 *
7388 * @return Returns the same Intent object, for chaining multiple calls
7389 * into a single statement.
7390 *
7391 * @see #putExtras
7392 * @see #removeExtra
7393 * @see #getDoubleExtra(String, double)
7394 */
7395 public Intent putExtra(String name, double value) {
7396 if (mExtras == null) {
7397 mExtras = new Bundle();
7398 }
7399 mExtras.putDouble(name, value);
7400 return this;
7401 }
7402
7403 /**
7404 * Add extended data to the intent. The name must include a package
7405 * prefix, for example the app com.android.contacts would use names
7406 * like "com.android.contacts.ShowAll".
7407 *
7408 * @param name The name of the extra data, with package prefix.
7409 * @param value The String data value.
7410 *
7411 * @return Returns the same Intent object, for chaining multiple calls
7412 * into a single statement.
7413 *
7414 * @see #putExtras
7415 * @see #removeExtra
7416 * @see #getStringExtra(String)
7417 */
7418 public Intent putExtra(String name, String value) {
7419 if (mExtras == null) {
7420 mExtras = new Bundle();
7421 }
7422 mExtras.putString(name, value);
7423 return this;
7424 }
7425
7426 /**
7427 * Add extended data to the intent. The name must include a package
7428 * prefix, for example the app com.android.contacts would use names
7429 * like "com.android.contacts.ShowAll".
7430 *
7431 * @param name The name of the extra data, with package prefix.
7432 * @param value The CharSequence data value.
7433 *
7434 * @return Returns the same Intent object, for chaining multiple calls
7435 * into a single statement.
7436 *
7437 * @see #putExtras
7438 * @see #removeExtra
7439 * @see #getCharSequenceExtra(String)
7440 */
7441 public Intent putExtra(String name, CharSequence value) {
7442 if (mExtras == null) {
7443 mExtras = new Bundle();
7444 }
7445 mExtras.putCharSequence(name, value);
7446 return this;
7447 }
7448
7449 /**
7450 * Add extended data to the intent. The name must include a package
7451 * prefix, for example the app com.android.contacts would use names
7452 * like "com.android.contacts.ShowAll".
7453 *
7454 * @param name The name of the extra data, with package prefix.
7455 * @param value The Parcelable data value.
7456 *
7457 * @return Returns the same Intent object, for chaining multiple calls
7458 * into a single statement.
7459 *
7460 * @see #putExtras
7461 * @see #removeExtra
7462 * @see #getParcelableExtra(String)
7463 */
7464 public Intent putExtra(String name, Parcelable value) {
7465 if (mExtras == null) {
7466 mExtras = new Bundle();
7467 }
7468 mExtras.putParcelable(name, value);
7469 return this;
7470 }
7471
7472 /**
7473 * Add extended data to the intent. The name must include a package
7474 * prefix, for example the app com.android.contacts would use names
7475 * like "com.android.contacts.ShowAll".
7476 *
7477 * @param name The name of the extra data, with package prefix.
7478 * @param value The Parcelable[] data value.
7479 *
7480 * @return Returns the same Intent object, for chaining multiple calls
7481 * into a single statement.
7482 *
7483 * @see #putExtras
7484 * @see #removeExtra
7485 * @see #getParcelableArrayExtra(String)
7486 */
7487 public Intent putExtra(String name, Parcelable[] value) {
7488 if (mExtras == null) {
7489 mExtras = new Bundle();
7490 }
7491 mExtras.putParcelableArray(name, value);
7492 return this;
7493 }
7494
7495 /**
7496 * Add extended data to the intent. The name must include a package
7497 * prefix, for example the app com.android.contacts would use names
7498 * like "com.android.contacts.ShowAll".
7499 *
7500 * @param name The name of the extra data, with package prefix.
7501 * @param value The ArrayList<Parcelable> data value.
7502 *
7503 * @return Returns the same Intent object, for chaining multiple calls
7504 * into a single statement.
7505 *
7506 * @see #putExtras
7507 * @see #removeExtra
7508 * @see #getParcelableArrayListExtra(String)
7509 */
7510 public Intent putParcelableArrayListExtra(String name, ArrayList<? extends Parcelable> value) {
7511 if (mExtras == null) {
7512 mExtras = new Bundle();
7513 }
7514 mExtras.putParcelableArrayList(name, value);
7515 return this;
7516 }
7517
7518 /**
7519 * Add extended data to the intent. The name must include a package
7520 * prefix, for example the app com.android.contacts would use names
7521 * like "com.android.contacts.ShowAll".
7522 *
7523 * @param name The name of the extra data, with package prefix.
7524 * @param value The ArrayList<Integer> data value.
7525 *
7526 * @return Returns the same Intent object, for chaining multiple calls
7527 * into a single statement.
7528 *
7529 * @see #putExtras
7530 * @see #removeExtra
7531 * @see #getIntegerArrayListExtra(String)
7532 */
7533 public Intent putIntegerArrayListExtra(String name, ArrayList<Integer> value) {
7534 if (mExtras == null) {
7535 mExtras = new Bundle();
7536 }
7537 mExtras.putIntegerArrayList(name, value);
7538 return this;
7539 }
7540
7541 /**
7542 * Add extended data to the intent. The name must include a package
7543 * prefix, for example the app com.android.contacts would use names
7544 * like "com.android.contacts.ShowAll".
7545 *
7546 * @param name The name of the extra data, with package prefix.
7547 * @param value The ArrayList<String> data value.
7548 *
7549 * @return Returns the same Intent object, for chaining multiple calls
7550 * into a single statement.
7551 *
7552 * @see #putExtras
7553 * @see #removeExtra
7554 * @see #getStringArrayListExtra(String)
7555 */
7556 public Intent putStringArrayListExtra(String name, ArrayList<String> value) {
7557 if (mExtras == null) {
7558 mExtras = new Bundle();
7559 }
7560 mExtras.putStringArrayList(name, value);
7561 return this;
7562 }
7563
7564 /**
7565 * Add extended data to the intent. The name must include a package
7566 * prefix, for example the app com.android.contacts would use names
7567 * like "com.android.contacts.ShowAll".
7568 *
7569 * @param name The name of the extra data, with package prefix.
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00007570 * @param value The ArrayList<CharSequence> data value.
7571 *
7572 * @return Returns the same Intent object, for chaining multiple calls
7573 * into a single statement.
7574 *
7575 * @see #putExtras
7576 * @see #removeExtra
7577 * @see #getCharSequenceArrayListExtra(String)
7578 */
7579 public Intent putCharSequenceArrayListExtra(String name, ArrayList<CharSequence> value) {
7580 if (mExtras == null) {
7581 mExtras = new Bundle();
7582 }
7583 mExtras.putCharSequenceArrayList(name, value);
7584 return this;
7585 }
7586
7587 /**
7588 * Add extended data to the intent. The name must include a package
7589 * prefix, for example the app com.android.contacts would use names
7590 * like "com.android.contacts.ShowAll".
7591 *
7592 * @param name The name of the extra data, with package prefix.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007593 * @param value The Serializable data value.
7594 *
7595 * @return Returns the same Intent object, for chaining multiple calls
7596 * into a single statement.
7597 *
7598 * @see #putExtras
7599 * @see #removeExtra
7600 * @see #getSerializableExtra(String)
7601 */
7602 public Intent putExtra(String name, Serializable value) {
7603 if (mExtras == null) {
7604 mExtras = new Bundle();
7605 }
7606 mExtras.putSerializable(name, value);
7607 return this;
7608 }
7609
7610 /**
7611 * Add extended data to the intent. The name must include a package
7612 * prefix, for example the app com.android.contacts would use names
7613 * like "com.android.contacts.ShowAll".
7614 *
7615 * @param name The name of the extra data, with package prefix.
7616 * @param value The boolean array data value.
7617 *
7618 * @return Returns the same Intent object, for chaining multiple calls
7619 * into a single statement.
7620 *
7621 * @see #putExtras
7622 * @see #removeExtra
7623 * @see #getBooleanArrayExtra(String)
7624 */
7625 public Intent putExtra(String name, boolean[] value) {
7626 if (mExtras == null) {
7627 mExtras = new Bundle();
7628 }
7629 mExtras.putBooleanArray(name, value);
7630 return this;
7631 }
7632
7633 /**
7634 * Add extended data to the intent. The name must include a package
7635 * prefix, for example the app com.android.contacts would use names
7636 * like "com.android.contacts.ShowAll".
7637 *
7638 * @param name The name of the extra data, with package prefix.
7639 * @param value The byte array data value.
7640 *
7641 * @return Returns the same Intent object, for chaining multiple calls
7642 * into a single statement.
7643 *
7644 * @see #putExtras
7645 * @see #removeExtra
7646 * @see #getByteArrayExtra(String)
7647 */
7648 public Intent putExtra(String name, byte[] value) {
7649 if (mExtras == null) {
7650 mExtras = new Bundle();
7651 }
7652 mExtras.putByteArray(name, value);
7653 return this;
7654 }
7655
7656 /**
7657 * Add extended data to the intent. The name must include a package
7658 * prefix, for example the app com.android.contacts would use names
7659 * like "com.android.contacts.ShowAll".
7660 *
7661 * @param name The name of the extra data, with package prefix.
7662 * @param value The short array data value.
7663 *
7664 * @return Returns the same Intent object, for chaining multiple calls
7665 * into a single statement.
7666 *
7667 * @see #putExtras
7668 * @see #removeExtra
7669 * @see #getShortArrayExtra(String)
7670 */
7671 public Intent putExtra(String name, short[] value) {
7672 if (mExtras == null) {
7673 mExtras = new Bundle();
7674 }
7675 mExtras.putShortArray(name, value);
7676 return this;
7677 }
7678
7679 /**
7680 * Add extended data to the intent. The name must include a package
7681 * prefix, for example the app com.android.contacts would use names
7682 * like "com.android.contacts.ShowAll".
7683 *
7684 * @param name The name of the extra data, with package prefix.
7685 * @param value The char array data value.
7686 *
7687 * @return Returns the same Intent object, for chaining multiple calls
7688 * into a single statement.
7689 *
7690 * @see #putExtras
7691 * @see #removeExtra
7692 * @see #getCharArrayExtra(String)
7693 */
7694 public Intent putExtra(String name, char[] value) {
7695 if (mExtras == null) {
7696 mExtras = new Bundle();
7697 }
7698 mExtras.putCharArray(name, value);
7699 return this;
7700 }
7701
7702 /**
7703 * Add extended data to the intent. The name must include a package
7704 * prefix, for example the app com.android.contacts would use names
7705 * like "com.android.contacts.ShowAll".
7706 *
7707 * @param name The name of the extra data, with package prefix.
7708 * @param value The int array data value.
7709 *
7710 * @return Returns the same Intent object, for chaining multiple calls
7711 * into a single statement.
7712 *
7713 * @see #putExtras
7714 * @see #removeExtra
7715 * @see #getIntArrayExtra(String)
7716 */
7717 public Intent putExtra(String name, int[] value) {
7718 if (mExtras == null) {
7719 mExtras = new Bundle();
7720 }
7721 mExtras.putIntArray(name, value);
7722 return this;
7723 }
7724
7725 /**
7726 * Add extended data to the intent. The name must include a package
7727 * prefix, for example the app com.android.contacts would use names
7728 * like "com.android.contacts.ShowAll".
7729 *
7730 * @param name The name of the extra data, with package prefix.
7731 * @param value The byte array data value.
7732 *
7733 * @return Returns the same Intent object, for chaining multiple calls
7734 * into a single statement.
7735 *
7736 * @see #putExtras
7737 * @see #removeExtra
7738 * @see #getLongArrayExtra(String)
7739 */
7740 public Intent putExtra(String name, long[] value) {
7741 if (mExtras == null) {
7742 mExtras = new Bundle();
7743 }
7744 mExtras.putLongArray(name, value);
7745 return this;
7746 }
7747
7748 /**
7749 * Add extended data to the intent. The name must include a package
7750 * prefix, for example the app com.android.contacts would use names
7751 * like "com.android.contacts.ShowAll".
7752 *
7753 * @param name The name of the extra data, with package prefix.
7754 * @param value The float array data value.
7755 *
7756 * @return Returns the same Intent object, for chaining multiple calls
7757 * into a single statement.
7758 *
7759 * @see #putExtras
7760 * @see #removeExtra
7761 * @see #getFloatArrayExtra(String)
7762 */
7763 public Intent putExtra(String name, float[] value) {
7764 if (mExtras == null) {
7765 mExtras = new Bundle();
7766 }
7767 mExtras.putFloatArray(name, value);
7768 return this;
7769 }
7770
7771 /**
7772 * Add extended data to the intent. The name must include a package
7773 * prefix, for example the app com.android.contacts would use names
7774 * like "com.android.contacts.ShowAll".
7775 *
7776 * @param name The name of the extra data, with package prefix.
7777 * @param value The double array data value.
7778 *
7779 * @return Returns the same Intent object, for chaining multiple calls
7780 * into a single statement.
7781 *
7782 * @see #putExtras
7783 * @see #removeExtra
7784 * @see #getDoubleArrayExtra(String)
7785 */
7786 public Intent putExtra(String name, double[] value) {
7787 if (mExtras == null) {
7788 mExtras = new Bundle();
7789 }
7790 mExtras.putDoubleArray(name, value);
7791 return this;
7792 }
7793
7794 /**
7795 * Add extended data to the intent. The name must include a package
7796 * prefix, for example the app com.android.contacts would use names
7797 * like "com.android.contacts.ShowAll".
7798 *
7799 * @param name The name of the extra data, with package prefix.
7800 * @param value The String array data value.
7801 *
7802 * @return Returns the same Intent object, for chaining multiple calls
7803 * into a single statement.
7804 *
7805 * @see #putExtras
7806 * @see #removeExtra
7807 * @see #getStringArrayExtra(String)
7808 */
7809 public Intent putExtra(String name, String[] value) {
7810 if (mExtras == null) {
7811 mExtras = new Bundle();
7812 }
7813 mExtras.putStringArray(name, value);
7814 return this;
7815 }
7816
7817 /**
7818 * Add extended data to the intent. The name must include a package
7819 * prefix, for example the app com.android.contacts would use names
7820 * like "com.android.contacts.ShowAll".
7821 *
7822 * @param name The name of the extra data, with package prefix.
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00007823 * @param value The CharSequence array data value.
7824 *
7825 * @return Returns the same Intent object, for chaining multiple calls
7826 * into a single statement.
7827 *
7828 * @see #putExtras
7829 * @see #removeExtra
7830 * @see #getCharSequenceArrayExtra(String)
7831 */
7832 public Intent putExtra(String name, CharSequence[] value) {
7833 if (mExtras == null) {
7834 mExtras = new Bundle();
7835 }
7836 mExtras.putCharSequenceArray(name, value);
7837 return this;
7838 }
7839
7840 /**
7841 * Add extended data to the intent. The name must include a package
7842 * prefix, for example the app com.android.contacts would use names
7843 * like "com.android.contacts.ShowAll".
7844 *
7845 * @param name The name of the extra data, with package prefix.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007846 * @param value The Bundle data value.
7847 *
7848 * @return Returns the same Intent object, for chaining multiple calls
7849 * into a single statement.
7850 *
7851 * @see #putExtras
7852 * @see #removeExtra
7853 * @see #getBundleExtra(String)
7854 */
7855 public Intent putExtra(String name, Bundle value) {
7856 if (mExtras == null) {
7857 mExtras = new Bundle();
7858 }
7859 mExtras.putBundle(name, value);
7860 return this;
7861 }
7862
7863 /**
7864 * Add extended data to the intent. The name must include a package
7865 * prefix, for example the app com.android.contacts would use names
7866 * like "com.android.contacts.ShowAll".
7867 *
7868 * @param name The name of the extra data, with package prefix.
7869 * @param value The IBinder data value.
7870 *
7871 * @return Returns the same Intent object, for chaining multiple calls
7872 * into a single statement.
7873 *
7874 * @see #putExtras
7875 * @see #removeExtra
7876 * @see #getIBinderExtra(String)
7877 *
7878 * @deprecated
7879 * @hide
7880 */
7881 @Deprecated
7882 public Intent putExtra(String name, IBinder value) {
7883 if (mExtras == null) {
7884 mExtras = new Bundle();
7885 }
7886 mExtras.putIBinder(name, value);
7887 return this;
7888 }
7889
7890 /**
7891 * Copy all extras in 'src' in to this intent.
7892 *
7893 * @param src Contains the extras to copy.
7894 *
7895 * @see #putExtra
7896 */
7897 public Intent putExtras(Intent src) {
7898 if (src.mExtras != null) {
7899 if (mExtras == null) {
7900 mExtras = new Bundle(src.mExtras);
7901 } else {
7902 mExtras.putAll(src.mExtras);
7903 }
7904 }
7905 return this;
7906 }
7907
7908 /**
7909 * Add a set of extended data to the intent. The keys must include a package
7910 * prefix, for example the app com.android.contacts would use names
7911 * like "com.android.contacts.ShowAll".
7912 *
7913 * @param extras The Bundle of extras to add to this intent.
7914 *
7915 * @see #putExtra
7916 * @see #removeExtra
7917 */
7918 public Intent putExtras(Bundle extras) {
7919 if (mExtras == null) {
7920 mExtras = new Bundle();
7921 }
7922 mExtras.putAll(extras);
7923 return this;
7924 }
7925
7926 /**
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08007927 * Completely replace the extras in the Intent with the extras in the
7928 * given Intent.
The Android Open Source Project10592532009-03-18 17:39:46 -07007929 *
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08007930 * @param src The exact extras contained in this Intent are copied
7931 * into the target intent, replacing any that were previously there.
7932 */
7933 public Intent replaceExtras(Intent src) {
7934 mExtras = src.mExtras != null ? new Bundle(src.mExtras) : null;
7935 return this;
7936 }
The Android Open Source Project10592532009-03-18 17:39:46 -07007937
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08007938 /**
7939 * Completely replace the extras in the Intent with the given Bundle of
7940 * extras.
The Android Open Source Project10592532009-03-18 17:39:46 -07007941 *
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08007942 * @param extras The new set of extras in the Intent, or null to erase
7943 * all extras.
7944 */
7945 public Intent replaceExtras(Bundle extras) {
7946 mExtras = extras != null ? new Bundle(extras) : null;
7947 return this;
7948 }
The Android Open Source Project10592532009-03-18 17:39:46 -07007949
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08007950 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007951 * Remove extended data from the intent.
7952 *
7953 * @see #putExtra
7954 */
7955 public void removeExtra(String name) {
7956 if (mExtras != null) {
7957 mExtras.remove(name);
7958 if (mExtras.size() == 0) {
7959 mExtras = null;
7960 }
7961 }
7962 }
7963
7964 /**
7965 * Set special flags controlling how this intent is handled. Most values
7966 * here depend on the type of component being executed by the Intent,
7967 * specifically the FLAG_ACTIVITY_* flags are all for use with
7968 * {@link Context#startActivity Context.startActivity()} and the
7969 * FLAG_RECEIVER_* flags are all for use with
7970 * {@link Context#sendBroadcast(Intent) Context.sendBroadcast()}.
7971 *
Scott Main7aee61f2011-02-08 11:25:01 -08007972 * <p>See the
7973 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
7974 * Stack</a> documentation for important information on how some of these options impact
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007975 * the behavior of your application.
7976 *
7977 * @param flags The desired flags.
7978 *
7979 * @return Returns the same Intent object, for chaining multiple calls
7980 * into a single statement.
7981 *
7982 * @see #getFlags
7983 * @see #addFlags
7984 *
7985 * @see #FLAG_GRANT_READ_URI_PERMISSION
7986 * @see #FLAG_GRANT_WRITE_URI_PERMISSION
Jeff Sharkey846318a2014-04-04 12:12:41 -07007987 * @see #FLAG_GRANT_PERSISTABLE_URI_PERMISSION
7988 * @see #FLAG_GRANT_PREFIX_URI_PERMISSION
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007989 * @see #FLAG_DEBUG_LOG_RESOLUTION
7990 * @see #FLAG_FROM_BACKGROUND
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007991 * @see #FLAG_ACTIVITY_BROUGHT_TO_FRONT
Dianne Hackborn621e17d2010-11-22 15:59:56 -08007992 * @see #FLAG_ACTIVITY_CLEAR_TASK
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007993 * @see #FLAG_ACTIVITY_CLEAR_TOP
Dianne Hackborn621e17d2010-11-22 15:59:56 -08007994 * @see #FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007995 * @see #FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS
7996 * @see #FLAG_ACTIVITY_FORWARD_RESULT
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08007997 * @see #FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007998 * @see #FLAG_ACTIVITY_MULTIPLE_TASK
Craig Mautnerd00f4742014-03-12 14:17:26 -07007999 * @see #FLAG_ACTIVITY_NEW_DOCUMENT
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008000 * @see #FLAG_ACTIVITY_NEW_TASK
Dianne Hackborn621e17d2010-11-22 15:59:56 -08008001 * @see #FLAG_ACTIVITY_NO_ANIMATION
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008002 * @see #FLAG_ACTIVITY_NO_HISTORY
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08008003 * @see #FLAG_ACTIVITY_NO_USER_ACTION
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08008004 * @see #FLAG_ACTIVITY_PREVIOUS_IS_TOP
8005 * @see #FLAG_ACTIVITY_RESET_TASK_IF_NEEDED
Dianne Hackborn621e17d2010-11-22 15:59:56 -08008006 * @see #FLAG_ACTIVITY_REORDER_TO_FRONT
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008007 * @see #FLAG_ACTIVITY_SINGLE_TOP
Dianne Hackborn621e17d2010-11-22 15:59:56 -08008008 * @see #FLAG_ACTIVITY_TASK_ON_HOME
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008009 * @see #FLAG_RECEIVER_REGISTERED_ONLY
8010 */
8011 public Intent setFlags(int flags) {
8012 mFlags = flags;
8013 return this;
8014 }
8015
8016 /**
8017 * Add additional flags to the intent (or with existing flags
8018 * value).
8019 *
8020 * @param flags The new flags to set.
8021 *
8022 * @return Returns the same Intent object, for chaining multiple calls
8023 * into a single statement.
8024 *
8025 * @see #setFlags
8026 */
8027 public Intent addFlags(int flags) {
8028 mFlags |= flags;
8029 return this;
8030 }
8031
8032 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008033 * (Usually optional) Set an explicit application package name that limits
8034 * the components this Intent will resolve to. If left to the default
8035 * value of null, all components in all applications will considered.
8036 * If non-null, the Intent can only match the components in the given
8037 * application package.
8038 *
8039 * @param packageName The name of the application package to handle the
8040 * intent, or null to allow any application package.
8041 *
8042 * @return Returns the same Intent object, for chaining multiple calls
8043 * into a single statement.
8044 *
8045 * @see #getPackage
8046 * @see #resolveActivity
8047 */
8048 public Intent setPackage(String packageName) {
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008049 if (packageName != null && mSelector != null) {
8050 throw new IllegalArgumentException(
8051 "Can't set package name when selector is already set");
8052 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008053 mPackage = packageName;
8054 return this;
8055 }
8056
8057 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008058 * (Usually optional) Explicitly set the component to handle the intent.
8059 * If left with the default value of null, the system will determine the
8060 * appropriate class to use based on the other fields (action, data,
8061 * type, categories) in the Intent. If this class is defined, the
8062 * specified class will always be used regardless of the other fields. You
8063 * should only set this value when you know you absolutely want a specific
8064 * class to be used; otherwise it is better to let the system find the
8065 * appropriate class so that you will respect the installed applications
8066 * and user preferences.
8067 *
8068 * @param component The name of the application component to handle the
8069 * intent, or null to let the system find one for you.
8070 *
8071 * @return Returns the same Intent object, for chaining multiple calls
8072 * into a single statement.
8073 *
8074 * @see #setClass
8075 * @see #setClassName(Context, String)
8076 * @see #setClassName(String, String)
8077 * @see #getComponent
8078 * @see #resolveActivity
8079 */
8080 public Intent setComponent(ComponentName component) {
8081 mComponent = component;
8082 return this;
8083 }
8084
8085 /**
8086 * Convenience for calling {@link #setComponent} with an
8087 * explicit class name.
8088 *
8089 * @param packageContext A Context of the application package implementing
8090 * this class.
8091 * @param className The name of a class inside of the application package
8092 * that will be used as the component for this Intent.
8093 *
8094 * @return Returns the same Intent object, for chaining multiple calls
8095 * into a single statement.
8096 *
8097 * @see #setComponent
8098 * @see #setClass
8099 */
8100 public Intent setClassName(Context packageContext, String className) {
8101 mComponent = new ComponentName(packageContext, className);
8102 return this;
8103 }
8104
8105 /**
8106 * Convenience for calling {@link #setComponent} with an
8107 * explicit application package name and class name.
8108 *
8109 * @param packageName The name of the package implementing the desired
8110 * component.
8111 * @param className The name of a class inside of the application package
8112 * that will be used as the component for this Intent.
8113 *
8114 * @return Returns the same Intent object, for chaining multiple calls
8115 * into a single statement.
8116 *
8117 * @see #setComponent
8118 * @see #setClass
8119 */
8120 public Intent setClassName(String packageName, String className) {
8121 mComponent = new ComponentName(packageName, className);
8122 return this;
8123 }
8124
8125 /**
8126 * Convenience for calling {@link #setComponent(ComponentName)} with the
8127 * name returned by a {@link Class} object.
8128 *
8129 * @param packageContext A Context of the application package implementing
8130 * this class.
8131 * @param cls The class name to set, equivalent to
8132 * <code>setClassName(context, cls.getName())</code>.
8133 *
8134 * @return Returns the same Intent object, for chaining multiple calls
8135 * into a single statement.
8136 *
8137 * @see #setComponent
8138 */
8139 public Intent setClass(Context packageContext, Class<?> cls) {
8140 mComponent = new ComponentName(packageContext, cls);
8141 return this;
8142 }
8143
8144 /**
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08008145 * Set the bounds of the sender of this intent, in screen coordinates. This can be
8146 * used as a hint to the receiver for animations and the like. Null means that there
8147 * is no source bounds.
8148 */
8149 public void setSourceBounds(Rect r) {
8150 if (r != null) {
8151 mSourceBounds = new Rect(r);
8152 } else {
Daniel Lehmanna5b58df2011-10-12 16:24:22 -07008153 mSourceBounds = null;
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08008154 }
8155 }
8156
Tor Norbyed9273d62013-05-30 15:59:53 -07008157 /** @hide */
8158 @IntDef(flag = true,
8159 value = {
8160 FILL_IN_ACTION,
8161 FILL_IN_DATA,
8162 FILL_IN_CATEGORIES,
8163 FILL_IN_COMPONENT,
8164 FILL_IN_PACKAGE,
8165 FILL_IN_SOURCE_BOUNDS,
8166 FILL_IN_SELECTOR,
8167 FILL_IN_CLIP_DATA
8168 })
8169 @Retention(RetentionPolicy.SOURCE)
8170 public @interface FillInFlags {}
8171
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08008172 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008173 * Use with {@link #fillIn} to allow the current action value to be
8174 * overwritten, even if it is already set.
8175 */
8176 public static final int FILL_IN_ACTION = 1<<0;
8177
8178 /**
8179 * Use with {@link #fillIn} to allow the current data or type value
8180 * overwritten, even if it is already set.
8181 */
8182 public static final int FILL_IN_DATA = 1<<1;
8183
8184 /**
8185 * Use with {@link #fillIn} to allow the current categories to be
8186 * overwritten, even if they are already set.
8187 */
8188 public static final int FILL_IN_CATEGORIES = 1<<2;
8189
8190 /**
8191 * Use with {@link #fillIn} to allow the current component value to be
8192 * overwritten, even if it is already set.
8193 */
8194 public static final int FILL_IN_COMPONENT = 1<<3;
8195
8196 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008197 * Use with {@link #fillIn} to allow the current package value to be
8198 * overwritten, even if it is already set.
8199 */
8200 public static final int FILL_IN_PACKAGE = 1<<4;
8201
8202 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008203 * Use with {@link #fillIn} to allow the current bounds rectangle to be
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08008204 * overwritten, even if it is already set.
8205 */
8206 public static final int FILL_IN_SOURCE_BOUNDS = 1<<5;
8207
8208 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008209 * Use with {@link #fillIn} to allow the current selector to be
8210 * overwritten, even if it is already set.
8211 */
8212 public static final int FILL_IN_SELECTOR = 1<<6;
8213
8214 /**
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008215 * Use with {@link #fillIn} to allow the current ClipData to be
8216 * overwritten, even if it is already set.
8217 */
8218 public static final int FILL_IN_CLIP_DATA = 1<<7;
8219
8220 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008221 * Copy the contents of <var>other</var> in to this object, but only
8222 * where fields are not defined by this object. For purposes of a field
8223 * being defined, the following pieces of data in the Intent are
8224 * considered to be separate fields:
8225 *
8226 * <ul>
8227 * <li> action, as set by {@link #setAction}.
Nick Pellyccae4122012-01-09 14:12:58 -08008228 * <li> data Uri and MIME type, as set by {@link #setData(Uri)},
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008229 * {@link #setType(String)}, or {@link #setDataAndType(Uri, String)}.
8230 * <li> categories, as set by {@link #addCategory}.
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008231 * <li> package, as set by {@link #setPackage}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008232 * <li> component, as set by {@link #setComponent(ComponentName)} or
8233 * related methods.
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008234 * <li> source bounds, as set by {@link #setSourceBounds}.
8235 * <li> selector, as set by {@link #setSelector(Intent)}.
8236 * <li> clip data, as set by {@link #setClipData(ClipData)}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008237 * <li> each top-level name in the associated extras.
8238 * </ul>
8239 *
8240 * <p>In addition, you can use the {@link #FILL_IN_ACTION},
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008241 * {@link #FILL_IN_DATA}, {@link #FILL_IN_CATEGORIES}, {@link #FILL_IN_PACKAGE},
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008242 * {@link #FILL_IN_COMPONENT}, {@link #FILL_IN_SOURCE_BOUNDS},
8243 * {@link #FILL_IN_SELECTOR}, and {@link #FILL_IN_CLIP_DATA} to override
8244 * the restriction where the corresponding field will not be replaced if
8245 * it is already set.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008246 *
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008247 * <p>Note: The component field will only be copied if {@link #FILL_IN_COMPONENT}
8248 * is explicitly specified. The selector will only be copied if
8249 * {@link #FILL_IN_SELECTOR} is explicitly specified.
Brett Chabot3e391752009-07-21 16:07:23 -07008250 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008251 * <p>For example, consider Intent A with {data="foo", categories="bar"}
8252 * and Intent B with {action="gotit", data-type="some/thing",
8253 * categories="one","two"}.
8254 *
8255 * <p>Calling A.fillIn(B, Intent.FILL_IN_DATA) will result in A now
8256 * containing: {action="gotit", data-type="some/thing",
8257 * categories="bar"}.
8258 *
8259 * @param other Another Intent whose values are to be used to fill in
8260 * the current one.
8261 * @param flags Options to control which fields can be filled in.
8262 *
8263 * @return Returns a bit mask of {@link #FILL_IN_ACTION},
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008264 * {@link #FILL_IN_DATA}, {@link #FILL_IN_CATEGORIES}, {@link #FILL_IN_PACKAGE},
Tor Norbyed9273d62013-05-30 15:59:53 -07008265 * {@link #FILL_IN_COMPONENT}, {@link #FILL_IN_SOURCE_BOUNDS},
8266 * {@link #FILL_IN_SELECTOR} and {@link #FILL_IN_CLIP_DATA indicating which fields were
8267 * changed.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008268 */
Tor Norbyed9273d62013-05-30 15:59:53 -07008269 @FillInFlags
8270 public int fillIn(Intent other, @FillInFlags int flags) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008271 int changes = 0;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008272 boolean mayHaveCopiedUris = false;
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008273 if (other.mAction != null
8274 && (mAction == null || (flags&FILL_IN_ACTION) != 0)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008275 mAction = other.mAction;
8276 changes |= FILL_IN_ACTION;
8277 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008278 if ((other.mData != null || other.mType != null)
8279 && ((mData == null && mType == null)
8280 || (flags&FILL_IN_DATA) != 0)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008281 mData = other.mData;
8282 mType = other.mType;
8283 changes |= FILL_IN_DATA;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008284 mayHaveCopiedUris = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008285 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008286 if (other.mCategories != null
8287 && (mCategories == null || (flags&FILL_IN_CATEGORIES) != 0)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008288 if (other.mCategories != null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07008289 mCategories = new ArraySet<String>(other.mCategories);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008290 }
8291 changes |= FILL_IN_CATEGORIES;
8292 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008293 if (other.mPackage != null
8294 && (mPackage == null || (flags&FILL_IN_PACKAGE) != 0)) {
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008295 // Only do this if mSelector is not set.
8296 if (mSelector == null) {
8297 mPackage = other.mPackage;
8298 changes |= FILL_IN_PACKAGE;
8299 }
8300 }
8301 // Selector is special: it can only be set if explicitly allowed,
8302 // for the same reason as the component name.
8303 if (other.mSelector != null && (flags&FILL_IN_SELECTOR) != 0) {
8304 if (mPackage == null) {
8305 mSelector = new Intent(other.mSelector);
8306 mPackage = null;
8307 changes |= FILL_IN_SELECTOR;
8308 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008309 }
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008310 if (other.mClipData != null
8311 && (mClipData == null || (flags&FILL_IN_CLIP_DATA) != 0)) {
8312 mClipData = other.mClipData;
8313 changes |= FILL_IN_CLIP_DATA;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008314 mayHaveCopiedUris = true;
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008315 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008316 // Component is special: it can -only- be set if explicitly allowed,
8317 // since otherwise the sender could force the intent somewhere the
8318 // originator didn't intend.
8319 if (other.mComponent != null && (flags&FILL_IN_COMPONENT) != 0) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008320 mComponent = other.mComponent;
8321 changes |= FILL_IN_COMPONENT;
8322 }
8323 mFlags |= other.mFlags;
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08008324 if (other.mSourceBounds != null
8325 && (mSourceBounds == null || (flags&FILL_IN_SOURCE_BOUNDS) != 0)) {
8326 mSourceBounds = new Rect(other.mSourceBounds);
8327 changes |= FILL_IN_SOURCE_BOUNDS;
8328 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008329 if (mExtras == null) {
8330 if (other.mExtras != null) {
8331 mExtras = new Bundle(other.mExtras);
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008332 mayHaveCopiedUris = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008333 }
8334 } else if (other.mExtras != null) {
8335 try {
8336 Bundle newb = new Bundle(other.mExtras);
8337 newb.putAll(mExtras);
8338 mExtras = newb;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008339 mayHaveCopiedUris = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008340 } catch (RuntimeException e) {
8341 // Modifying the extras can cause us to unparcel the contents
8342 // of the bundle, and if we do this in the system process that
8343 // may fail. We really should handle this (i.e., the Bundle
8344 // impl shouldn't be on top of a plain map), but for now just
8345 // ignore it and keep the original contents. :(
8346 Log.w("Intent", "Failure filling in extras", e);
8347 }
8348 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008349 if (mayHaveCopiedUris && mContentUserHint == UserHandle.USER_CURRENT
8350 && other.mContentUserHint != UserHandle.USER_CURRENT) {
8351 mContentUserHint = other.mContentUserHint;
8352 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008353 return changes;
8354 }
8355
8356 /**
8357 * Wrapper class holding an Intent and implementing comparisons on it for
8358 * the purpose of filtering. The class implements its
8359 * {@link #equals equals()} and {@link #hashCode hashCode()} methods as
8360 * simple calls to {@link Intent#filterEquals(Intent)} filterEquals()} and
8361 * {@link android.content.Intent#filterHashCode()} filterHashCode()}
8362 * on the wrapped Intent.
8363 */
8364 public static final class FilterComparison {
8365 private final Intent mIntent;
8366 private final int mHashCode;
8367
8368 public FilterComparison(Intent intent) {
8369 mIntent = intent;
8370 mHashCode = intent.filterHashCode();
8371 }
8372
8373 /**
8374 * Return the Intent that this FilterComparison represents.
8375 * @return Returns the Intent held by the FilterComparison. Do
8376 * not modify!
8377 */
8378 public Intent getIntent() {
8379 return mIntent;
8380 }
8381
8382 @Override
8383 public boolean equals(Object obj) {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08008384 if (obj instanceof FilterComparison) {
8385 Intent other = ((FilterComparison)obj).mIntent;
8386 return mIntent.filterEquals(other);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008387 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08008388 return false;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008389 }
8390
8391 @Override
8392 public int hashCode() {
8393 return mHashCode;
8394 }
8395 }
8396
8397 /**
8398 * Determine if two intents are the same for the purposes of intent
8399 * resolution (filtering). That is, if their action, data, type,
8400 * class, and categories are the same. This does <em>not</em> compare
8401 * any extra data included in the intents.
8402 *
8403 * @param other The other Intent to compare against.
8404 *
8405 * @return Returns true if action, data, type, class, and categories
8406 * are the same.
8407 */
8408 public boolean filterEquals(Intent other) {
8409 if (other == null) {
8410 return false;
8411 }
Christopher Tate63d9ae12014-06-19 19:07:26 -07008412 if (!Objects.equals(this.mAction, other.mAction)) return false;
8413 if (!Objects.equals(this.mData, other.mData)) return false;
8414 if (!Objects.equals(this.mType, other.mType)) return false;
8415 if (!Objects.equals(this.mPackage, other.mPackage)) return false;
8416 if (!Objects.equals(this.mComponent, other.mComponent)) return false;
8417 if (!Objects.equals(this.mCategories, other.mCategories)) return false;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008418
8419 return true;
8420 }
8421
8422 /**
8423 * Generate hash code that matches semantics of filterEquals().
8424 *
8425 * @return Returns the hash value of the action, data, type, class, and
8426 * categories.
8427 *
8428 * @see #filterEquals
8429 */
8430 public int filterHashCode() {
8431 int code = 0;
8432 if (mAction != null) {
8433 code += mAction.hashCode();
8434 }
8435 if (mData != null) {
8436 code += mData.hashCode();
8437 }
8438 if (mType != null) {
8439 code += mType.hashCode();
8440 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008441 if (mPackage != null) {
8442 code += mPackage.hashCode();
8443 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008444 if (mComponent != null) {
8445 code += mComponent.hashCode();
8446 }
8447 if (mCategories != null) {
8448 code += mCategories.hashCode();
8449 }
8450 return code;
8451 }
8452
8453 @Override
8454 public String toString() {
Dianne Hackborn90c52de2011-09-23 12:57:44 -07008455 StringBuilder b = new StringBuilder(128);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008456
Dianne Hackborn1d442e02009-04-20 18:14:05 -07008457 b.append("Intent { ");
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008458 toShortString(b, true, true, true, false);
Dianne Hackborn1d442e02009-04-20 18:14:05 -07008459 b.append(" }");
8460
8461 return b.toString();
8462 }
8463
8464 /** @hide */
Dianne Hackborn90c52de2011-09-23 12:57:44 -07008465 public String toInsecureString() {
8466 StringBuilder b = new StringBuilder(128);
8467
8468 b.append("Intent { ");
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008469 toShortString(b, false, true, true, false);
Dianne Hackborn90c52de2011-09-23 12:57:44 -07008470 b.append(" }");
8471
Dianne Hackborn1d442e02009-04-20 18:14:05 -07008472 return b.toString();
8473 }
Romain Guy4969af72009-06-17 10:53:19 -07008474
Dianne Hackborn1d442e02009-04-20 18:14:05 -07008475 /** @hide */
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008476 public String toInsecureStringWithClip() {
Dianne Hackborn90c52de2011-09-23 12:57:44 -07008477 StringBuilder b = new StringBuilder(128);
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008478
8479 b.append("Intent { ");
8480 toShortString(b, false, true, true, true);
8481 b.append(" }");
8482
Dianne Hackborn90c52de2011-09-23 12:57:44 -07008483 return b.toString();
8484 }
8485
8486 /** @hide */
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008487 public String toShortString(boolean secure, boolean comp, boolean extras, boolean clip) {
8488 StringBuilder b = new StringBuilder(128);
8489 toShortString(b, secure, comp, extras, clip);
8490 return b.toString();
8491 }
8492
8493 /** @hide */
8494 public void toShortString(StringBuilder b, boolean secure, boolean comp, boolean extras,
8495 boolean clip) {
Dianne Hackborn1d442e02009-04-20 18:14:05 -07008496 boolean first = true;
8497 if (mAction != null) {
8498 b.append("act=").append(mAction);
8499 first = false;
8500 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008501 if (mCategories != null) {
Dianne Hackborn1d442e02009-04-20 18:14:05 -07008502 if (!first) {
8503 b.append(' ');
8504 }
8505 first = false;
8506 b.append("cat=[");
Dianne Hackbornadd005c2013-07-17 18:43:12 -07008507 for (int i=0; i<mCategories.size(); i++) {
8508 if (i > 0) b.append(',');
8509 b.append(mCategories.valueAt(i));
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008510 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07008511 b.append("]");
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008512 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07008513 if (mData != null) {
8514 if (!first) {
8515 b.append(' ');
8516 }
8517 first = false;
Wink Savillea4288072010-10-12 12:36:38 -07008518 b.append("dat=");
Dianne Hackborn90c52de2011-09-23 12:57:44 -07008519 if (secure) {
8520 b.append(mData.toSafeString());
Wink Savillea4288072010-10-12 12:36:38 -07008521 } else {
8522 b.append(mData);
8523 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07008524 }
8525 if (mType != null) {
8526 if (!first) {
8527 b.append(' ');
8528 }
8529 first = false;
8530 b.append("typ=").append(mType);
8531 }
8532 if (mFlags != 0) {
8533 if (!first) {
8534 b.append(' ');
8535 }
8536 first = false;
8537 b.append("flg=0x").append(Integer.toHexString(mFlags));
8538 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008539 if (mPackage != null) {
8540 if (!first) {
8541 b.append(' ');
8542 }
8543 first = false;
8544 b.append("pkg=").append(mPackage);
8545 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07008546 if (comp && mComponent != null) {
8547 if (!first) {
8548 b.append(' ');
8549 }
8550 first = false;
8551 b.append("cmp=").append(mComponent.flattenToShortString());
8552 }
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08008553 if (mSourceBounds != null) {
8554 if (!first) {
8555 b.append(' ');
8556 }
8557 first = false;
8558 b.append("bnds=").append(mSourceBounds.toShortString());
8559 }
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008560 if (mClipData != null) {
8561 if (!first) {
8562 b.append(' ');
8563 }
Dianne Hackbornae498722015-08-14 13:29:47 -07008564 b.append("clip={");
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008565 if (clip) {
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008566 mClipData.toShortString(b);
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008567 } else {
Dianne Hackbornae498722015-08-14 13:29:47 -07008568 if (mClipData.getDescription() != null) {
8569 first = !mClipData.getDescription().toShortStringTypesOnly(b);
8570 } else {
8571 first = true;
8572 }
8573 mClipData.toShortStringShortItems(b, first);
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008574 }
Dianne Hackbornae498722015-08-14 13:29:47 -07008575 first = false;
8576 b.append('}');
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008577 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07008578 if (extras && mExtras != null) {
8579 if (!first) {
8580 b.append(' ');
8581 }
8582 first = false;
8583 b.append("(has extras)");
8584 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008585 if (mContentUserHint != UserHandle.USER_CURRENT) {
8586 if (!first) {
8587 b.append(' ');
8588 }
8589 first = false;
8590 b.append("u=").append(mContentUserHint);
8591 }
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008592 if (mSelector != null) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008593 b.append(" sel=");
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008594 mSelector.toShortString(b, secure, comp, extras, clip);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008595 b.append("}");
8596 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008597 }
8598
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008599 /**
8600 * Call {@link #toUri} with 0 flags.
8601 * @deprecated Use {@link #toUri} instead.
8602 */
8603 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008604 public String toURI() {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008605 return toUri(0);
8606 }
8607
8608 /**
8609 * Convert this Intent into a String holding a URI representation of it.
8610 * The returned URI string has been properly URI encoded, so it can be
8611 * used with {@link Uri#parse Uri.parse(String)}. The URI contains the
8612 * Intent's data as the base URI, with an additional fragment describing
8613 * the action, categories, type, flags, package, component, and extras.
Tom Taylord4a47292009-12-21 13:59:18 -08008614 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008615 * <p>You can convert the returned string back to an Intent with
8616 * {@link #getIntent}.
Tom Taylord4a47292009-12-21 13:59:18 -08008617 *
Dianne Hackborn85d558c2014-11-04 10:31:54 -08008618 * @param flags Additional operating flags. Either 0,
8619 * {@link #URI_INTENT_SCHEME}, or {@link #URI_ANDROID_APP_SCHEME}.
Tom Taylord4a47292009-12-21 13:59:18 -08008620 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008621 * @return Returns a URI encoding URI string describing the entire contents
8622 * of the Intent.
8623 */
8624 public String toUri(int flags) {
Dianne Hackborn1d442e02009-04-20 18:14:05 -07008625 StringBuilder uri = new StringBuilder(128);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08008626 if ((flags&URI_ANDROID_APP_SCHEME) != 0) {
8627 if (mPackage == null) {
8628 throw new IllegalArgumentException(
8629 "Intent must include an explicit package name to build an android-app: "
8630 + this);
8631 }
8632 uri.append("android-app://");
8633 uri.append(mPackage);
8634 String scheme = null;
8635 if (mData != null) {
8636 scheme = mData.getScheme();
8637 if (scheme != null) {
8638 uri.append('/');
8639 uri.append(scheme);
8640 String authority = mData.getEncodedAuthority();
8641 if (authority != null) {
8642 uri.append('/');
8643 uri.append(authority);
8644 String path = mData.getEncodedPath();
8645 if (path != null) {
8646 uri.append(path);
8647 }
8648 String queryParams = mData.getEncodedQuery();
8649 if (queryParams != null) {
8650 uri.append('?');
8651 uri.append(queryParams);
8652 }
8653 String fragment = mData.getEncodedFragment();
8654 if (fragment != null) {
8655 uri.append('#');
8656 uri.append(fragment);
8657 }
8658 }
8659 }
8660 }
8661 toUriFragment(uri, null, scheme == null ? Intent.ACTION_MAIN : Intent.ACTION_VIEW,
8662 mPackage, flags);
8663 return uri.toString();
8664 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008665 String scheme = null;
8666 if (mData != null) {
8667 String data = mData.toString();
8668 if ((flags&URI_INTENT_SCHEME) != 0) {
8669 final int N = data.length();
8670 for (int i=0; i<N; i++) {
8671 char c = data.charAt(i);
8672 if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')
8673 || c == '.' || c == '-') {
8674 continue;
8675 }
8676 if (c == ':' && i > 0) {
8677 // Valid scheme.
8678 scheme = data.substring(0, i);
8679 uri.append("intent:");
8680 data = data.substring(i+1);
8681 break;
8682 }
Tom Taylord4a47292009-12-21 13:59:18 -08008683
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008684 // No scheme.
8685 break;
8686 }
8687 }
8688 uri.append(data);
Tom Taylord4a47292009-12-21 13:59:18 -08008689
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008690 } else if ((flags&URI_INTENT_SCHEME) != 0) {
8691 uri.append("intent:");
8692 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008693
Dianne Hackborn85d558c2014-11-04 10:31:54 -08008694 toUriFragment(uri, scheme, Intent.ACTION_VIEW, null, flags);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008695
Dianne Hackborn85d558c2014-11-04 10:31:54 -08008696 return uri.toString();
8697 }
8698
8699 private void toUriFragment(StringBuilder uri, String scheme, String defAction,
8700 String defPackage, int flags) {
8701 StringBuilder frag = new StringBuilder(128);
8702
8703 toUriInner(frag, scheme, defAction, defPackage, flags);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008704 if (mSelector != null) {
Dianne Hackborn80b1c562014-12-09 20:22:08 -08008705 frag.append("SEL;");
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008706 // Note that for now we are not going to try to handle the
8707 // data part; not clear how to represent this as a URI, and
8708 // not much utility in it.
Dianne Hackborn85d558c2014-11-04 10:31:54 -08008709 mSelector.toUriInner(frag, mSelector.mData != null ? mSelector.mData.getScheme() : null,
8710 null, null, flags);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008711 }
8712
Dianne Hackborn85d558c2014-11-04 10:31:54 -08008713 if (frag.length() > 0) {
8714 uri.append("#Intent;");
8715 uri.append(frag);
8716 uri.append("end");
8717 }
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008718 }
8719
Dianne Hackborn85d558c2014-11-04 10:31:54 -08008720 private void toUriInner(StringBuilder uri, String scheme, String defAction,
8721 String defPackage, int flags) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008722 if (scheme != null) {
8723 uri.append("scheme=").append(scheme).append(';');
8724 }
Dianne Hackborn85d558c2014-11-04 10:31:54 -08008725 if (mAction != null && !mAction.equals(defAction)) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008726 uri.append("action=").append(Uri.encode(mAction)).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008727 }
8728 if (mCategories != null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07008729 for (int i=0; i<mCategories.size(); i++) {
8730 uri.append("category=").append(Uri.encode(mCategories.valueAt(i))).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008731 }
8732 }
8733 if (mType != null) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008734 uri.append("type=").append(Uri.encode(mType, "/")).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008735 }
8736 if (mFlags != 0) {
8737 uri.append("launchFlags=0x").append(Integer.toHexString(mFlags)).append(';');
8738 }
Dianne Hackborn85d558c2014-11-04 10:31:54 -08008739 if (mPackage != null && !mPackage.equals(defPackage)) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008740 uri.append("package=").append(Uri.encode(mPackage)).append(';');
8741 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008742 if (mComponent != null) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008743 uri.append("component=").append(Uri.encode(
8744 mComponent.flattenToShortString(), "/")).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008745 }
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08008746 if (mSourceBounds != null) {
8747 uri.append("sourceBounds=")
8748 .append(Uri.encode(mSourceBounds.flattenToString()))
8749 .append(';');
8750 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008751 if (mExtras != null) {
8752 for (String key : mExtras.keySet()) {
8753 final Object value = mExtras.get(key);
8754 char entryType =
8755 value instanceof String ? 'S' :
8756 value instanceof Boolean ? 'B' :
8757 value instanceof Byte ? 'b' :
8758 value instanceof Character ? 'c' :
8759 value instanceof Double ? 'd' :
8760 value instanceof Float ? 'f' :
8761 value instanceof Integer ? 'i' :
8762 value instanceof Long ? 'l' :
8763 value instanceof Short ? 's' :
8764 '\0';
8765
8766 if (entryType != '\0') {
8767 uri.append(entryType);
8768 uri.append('.');
8769 uri.append(Uri.encode(key));
8770 uri.append('=');
8771 uri.append(Uri.encode(value.toString()));
8772 uri.append(';');
8773 }
8774 }
8775 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008776 }
The Android Open Source Project10592532009-03-18 17:39:46 -07008777
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008778 public int describeContents() {
8779 return (mExtras != null) ? mExtras.describeContents() : 0;
8780 }
8781
8782 public void writeToParcel(Parcel out, int flags) {
8783 out.writeString(mAction);
8784 Uri.writeToParcel(out, mData);
8785 out.writeString(mType);
8786 out.writeInt(mFlags);
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008787 out.writeString(mPackage);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008788 ComponentName.writeToParcel(mComponent, out);
8789
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08008790 if (mSourceBounds != null) {
8791 out.writeInt(1);
8792 mSourceBounds.writeToParcel(out, flags);
8793 } else {
8794 out.writeInt(0);
8795 }
8796
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008797 if (mCategories != null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07008798 final int N = mCategories.size();
8799 out.writeInt(N);
8800 for (int i=0; i<N; i++) {
8801 out.writeString(mCategories.valueAt(i));
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008802 }
8803 } else {
8804 out.writeInt(0);
8805 }
8806
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008807 if (mSelector != null) {
8808 out.writeInt(1);
8809 mSelector.writeToParcel(out, flags);
8810 } else {
8811 out.writeInt(0);
8812 }
8813
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008814 if (mClipData != null) {
8815 out.writeInt(1);
8816 mClipData.writeToParcel(out, flags);
8817 } else {
8818 out.writeInt(0);
8819 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008820 out.writeInt(mContentUserHint);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008821 out.writeBundle(mExtras);
8822 }
8823
8824 public static final Parcelable.Creator<Intent> CREATOR
8825 = new Parcelable.Creator<Intent>() {
8826 public Intent createFromParcel(Parcel in) {
8827 return new Intent(in);
8828 }
8829 public Intent[] newArray(int size) {
8830 return new Intent[size];
8831 }
8832 };
8833
Dianne Hackborneb034652009-09-07 00:49:58 -07008834 /** @hide */
8835 protected Intent(Parcel in) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008836 readFromParcel(in);
8837 }
8838
8839 public void readFromParcel(Parcel in) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08008840 setAction(in.readString());
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008841 mData = Uri.CREATOR.createFromParcel(in);
8842 mType = in.readString();
8843 mFlags = in.readInt();
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008844 mPackage = in.readString();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008845 mComponent = ComponentName.readFromParcel(in);
8846
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08008847 if (in.readInt() != 0) {
8848 mSourceBounds = Rect.CREATOR.createFromParcel(in);
8849 }
8850
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008851 int N = in.readInt();
8852 if (N > 0) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07008853 mCategories = new ArraySet<String>();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008854 int i;
8855 for (i=0; i<N; i++) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08008856 mCategories.add(in.readString().intern());
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008857 }
8858 } else {
8859 mCategories = null;
8860 }
8861
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008862 if (in.readInt() != 0) {
8863 mSelector = new Intent(in);
8864 }
8865
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008866 if (in.readInt() != 0) {
8867 mClipData = new ClipData(in);
8868 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008869 mContentUserHint = in.readInt();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008870 mExtras = in.readBundle();
8871 }
8872
8873 /**
8874 * Parses the "intent" element (and its children) from XML and instantiates
8875 * an Intent object. The given XML parser should be located at the tag
8876 * where parsing should start (often named "intent"), from which the
8877 * basic action, data, type, and package and class name will be
8878 * retrieved. The function will then parse in to any child elements,
8879 * looking for <category android:name="xxx"> tags to add categories and
8880 * <extra android:name="xxx" android:value="yyy"> to attach extra data
8881 * to the intent.
8882 *
8883 * @param resources The Resources to use when inflating resources.
8884 * @param parser The XML parser pointing at an "intent" tag.
8885 * @param attrs The AttributeSet interface for retrieving extended
8886 * attribute data at the current <var>parser</var> location.
8887 * @return An Intent object matching the XML data.
8888 * @throws XmlPullParserException If there was an XML parsing error.
8889 * @throws IOException If there was an I/O error.
8890 */
8891 public static Intent parseIntent(Resources resources, XmlPullParser parser, AttributeSet attrs)
8892 throws XmlPullParserException, IOException {
8893 Intent intent = new Intent();
8894
8895 TypedArray sa = resources.obtainAttributes(attrs,
8896 com.android.internal.R.styleable.Intent);
8897
8898 intent.setAction(sa.getString(com.android.internal.R.styleable.Intent_action));
8899
8900 String data = sa.getString(com.android.internal.R.styleable.Intent_data);
8901 String mimeType = sa.getString(com.android.internal.R.styleable.Intent_mimeType);
8902 intent.setDataAndType(data != null ? Uri.parse(data) : null, mimeType);
8903
8904 String packageName = sa.getString(com.android.internal.R.styleable.Intent_targetPackage);
8905 String className = sa.getString(com.android.internal.R.styleable.Intent_targetClass);
8906 if (packageName != null && className != null) {
8907 intent.setComponent(new ComponentName(packageName, className));
8908 }
8909
8910 sa.recycle();
8911
8912 int outerDepth = parser.getDepth();
8913 int type;
8914 while ((type=parser.next()) != XmlPullParser.END_DOCUMENT
8915 && (type != XmlPullParser.END_TAG || parser.getDepth() > outerDepth)) {
8916 if (type == XmlPullParser.END_TAG || type == XmlPullParser.TEXT) {
8917 continue;
8918 }
8919
8920 String nodeName = parser.getName();
Craig Mautner21d24a22014-04-23 11:45:37 -07008921 if (nodeName.equals(TAG_CATEGORIES)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008922 sa = resources.obtainAttributes(attrs,
8923 com.android.internal.R.styleable.IntentCategory);
8924 String cat = sa.getString(com.android.internal.R.styleable.IntentCategory_name);
8925 sa.recycle();
8926
8927 if (cat != null) {
8928 intent.addCategory(cat);
8929 }
8930 XmlUtils.skipCurrentTag(parser);
8931
Craig Mautner21d24a22014-04-23 11:45:37 -07008932 } else if (nodeName.equals(TAG_EXTRA)) {
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08008933 if (intent.mExtras == null) {
8934 intent.mExtras = new Bundle();
8935 }
Craig Mautner21d24a22014-04-23 11:45:37 -07008936 resources.parseBundleExtra(TAG_EXTRA, attrs, intent.mExtras);
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08008937 XmlUtils.skipCurrentTag(parser);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008938
8939 } else {
8940 XmlUtils.skipCurrentTag(parser);
8941 }
8942 }
8943
8944 return intent;
8945 }
Nick Pellyccae4122012-01-09 14:12:58 -08008946
Craig Mautner21d24a22014-04-23 11:45:37 -07008947 /** @hide */
8948 public void saveToXml(XmlSerializer out) throws IOException {
8949 if (mAction != null) {
8950 out.attribute(null, ATTR_ACTION, mAction);
8951 }
8952 if (mData != null) {
8953 out.attribute(null, ATTR_DATA, mData.toString());
8954 }
8955 if (mType != null) {
8956 out.attribute(null, ATTR_TYPE, mType);
8957 }
8958 if (mComponent != null) {
8959 out.attribute(null, ATTR_COMPONENT, mComponent.flattenToShortString());
8960 }
8961 out.attribute(null, ATTR_FLAGS, Integer.toHexString(getFlags()));
8962
8963 if (mCategories != null) {
8964 out.startTag(null, TAG_CATEGORIES);
8965 for (int categoryNdx = mCategories.size() - 1; categoryNdx >= 0; --categoryNdx) {
8966 out.attribute(null, ATTR_CATEGORY, mCategories.valueAt(categoryNdx));
8967 }
Craig Mautner43e52ed2014-06-16 17:18:52 -07008968 out.endTag(null, TAG_CATEGORIES);
Craig Mautner21d24a22014-04-23 11:45:37 -07008969 }
8970 }
8971
8972 /** @hide */
8973 public static Intent restoreFromXml(XmlPullParser in) throws IOException,
8974 XmlPullParserException {
8975 Intent intent = new Intent();
8976 final int outerDepth = in.getDepth();
8977
8978 int attrCount = in.getAttributeCount();
8979 for (int attrNdx = attrCount - 1; attrNdx >= 0; --attrNdx) {
8980 final String attrName = in.getAttributeName(attrNdx);
8981 final String attrValue = in.getAttributeValue(attrNdx);
8982 if (ATTR_ACTION.equals(attrName)) {
8983 intent.setAction(attrValue);
8984 } else if (ATTR_DATA.equals(attrName)) {
8985 intent.setData(Uri.parse(attrValue));
8986 } else if (ATTR_TYPE.equals(attrName)) {
8987 intent.setType(attrValue);
8988 } else if (ATTR_COMPONENT.equals(attrName)) {
8989 intent.setComponent(ComponentName.unflattenFromString(attrValue));
8990 } else if (ATTR_FLAGS.equals(attrName)) {
Narayan Kamatha09b4d22016-04-15 18:32:45 +01008991 intent.setFlags(Integer.parseInt(attrValue, 16));
Craig Mautner21d24a22014-04-23 11:45:37 -07008992 } else {
8993 Log.e("Intent", "restoreFromXml: unknown attribute=" + attrName);
8994 }
8995 }
8996
8997 int event;
8998 String name;
8999 while (((event = in.next()) != XmlPullParser.END_DOCUMENT) &&
9000 (event != XmlPullParser.END_TAG || in.getDepth() < outerDepth)) {
9001 if (event == XmlPullParser.START_TAG) {
9002 name = in.getName();
9003 if (TAG_CATEGORIES.equals(name)) {
9004 attrCount = in.getAttributeCount();
9005 for (int attrNdx = attrCount - 1; attrNdx >= 0; --attrNdx) {
9006 intent.addCategory(in.getAttributeValue(attrNdx));
9007 }
9008 } else {
9009 Log.w("Intent", "restoreFromXml: unknown name=" + name);
9010 XmlUtils.skipCurrentTag(in);
9011 }
9012 }
9013 }
9014
9015 return intent;
9016 }
9017
Nick Pellyccae4122012-01-09 14:12:58 -08009018 /**
9019 * Normalize a MIME data type.
9020 *
9021 * <p>A normalized MIME type has white-space trimmed,
9022 * content-type parameters removed, and is lower-case.
9023 * This aligns the type with Android best practices for
9024 * intent filtering.
9025 *
9026 * <p>For example, "text/plain; charset=utf-8" becomes "text/plain".
9027 * "text/x-vCard" becomes "text/x-vcard".
9028 *
9029 * <p>All MIME types received from outside Android (such as user input,
9030 * or external sources like Bluetooth, NFC, or the Internet) should
9031 * be normalized before they are used to create an Intent.
9032 *
9033 * @param type MIME data type to normalize
9034 * @return normalized MIME data type, or null if the input was null
John Spurlock125d1332013-11-25 11:58:37 -05009035 * @see #setType
9036 * @see #setTypeAndNormalize
Nick Pellyccae4122012-01-09 14:12:58 -08009037 */
9038 public static String normalizeMimeType(String type) {
9039 if (type == null) {
9040 return null;
9041 }
9042
Elliott Hughescb64d432013-08-02 10:00:44 -07009043 type = type.trim().toLowerCase(Locale.ROOT);
Nick Pellyccae4122012-01-09 14:12:58 -08009044
9045 final int semicolonIndex = type.indexOf(';');
9046 if (semicolonIndex != -1) {
9047 type = type.substring(0, semicolonIndex);
9048 }
9049 return type;
9050 }
Jeff Sharkey678d04f2012-03-23 15:41:58 -07009051
9052 /**
Jeff Sharkeya14acd22013-04-02 18:27:45 -07009053 * Prepare this {@link Intent} to leave an app process.
9054 *
9055 * @hide
9056 */
Jeff Sharkey344744b2016-01-28 19:03:30 -07009057 public void prepareToLeaveProcess(Context context) {
9058 final boolean leavingPackage = (mComponent == null)
9059 || !Objects.equals(mComponent.getPackageName(), context.getPackageName());
9060 prepareToLeaveProcess(leavingPackage);
9061 }
9062
9063 /**
9064 * Prepare this {@link Intent} to leave an app process.
9065 *
9066 * @hide
9067 */
9068 public void prepareToLeaveProcess(boolean leavingPackage) {
Jeff Sharkeya14acd22013-04-02 18:27:45 -07009069 setAllowFds(false);
9070
9071 if (mSelector != null) {
Jeff Sharkey344744b2016-01-28 19:03:30 -07009072 mSelector.prepareToLeaveProcess(leavingPackage);
Jeff Sharkeya14acd22013-04-02 18:27:45 -07009073 }
9074 if (mClipData != null) {
Jeff Sharkeyfb833f32016-12-01 14:59:59 -07009075 mClipData.prepareToLeaveProcess(leavingPackage, getFlags());
Jeff Sharkeya14acd22013-04-02 18:27:45 -07009076 }
9077
Jeff Sharkeya8b42782016-01-30 17:58:09 -07009078 if (mAction != null && mData != null && StrictMode.vmFileUriExposureEnabled()
9079 && leavingPackage) {
Jeff Sharkey344744b2016-01-28 19:03:30 -07009080 switch (mAction) {
9081 case ACTION_MEDIA_REMOVED:
9082 case ACTION_MEDIA_UNMOUNTED:
9083 case ACTION_MEDIA_CHECKING:
9084 case ACTION_MEDIA_NOFS:
9085 case ACTION_MEDIA_MOUNTED:
9086 case ACTION_MEDIA_SHARED:
9087 case ACTION_MEDIA_UNSHARED:
9088 case ACTION_MEDIA_BAD_REMOVAL:
9089 case ACTION_MEDIA_UNMOUNTABLE:
9090 case ACTION_MEDIA_EJECT:
9091 case ACTION_MEDIA_SCANNER_STARTED:
9092 case ACTION_MEDIA_SCANNER_FINISHED:
9093 case ACTION_MEDIA_SCANNER_SCAN_FILE:
Jeff Sharkey37355a92016-02-05 16:19:10 -07009094 case ACTION_PACKAGE_NEEDS_VERIFICATION:
9095 case ACTION_PACKAGE_VERIFIED:
Jeff Sharkey344744b2016-01-28 19:03:30 -07009096 // Ignore legacy actions
9097 break;
9098 default:
9099 mData.checkFileUriExposed("Intent.getData()");
Jeff Sharkeya14acd22013-04-02 18:27:45 -07009100 }
9101 }
Jeff Sharkeyfb833f32016-12-01 14:59:59 -07009102
9103 if (mAction != null && mData != null && StrictMode.vmContentUriWithoutPermissionEnabled()
9104 && leavingPackage) {
9105 switch (mAction) {
9106 case ACTION_PROVIDER_CHANGED:
9107 // Ignore actions that don't need to grant
9108 break;
9109 default:
9110 mData.checkContentUriWithoutPermission("Intent.getData()", getFlags());
9111 }
9112 }
Jeff Sharkeya14acd22013-04-02 18:27:45 -07009113 }
9114
9115 /**
Nicolas Prevotd85fc722014-04-16 19:52:08 +01009116 * @hide
9117 */
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009118 public void prepareToEnterProcess() {
Jeff Sharkeyd136e512016-03-09 22:30:56 -07009119 // We just entered destination process, so we should be able to read all
9120 // parcelables inside.
9121 setDefusable(true);
9122
9123 if (mSelector != null) {
9124 mSelector.prepareToEnterProcess();
9125 }
9126 if (mClipData != null) {
9127 mClipData.prepareToEnterProcess();
9128 }
9129
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009130 if (mContentUserHint != UserHandle.USER_CURRENT) {
Nicolas Prevotc4fc00a2014-10-31 12:01:32 +00009131 if (UserHandle.getAppId(Process.myUid()) != Process.SYSTEM_UID) {
9132 fixUris(mContentUserHint);
9133 mContentUserHint = UserHandle.USER_CURRENT;
9134 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009135 }
9136 }
9137
9138 /**
9139 * @hide
9140 */
9141 public void fixUris(int contentUserHint) {
Nicolas Prevotd85fc722014-04-16 19:52:08 +01009142 Uri data = getData();
9143 if (data != null) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009144 mData = maybeAddUserId(data, contentUserHint);
Nicolas Prevotd85fc722014-04-16 19:52:08 +01009145 }
9146 if (mClipData != null) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009147 mClipData.fixUris(contentUserHint);
Nicolas Prevotd85fc722014-04-16 19:52:08 +01009148 }
9149 String action = getAction();
9150 if (ACTION_SEND.equals(action)) {
9151 final Uri stream = getParcelableExtra(EXTRA_STREAM);
9152 if (stream != null) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009153 putExtra(EXTRA_STREAM, maybeAddUserId(stream, contentUserHint));
Nicolas Prevotd85fc722014-04-16 19:52:08 +01009154 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009155 } else if (ACTION_SEND_MULTIPLE.equals(action)) {
Nicolas Prevotd85fc722014-04-16 19:52:08 +01009156 final ArrayList<Uri> streams = getParcelableArrayListExtra(EXTRA_STREAM);
9157 if (streams != null) {
9158 ArrayList<Uri> newStreams = new ArrayList<Uri>();
9159 for (int i = 0; i < streams.size(); i++) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009160 newStreams.add(maybeAddUserId(streams.get(i), contentUserHint));
Nicolas Prevotd85fc722014-04-16 19:52:08 +01009161 }
9162 putParcelableArrayListExtra(EXTRA_STREAM, newStreams);
9163 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009164 } else if (MediaStore.ACTION_IMAGE_CAPTURE.equals(action)
9165 || MediaStore.ACTION_IMAGE_CAPTURE_SECURE.equals(action)
9166 || MediaStore.ACTION_VIDEO_CAPTURE.equals(action)) {
9167 final Uri output = getParcelableExtra(MediaStore.EXTRA_OUTPUT);
9168 if (output != null) {
9169 putExtra(MediaStore.EXTRA_OUTPUT, maybeAddUserId(output, contentUserHint));
9170 }
Nicolas Prevotd85fc722014-04-16 19:52:08 +01009171 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009172 }
Nicolas Prevotd85fc722014-04-16 19:52:08 +01009173
9174 /**
Jeff Sharkey678d04f2012-03-23 15:41:58 -07009175 * Migrate any {@link #EXTRA_STREAM} in {@link #ACTION_SEND} and
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009176 * {@link #ACTION_SEND_MULTIPLE} to {@link ClipData}. Also inspects nested
9177 * intents in {@link #ACTION_CHOOSER}.
Jeff Sharkey678d04f2012-03-23 15:41:58 -07009178 *
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009179 * @return Whether any contents were migrated.
Jeff Sharkey678d04f2012-03-23 15:41:58 -07009180 * @hide
9181 */
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009182 public boolean migrateExtraStreamToClipData() {
Jeff Sharkey678d04f2012-03-23 15:41:58 -07009183 // Refuse to touch if extras already parcelled
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009184 if (mExtras != null && mExtras.isParcelled()) return false;
Jeff Sharkey678d04f2012-03-23 15:41:58 -07009185
9186 // Bail when someone already gave us ClipData
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009187 if (getClipData() != null) return false;
Jeff Sharkey678d04f2012-03-23 15:41:58 -07009188
9189 final String action = getAction();
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009190 if (ACTION_CHOOSER.equals(action)) {
Jeff Sharkeyc004eef2014-09-23 16:40:50 -07009191 // Inspect contained intents to see if we need to migrate extras. We
9192 // don't promote ClipData to the parent, since ChooserActivity will
9193 // already start the picked item as the caller, and we can't combine
9194 // the flags in a safe way.
9195
9196 boolean migrated = false;
Jeff Sharkey1c297002012-05-18 13:55:47 -07009197 try {
Jeff Sharkeyc004eef2014-09-23 16:40:50 -07009198 final Intent intent = getParcelableExtra(EXTRA_INTENT);
9199 if (intent != null) {
9200 migrated |= intent.migrateExtraStreamToClipData();
Jeff Sharkey1c297002012-05-18 13:55:47 -07009201 }
9202 } catch (ClassCastException e) {
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009203 }
Jeff Sharkeyc004eef2014-09-23 16:40:50 -07009204 try {
9205 final Parcelable[] intents = getParcelableArrayExtra(EXTRA_INITIAL_INTENTS);
9206 if (intents != null) {
9207 for (int i = 0; i < intents.length; i++) {
9208 final Intent intent = (Intent) intents[i];
9209 if (intent != null) {
9210 migrated |= intent.migrateExtraStreamToClipData();
9211 }
9212 }
9213 }
9214 } catch (ClassCastException e) {
9215 }
9216 return migrated;
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009217
9218 } else if (ACTION_SEND.equals(action)) {
Jeff Sharkeyf27ea662012-03-27 10:34:24 -07009219 try {
Jeff Sharkeydd471e62012-05-01 13:07:01 -07009220 final Uri stream = getParcelableExtra(EXTRA_STREAM);
9221 final CharSequence text = getCharSequenceExtra(EXTRA_TEXT);
9222 final String htmlText = getStringExtra(EXTRA_HTML_TEXT);
9223 if (stream != null || text != null || htmlText != null) {
9224 final ClipData clipData = new ClipData(
9225 null, new String[] { getType() },
9226 new ClipData.Item(text, htmlText, null, stream));
9227 setClipData(clipData);
9228 addFlags(FLAG_GRANT_READ_URI_PERMISSION);
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009229 return true;
Jeff Sharkeydd471e62012-05-01 13:07:01 -07009230 }
Jeff Sharkeyf27ea662012-03-27 10:34:24 -07009231 } catch (ClassCastException e) {
Jeff Sharkeyf27ea662012-03-27 10:34:24 -07009232 }
Jeff Sharkey678d04f2012-03-23 15:41:58 -07009233
9234 } else if (ACTION_SEND_MULTIPLE.equals(action)) {
Jeff Sharkeyf27ea662012-03-27 10:34:24 -07009235 try {
Jeff Sharkeydd471e62012-05-01 13:07:01 -07009236 final ArrayList<Uri> streams = getParcelableArrayListExtra(EXTRA_STREAM);
9237 final ArrayList<CharSequence> texts = getCharSequenceArrayListExtra(EXTRA_TEXT);
9238 final ArrayList<String> htmlTexts = getStringArrayListExtra(EXTRA_HTML_TEXT);
9239 int num = -1;
9240 if (streams != null) {
9241 num = streams.size();
9242 }
9243 if (texts != null) {
9244 if (num >= 0 && num != texts.size()) {
9245 // Wha...! F- you.
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009246 return false;
Jeff Sharkeydd471e62012-05-01 13:07:01 -07009247 }
9248 num = texts.size();
9249 }
9250 if (htmlTexts != null) {
9251 if (num >= 0 && num != htmlTexts.size()) {
9252 // Wha...! F- you.
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009253 return false;
Jeff Sharkeydd471e62012-05-01 13:07:01 -07009254 }
9255 num = htmlTexts.size();
9256 }
9257 if (num > 0) {
9258 final ClipData clipData = new ClipData(
9259 null, new String[] { getType() },
9260 makeClipItem(streams, texts, htmlTexts, 0));
9261
9262 for (int i = 1; i < num; i++) {
9263 clipData.addItem(makeClipItem(streams, texts, htmlTexts, i));
9264 }
9265
9266 setClipData(clipData);
9267 addFlags(FLAG_GRANT_READ_URI_PERMISSION);
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009268 return true;
Jeff Sharkeydd471e62012-05-01 13:07:01 -07009269 }
Jeff Sharkeyf27ea662012-03-27 10:34:24 -07009270 } catch (ClassCastException e) {
Jeff Sharkeyf27ea662012-03-27 10:34:24 -07009271 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009272 } else if (MediaStore.ACTION_IMAGE_CAPTURE.equals(action)
9273 || MediaStore.ACTION_IMAGE_CAPTURE_SECURE.equals(action)
9274 || MediaStore.ACTION_VIDEO_CAPTURE.equals(action)) {
9275 final Uri output;
9276 try {
9277 output = getParcelableExtra(MediaStore.EXTRA_OUTPUT);
9278 } catch (ClassCastException e) {
9279 return false;
9280 }
9281 if (output != null) {
9282 setClipData(ClipData.newRawUri("", output));
9283 addFlags(FLAG_GRANT_WRITE_URI_PERMISSION|FLAG_GRANT_READ_URI_PERMISSION);
9284 return true;
9285 }
Jeff Sharkey678d04f2012-03-23 15:41:58 -07009286 }
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009287
9288 return false;
Jeff Sharkey678d04f2012-03-23 15:41:58 -07009289 }
Dianne Hackbornac4243f2012-04-13 17:32:18 -07009290
9291 private static ClipData.Item makeClipItem(ArrayList<Uri> streams, ArrayList<CharSequence> texts,
9292 ArrayList<String> htmlTexts, int which) {
9293 Uri uri = streams != null ? streams.get(which) : null;
9294 CharSequence text = texts != null ? texts.get(which) : null;
9295 String htmlText = htmlTexts != null ? htmlTexts.get(which) : null;
9296 return new ClipData.Item(text, htmlText, null, uri);
9297 }
Craig Mautnerd00f4742014-03-12 14:17:26 -07009298
9299 /** @hide */
9300 public boolean isDocument() {
9301 return (mFlags & FLAG_ACTIVITY_NEW_DOCUMENT) == FLAG_ACTIVITY_NEW_DOCUMENT;
9302 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009303}