blob: e0dc10daf64d74194004dcc107249f03916f71c0 [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}
Zak Cohendb6ca492017-01-26 14:09:00 -0800572 * <li> {@link #CATEGORY_VR_HOME}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700573 * </ul>
574 *
575 * <h3>Standard Extra Data</h3>
576 *
577 * <p>These are the current standard fields that can be used as extra data via
578 * {@link #putExtra}.
579 *
580 * <ul>
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800581 * <li> {@link #EXTRA_ALARM_COUNT}
582 * <li> {@link #EXTRA_BCC}
583 * <li> {@link #EXTRA_CC}
584 * <li> {@link #EXTRA_CHANGED_COMPONENT_NAME}
585 * <li> {@link #EXTRA_DATA_REMOVED}
586 * <li> {@link #EXTRA_DOCK_STATE}
Praveen Bharathi21e941b2010-10-06 15:23:14 -0500587 * <li> {@link #EXTRA_DOCK_STATE_HE_DESK}
588 * <li> {@link #EXTRA_DOCK_STATE_LE_DESK}
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800589 * <li> {@link #EXTRA_DOCK_STATE_CAR}
590 * <li> {@link #EXTRA_DOCK_STATE_DESK}
591 * <li> {@link #EXTRA_DOCK_STATE_UNDOCKED}
592 * <li> {@link #EXTRA_DONT_KILL_APP}
593 * <li> {@link #EXTRA_EMAIL}
594 * <li> {@link #EXTRA_INITIAL_INTENTS}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700595 * <li> {@link #EXTRA_INTENT}
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800596 * <li> {@link #EXTRA_KEY_EVENT}
rich cannings706e8ba2012-08-20 13:20:14 -0700597 * <li> {@link #EXTRA_ORIGINATING_URI}
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800598 * <li> {@link #EXTRA_PHONE_NUMBER}
rich cannings368ed012012-06-07 15:37:57 -0700599 * <li> {@link #EXTRA_REFERRER}
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800600 * <li> {@link #EXTRA_REMOTE_INTENT_TOKEN}
601 * <li> {@link #EXTRA_REPLACING}
602 * <li> {@link #EXTRA_SHORTCUT_ICON}
603 * <li> {@link #EXTRA_SHORTCUT_ICON_RESOURCE}
604 * <li> {@link #EXTRA_SHORTCUT_INTENT}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700605 * <li> {@link #EXTRA_STREAM}
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800606 * <li> {@link #EXTRA_SHORTCUT_NAME}
607 * <li> {@link #EXTRA_SUBJECT}
608 * <li> {@link #EXTRA_TEMPLATE}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700609 * <li> {@link #EXTRA_TEXT}
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800610 * <li> {@link #EXTRA_TITLE}
611 * <li> {@link #EXTRA_UID}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700612 * </ul>
613 *
614 * <h3>Flags</h3>
615 *
616 * <p>These are the possible flags that can be used in the Intent via
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800617 * {@link #setFlags} and {@link #addFlags}. See {@link #setFlags} for a list
618 * of all possible flags.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700619 */
Dianne Hackbornee0511d2009-12-21 18:08:13 -0800620public class Intent implements Parcelable, Cloneable {
Craig Mautner21d24a22014-04-23 11:45:37 -0700621 private static final String ATTR_ACTION = "action";
622 private static final String TAG_CATEGORIES = "categories";
623 private static final String ATTR_CATEGORY = "category";
624 private static final String TAG_EXTRA = "extra";
625 private static final String ATTR_TYPE = "type";
626 private static final String ATTR_COMPONENT = "component";
627 private static final String ATTR_DATA = "data";
628 private static final String ATTR_FLAGS = "flags";
629
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700630 // ---------------------------------------------------------------------
631 // ---------------------------------------------------------------------
632 // Standard intent activity actions (see action variable).
633
634 /**
635 * Activity Action: Start as a main entry point, does not expect to
636 * receive data.
637 * <p>Input: nothing
638 * <p>Output: nothing
639 */
640 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
641 public static final String ACTION_MAIN = "android.intent.action.MAIN";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800642
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700643 /**
644 * Activity Action: Display the data to the user. This is the most common
645 * action performed on data -- it is the generic action you can use on
646 * a piece of data to get the most reasonable thing to occur. For example,
647 * when used on a contacts entry it will view the entry; when used on a
648 * mailto: URI it will bring up a compose window filled with the information
649 * supplied by the URI; when used with a tel: URI it will invoke the
650 * dialer.
651 * <p>Input: {@link #getData} is URI from which to retrieve data.
652 * <p>Output: nothing.
653 */
654 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
655 public static final String ACTION_VIEW = "android.intent.action.VIEW";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800656
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700657 /**
658 * A synonym for {@link #ACTION_VIEW}, the "standard" action that is
659 * performed on a piece of data.
660 */
661 public static final String ACTION_DEFAULT = ACTION_VIEW;
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800662
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700663 /**
Tomasz Mikolajewski319fb492016-01-20 12:24:01 +0900664 * Activity Action: Quick view the data. Launches a quick viewer for
665 * a URI or a list of URIs.
Tomasz Mikolajewskife023132016-03-10 17:42:35 +0900666 * <p>Activities handling this intent action should handle the vast majority of
667 * MIME types rather than only specific ones.
Tomasz Mikolajewski319fb492016-01-20 12:24:01 +0900668 * <p>Input: {@link #getData} is a mandatory content URI of the item to
669 * preview. {@link #getClipData} contains an optional list of content URIs
670 * if there is more than one item to preview. {@link #EXTRA_INDEX} is an
671 * optional index of the URI in the clip data to show first.
Tomasz Mikolajewski17c50da2017-02-16 14:38:04 +0900672 * <p>By default quick viewers are supposed to be lightweight and focus on
673 * previewing the content only. They should not expose features such as printing,
674 * opening in an external app, deleting, rotating, casting, etc.
675 * However, if {@link #EXTRA_QUICK_VIEW_ADVANCED} is true, then the quick viewer
676 * may show advanced UI which includes convenience actions suitable for the passed
677 * Uris.
Steve McKayc78bcb82015-07-31 14:35:22 -0700678 * <p>Output: nothing.
Tomasz Mikolajewski17c50da2017-02-16 14:38:04 +0900679 * @see #EXTRA_QUICK_VIEW_ADVANCED
Tomasz Mikolajewski867addf2017-02-01 14:16:39 +0900680 * @see #EXTRA_INDEX
Steve McKayc78bcb82015-07-31 14:35:22 -0700681 */
682 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
683 public static final String ACTION_QUICK_VIEW = "android.intent.action.QUICK_VIEW";
684
685 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700686 * Used to indicate that some piece of data should be attached to some other
687 * place. For example, image data could be attached to a contact. It is up
688 * to the recipient to decide where the data should be attached; the intent
689 * does not specify the ultimate destination.
690 * <p>Input: {@link #getData} is URI of data to be attached.
691 * <p>Output: nothing.
692 */
693 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
694 public static final String ACTION_ATTACH_DATA = "android.intent.action.ATTACH_DATA";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800695
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700696 /**
697 * Activity Action: Provide explicit editable access to the given data.
698 * <p>Input: {@link #getData} is URI of data to be edited.
699 * <p>Output: nothing.
700 */
701 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
702 public static final String ACTION_EDIT = "android.intent.action.EDIT";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800703
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700704 /**
705 * Activity Action: Pick an existing item, or insert a new item, and then edit it.
706 * <p>Input: {@link #getType} is the desired MIME type of the item to create or edit.
707 * The extras can contain type specific data to pass through to the editing/creating
708 * activity.
709 * <p>Output: The URI of the item that was picked. This must be a content:
710 * URI so that any receiver can access it.
711 */
712 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
713 public static final String ACTION_INSERT_OR_EDIT = "android.intent.action.INSERT_OR_EDIT";
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: Pick an item from the data, returning what was selected.
717 * <p>Input: {@link #getData} is URI containing a directory of data
718 * (vnd.android.cursor.dir/*) from which to pick an item.
719 * <p>Output: The URI of the item that was picked.
720 */
721 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
722 public static final String ACTION_PICK = "android.intent.action.PICK";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800723
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700724 /**
725 * Activity Action: Creates a shortcut.
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800726 * <p>Input: Nothing.</p>
Sunny Goyala6be88a2017-01-12 16:27:58 -0800727 * <p>Output: An Intent representing the {@link android.content.pm.ShortcutInfo} result.</p>
728 * <p>For compatibility with older versions of android the intent may also contain three
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700729 * extras: SHORTCUT_INTENT (value: Intent), SHORTCUT_NAME (value: String),
730 * and SHORTCUT_ICON (value: Bitmap) or SHORTCUT_ICON_RESOURCE
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800731 * (value: ShortcutIconResource).</p>
732 *
Sunny Goyala6be88a2017-01-12 16:27:58 -0800733 * @see android.content.pm.ShortcutManager#createShortcutResultIntent
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700734 * @see #EXTRA_SHORTCUT_INTENT
735 * @see #EXTRA_SHORTCUT_NAME
736 * @see #EXTRA_SHORTCUT_ICON
737 * @see #EXTRA_SHORTCUT_ICON_RESOURCE
738 * @see android.content.Intent.ShortcutIconResource
739 */
740 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
741 public static final String ACTION_CREATE_SHORTCUT = "android.intent.action.CREATE_SHORTCUT";
742
743 /**
744 * The name of the extra used to define the Intent of a shortcut.
745 *
746 * @see #ACTION_CREATE_SHORTCUT
Sunny Goyala6be88a2017-01-12 16:27:58 -0800747 * @deprecated Replaced with {@link android.content.pm.ShortcutManager#createShortcutResultIntent}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700748 */
Sunny Goyala6be88a2017-01-12 16:27:58 -0800749 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700750 public static final String EXTRA_SHORTCUT_INTENT = "android.intent.extra.shortcut.INTENT";
751 /**
752 * The name of the extra used to define the name of a shortcut.
753 *
754 * @see #ACTION_CREATE_SHORTCUT
Sunny Goyala6be88a2017-01-12 16:27:58 -0800755 * @deprecated Replaced with {@link android.content.pm.ShortcutManager#createShortcutResultIntent}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700756 */
Sunny Goyala6be88a2017-01-12 16:27:58 -0800757 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700758 public static final String EXTRA_SHORTCUT_NAME = "android.intent.extra.shortcut.NAME";
759 /**
760 * The name of the extra used to define the icon, as a Bitmap, of a shortcut.
761 *
762 * @see #ACTION_CREATE_SHORTCUT
Sunny Goyala6be88a2017-01-12 16:27:58 -0800763 * @deprecated Replaced with {@link android.content.pm.ShortcutManager#createShortcutResultIntent}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700764 */
Sunny Goyala6be88a2017-01-12 16:27:58 -0800765 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700766 public static final String EXTRA_SHORTCUT_ICON = "android.intent.extra.shortcut.ICON";
767 /**
768 * The name of the extra used to define the icon, as a ShortcutIconResource, of a shortcut.
769 *
770 * @see #ACTION_CREATE_SHORTCUT
771 * @see android.content.Intent.ShortcutIconResource
Sunny Goyala6be88a2017-01-12 16:27:58 -0800772 * @deprecated Replaced with {@link android.content.pm.ShortcutManager#createShortcutResultIntent}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700773 */
Sunny Goyala6be88a2017-01-12 16:27:58 -0800774 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700775 public static final String EXTRA_SHORTCUT_ICON_RESOURCE =
776 "android.intent.extra.shortcut.ICON_RESOURCE";
777
778 /**
Jason Monk2f68e8a2016-02-23 17:57:28 -0500779 * An activity that provides a user interface for adjusting application preferences.
780 * Optional but recommended settings for all applications which have settings.
781 */
782 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
783 public static final String ACTION_APPLICATION_PREFERENCES
784 = "android.intent.action.APPLICATION_PREFERENCES";
785
786 /**
Sudheer Shanka80b66412016-04-06 18:31:10 -0700787 * Activity Action: Launch an activity showing the app information.
788 * For applications which install other applications (such as app stores), it is recommended
789 * to handle this action for providing the app information to the user.
790 *
791 * <p>Input: {@link #EXTRA_PACKAGE_NAME} specifies the package whose information needs
792 * to be displayed.
793 * <p>Output: Nothing.
794 */
795 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
796 public static final String ACTION_SHOW_APP_INFO
797 = "android.intent.action.SHOW_APP_INFO";
798
799 /**
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800800 * Represents a shortcut/live folder icon resource.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700801 *
802 * @see Intent#ACTION_CREATE_SHORTCUT
803 * @see Intent#EXTRA_SHORTCUT_ICON_RESOURCE
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800804 * @see android.provider.LiveFolders#ACTION_CREATE_LIVE_FOLDER
805 * @see android.provider.LiveFolders#EXTRA_LIVE_FOLDER_ICON
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700806 */
807 public static class ShortcutIconResource implements Parcelable {
808 /**
809 * The package name of the application containing the icon.
810 */
811 public String packageName;
812
813 /**
814 * The resource name of the icon, including package, name and type.
815 */
816 public String resourceName;
817
818 /**
819 * Creates a new ShortcutIconResource for the specified context and resource
820 * identifier.
821 *
822 * @param context The context of the application.
Tor Norbye7b9c9122013-05-30 16:48:33 -0700823 * @param resourceId The resource identifier for the icon.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700824 * @return A new ShortcutIconResource with the specified's context package name
Tor Norbye7b9c9122013-05-30 16:48:33 -0700825 * and icon resource identifier.``
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700826 */
Tor Norbye7b9c9122013-05-30 16:48:33 -0700827 public static ShortcutIconResource fromContext(Context context, @AnyRes int resourceId) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700828 ShortcutIconResource icon = new ShortcutIconResource();
829 icon.packageName = context.getPackageName();
830 icon.resourceName = context.getResources().getResourceName(resourceId);
831 return icon;
832 }
833
834 /**
835 * Used to read a ShortcutIconResource from a Parcel.
836 */
837 public static final Parcelable.Creator<ShortcutIconResource> CREATOR =
838 new Parcelable.Creator<ShortcutIconResource>() {
839
840 public ShortcutIconResource createFromParcel(Parcel source) {
841 ShortcutIconResource icon = new ShortcutIconResource();
842 icon.packageName = source.readString();
843 icon.resourceName = source.readString();
844 return icon;
845 }
846
847 public ShortcutIconResource[] newArray(int size) {
848 return new ShortcutIconResource[size];
849 }
850 };
851
852 /**
853 * No special parcel contents.
854 */
855 public int describeContents() {
856 return 0;
857 }
858
859 public void writeToParcel(Parcel dest, int flags) {
860 dest.writeString(packageName);
861 dest.writeString(resourceName);
862 }
863
864 @Override
865 public String toString() {
866 return resourceName;
867 }
868 }
869
870 /**
871 * Activity Action: Display an activity chooser, allowing the user to pick
872 * what they want to before proceeding. This can be used as an alternative
873 * to the standard activity picker that is displayed by the system when
874 * you try to start an activity with multiple possible matches, with these
875 * differences in behavior:
876 * <ul>
877 * <li>You can specify the title that will appear in the activity chooser.
878 * <li>The user does not have the option to make one of the matching
879 * activities a preferred activity, and all possible activities will
880 * always be shown even if one of them is currently marked as the
881 * preferred activity.
882 * </ul>
883 * <p>
884 * This action should be used when the user will naturally expect to
885 * select an activity in order to proceed. An example if when not to use
886 * it is when the user clicks on a "mailto:" link. They would naturally
887 * expect to go directly to their mail app, so startActivity() should be
888 * called directly: it will
889 * either launch the current preferred app, or put up a dialog allowing the
890 * user to pick an app to use and optionally marking that as preferred.
891 * <p>
892 * In contrast, if the user is selecting a menu item to send a picture
893 * they are viewing to someone else, there are many different things they
894 * may want to do at this point: send it through e-mail, upload it to a
895 * web service, etc. In this case the CHOOSER action should be used, to
896 * always present to the user a list of the things they can do, with a
897 * nice title given by the caller such as "Send this photo with:".
898 * <p>
Dianne Hackborne302a162012-05-15 14:58:32 -0700899 * If you need to grant URI permissions through a chooser, you must specify
900 * the permissions to be granted on the ACTION_CHOOSER Intent
901 * <em>in addition</em> to the EXTRA_INTENT inside. This means using
902 * {@link #setClipData} to specify the URIs to be granted as well as
903 * {@link #FLAG_GRANT_READ_URI_PERMISSION} and/or
904 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION} as appropriate.
905 * <p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700906 * As a convenience, an Intent of this form can be created with the
907 * {@link #createChooser} function.
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -0700908 * <p>
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -0700909 * Input: No data should be specified. get*Extra must have
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700910 * a {@link #EXTRA_INTENT} field containing the Intent being executed,
911 * and can optionally have a {@link #EXTRA_TITLE} field containing the
912 * title text to display in the chooser.
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -0700913 * <p>
914 * Output: Depends on the protocol of {@link #EXTRA_INTENT}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700915 */
916 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
917 public static final String ACTION_CHOOSER = "android.intent.action.CHOOSER";
918
919 /**
920 * Convenience function for creating a {@link #ACTION_CHOOSER} Intent.
921 *
Dianne Hackborne302a162012-05-15 14:58:32 -0700922 * <p>Builds a new {@link #ACTION_CHOOSER} Intent that wraps the given
923 * target intent, also optionally supplying a title. If the target
924 * intent has specified {@link #FLAG_GRANT_READ_URI_PERMISSION} or
925 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, then these flags will also be
926 * set in the returned chooser intent, with its ClipData set appropriately:
927 * either a direct reflection of {@link #getClipData()} if that is non-null,
John Spurlock33900182014-01-02 11:04:18 -0500928 * or a new ClipData built from {@link #getData()}.
Dianne Hackborne302a162012-05-15 14:58:32 -0700929 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700930 * @param target The Intent that the user will be selecting an activity
931 * to perform.
932 * @param title Optional title that will be displayed in the chooser.
933 * @return Return a new Intent object that you can hand to
934 * {@link Context#startActivity(Intent) Context.startActivity()} and
935 * related methods.
936 */
937 public static Intent createChooser(Intent target, CharSequence title) {
Adam Powell0b3c1122014-10-09 12:50:14 -0700938 return createChooser(target, title, null);
939 }
940
941 /**
942 * Convenience function for creating a {@link #ACTION_CHOOSER} Intent.
943 *
944 * <p>Builds a new {@link #ACTION_CHOOSER} Intent that wraps the given
945 * target intent, also optionally supplying a title. If the target
946 * intent has specified {@link #FLAG_GRANT_READ_URI_PERMISSION} or
947 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, then these flags will also be
948 * set in the returned chooser intent, with its ClipData set appropriately:
949 * either a direct reflection of {@link #getClipData()} if that is non-null,
950 * or a new ClipData built from {@link #getData()}.</p>
951 *
952 * <p>The caller may optionally supply an {@link IntentSender} to receive a callback
953 * when the user makes a choice. This can be useful if the calling application wants
954 * to remember the last chosen target and surface it as a more prominent or one-touch
955 * affordance elsewhere in the UI for next time.</p>
956 *
957 * @param target The Intent that the user will be selecting an activity
958 * to perform.
959 * @param title Optional title that will be displayed in the chooser.
960 * @param sender Optional IntentSender to be called when a choice is made.
961 * @return Return a new Intent object that you can hand to
962 * {@link Context#startActivity(Intent) Context.startActivity()} and
963 * related methods.
964 */
965 public static Intent createChooser(Intent target, CharSequence title, IntentSender sender) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700966 Intent intent = new Intent(ACTION_CHOOSER);
967 intent.putExtra(EXTRA_INTENT, target);
968 if (title != null) {
969 intent.putExtra(EXTRA_TITLE, title);
970 }
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -0700971
Adam Powell0b3c1122014-10-09 12:50:14 -0700972 if (sender != null) {
973 intent.putExtra(EXTRA_CHOSEN_COMPONENT_INTENT_SENDER, sender);
974 }
975
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -0700976 // Migrate any clip data and flags from target.
Jeff Sharkey846318a2014-04-04 12:12:41 -0700977 int permFlags = target.getFlags() & (FLAG_GRANT_READ_URI_PERMISSION
978 | FLAG_GRANT_WRITE_URI_PERMISSION | FLAG_GRANT_PERSISTABLE_URI_PERMISSION
979 | FLAG_GRANT_PREFIX_URI_PERMISSION);
Dianne Hackborne302a162012-05-15 14:58:32 -0700980 if (permFlags != 0) {
981 ClipData targetClipData = target.getClipData();
982 if (targetClipData == null && target.getData() != null) {
983 ClipData.Item item = new ClipData.Item(target.getData());
984 String[] mimeTypes;
985 if (target.getType() != null) {
986 mimeTypes = new String[] { target.getType() };
987 } else {
988 mimeTypes = new String[] { };
989 }
990 targetClipData = new ClipData(null, mimeTypes, item);
991 }
992 if (targetClipData != null) {
993 intent.setClipData(targetClipData);
994 intent.addFlags(permFlags);
995 }
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -0700996 }
Dianne Hackborne302a162012-05-15 14:58:32 -0700997
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700998 return intent;
999 }
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07001000
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001001 /**
1002 * Activity Action: Allow the user to select a particular kind of data and
1003 * return it. This is different than {@link #ACTION_PICK} in that here we
1004 * just say what kind of data is desired, not a URI of existing data from
Dianne Hackbornfdb3f092013-01-28 15:10:48 -08001005 * which the user can pick. An ACTION_GET_CONTENT could allow the user to
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001006 * create the data as it runs (for example taking a picture or recording a
Ken Wakasaf76a50c2012-03-09 19:56:35 +09001007 * sound), let them browse over the web and download the desired data,
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001008 * etc.
1009 * <p>
Ken Wakasaf76a50c2012-03-09 19:56:35 +09001010 * 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 -07001011 * of data, such as a person contact, you set the MIME type to the kind of
1012 * data you want and launch it with {@link Context#startActivity(Intent)}.
1013 * The system will then launch the best application to select that kind
1014 * of data for you.
1015 * <p>
1016 * You may also be interested in any of a set of types of content the user
1017 * can pick. For example, an e-mail application that wants to allow the
1018 * user to add an attachment to an e-mail message can use this action to
1019 * bring up a list of all of the types of content the user can attach.
1020 * <p>
1021 * In this case, you should wrap the GET_CONTENT intent with a chooser
1022 * (through {@link #createChooser}), which will give the proper interface
1023 * for the user to pick how to send your data and allow you to specify
1024 * a prompt indicating what they are doing. You will usually specify a
1025 * broad MIME type (such as image/* or {@literal *}/*), resulting in a
1026 * broad range of content types the user can select from.
1027 * <p>
Ken Wakasaf76a50c2012-03-09 19:56:35 +09001028 * When using such a broad GET_CONTENT action, it is often desirable to
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001029 * only pick from data that can be represented as a stream. This is
1030 * accomplished by requiring the {@link #CATEGORY_OPENABLE} in the Intent.
1031 * <p>
Dianne Hackbornc4d0e6f2011-01-25 14:55:06 -08001032 * Callers can optionally specify {@link #EXTRA_LOCAL_ONLY} to request that
Ken Wakasaf76a50c2012-03-09 19:56:35 +09001033 * the launched content chooser only returns results representing data that
Dianne Hackbornc4d0e6f2011-01-25 14:55:06 -08001034 * is locally available on the device. For example, if this extra is set
1035 * to true then an image picker should not show any pictures that are available
1036 * from a remote server but not already on the local device (thus requiring
1037 * they be downloaded when opened).
1038 * <p>
Dianne Hackbornfdb3f092013-01-28 15:10:48 -08001039 * If the caller can handle multiple returned items (the user performing
1040 * multiple selection), then it can specify {@link #EXTRA_ALLOW_MULTIPLE}
1041 * to indicate this.
1042 * <p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001043 * Input: {@link #getType} is the desired MIME type to retrieve. Note
1044 * that no URI is supplied in the intent, as there are no constraints on
1045 * where the returned data originally comes from. You may also include the
1046 * {@link #CATEGORY_OPENABLE} if you can only accept data that can be
Dianne Hackbornc4d0e6f2011-01-25 14:55:06 -08001047 * opened as a stream. You may use {@link #EXTRA_LOCAL_ONLY} to limit content
Dianne Hackbornfdb3f092013-01-28 15:10:48 -08001048 * selection to local data. You may use {@link #EXTRA_ALLOW_MULTIPLE} to
1049 * allow the user to select multiple items.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001050 * <p>
1051 * Output: The URI of the item that was picked. This must be a content:
1052 * URI so that any receiver can access it.
1053 */
1054 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1055 public static final String ACTION_GET_CONTENT = "android.intent.action.GET_CONTENT";
1056 /**
1057 * Activity Action: Dial a number as specified by the data. This shows a
1058 * UI with the number being dialed, allowing the user to explicitly
1059 * initiate the call.
1060 * <p>Input: If nothing, an empty dialer is started; else {@link #getData}
1061 * is URI of a phone number to be dialed or a tel: URI of an explicit phone
1062 * number.
1063 * <p>Output: nothing.
1064 */
1065 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1066 public static final String ACTION_DIAL = "android.intent.action.DIAL";
1067 /**
1068 * Activity Action: Perform a call to someone specified by the data.
1069 * <p>Input: If nothing, an empty dialer is started; else {@link #getData}
1070 * is URI of a phone number to be dialed or a tel: URI of an explicit phone
1071 * number.
1072 * <p>Output: nothing.
1073 *
1074 * <p>Note: there will be restrictions on which applications can initiate a
1075 * call; most applications should use the {@link #ACTION_DIAL}.
1076 * <p>Note: this Intent <strong>cannot</strong> be used to call emergency
1077 * numbers. Applications can <strong>dial</strong> emergency numbers using
1078 * {@link #ACTION_DIAL}, however.
Svetoslav7008b512015-06-24 18:47:07 -07001079 *
Dianne Hackborn0e3de6c2015-07-29 15:20:21 -07001080 * <p>Note: if you app targets {@link android.os.Build.VERSION_CODES#M M}
Svetoslav7008b512015-06-24 18:47:07 -07001081 * and above and declares as using the {@link android.Manifest.permission#CALL_PHONE}
Svet Ganov7121e182015-07-13 22:38:12 -07001082 * permission which is not granted, then attempting to use this action will
Svetoslav7008b512015-06-24 18:47:07 -07001083 * result in a {@link java.lang.SecurityException}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001084 */
1085 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1086 public static final String ACTION_CALL = "android.intent.action.CALL";
1087 /**
1088 * Activity Action: Perform a call to an emergency number specified by the
1089 * data.
1090 * <p>Input: {@link #getData} is URI of a phone number to be dialed or a
1091 * tel: URI of an explicit phone number.
1092 * <p>Output: nothing.
1093 * @hide
1094 */
1095 public static final String ACTION_CALL_EMERGENCY = "android.intent.action.CALL_EMERGENCY";
1096 /**
1097 * Activity action: Perform a call to any number (emergency or not)
1098 * specified by the data.
1099 * <p>Input: {@link #getData} is URI of a phone number to be dialed or a
1100 * tel: URI of an explicit phone number.
1101 * <p>Output: nothing.
1102 * @hide
1103 */
1104 public static final String ACTION_CALL_PRIVILEGED = "android.intent.action.CALL_PRIVILEGED";
1105 /**
Santos Cordon15a13782015-03-31 18:32:31 -07001106 * Activity action: Activate the current SIM card. If SIM cards do not require activation,
1107 * sending this intent is a no-op.
1108 * <p>Input: No data should be specified. get*Extra may have an optional
1109 * {@link #EXTRA_SIM_ACTIVATION_RESPONSE} field containing a PendingIntent through which to
1110 * send the activation result.
1111 * <p>Output: nothing.
1112 * @hide
1113 */
1114 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1115 public static final String ACTION_SIM_ACTIVATION_REQUEST =
1116 "android.intent.action.SIM_ACTIVATION_REQUEST";
1117 /**
fionaxuadfe7002017-02-17 17:20:46 -08001118 * Activity Action: Main entry point for carrier setup apps.
1119 * <p>Carrier apps that provide an implementation for this action may be invoked to configure
1120 * carrier service and typically require
1121 * {@link android.telephony.TelephonyManager#hasCarrierPrivileges() carrier privileges} to
1122 * fulfill their duties.
1123 */
1124 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1125 public static final String ACTION_CARRIER_SETUP = "android.intent.action.CARRIER_SETUP";
1126 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001127 * Activity Action: Send a message to someone specified by the data.
1128 * <p>Input: {@link #getData} is URI describing the target.
1129 * <p>Output: nothing.
1130 */
1131 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1132 public static final String ACTION_SENDTO = "android.intent.action.SENDTO";
1133 /**
1134 * Activity Action: Deliver some data to someone else. Who the data is
1135 * being delivered to is not specified; it is up to the receiver of this
1136 * action to ask the user where the data should be sent.
1137 * <p>
1138 * When launching a SEND intent, you should usually wrap it in a chooser
1139 * (through {@link #createChooser}), which will give the proper interface
1140 * for the user to pick how to send your data and allow you to specify
1141 * a prompt indicating what they are doing.
1142 * <p>
1143 * Input: {@link #getType} is the MIME type of the data being sent.
1144 * get*Extra can have either a {@link #EXTRA_TEXT}
1145 * or {@link #EXTRA_STREAM} field, containing the data to be sent. If
1146 * using EXTRA_TEXT, the MIME type should be "text/plain"; otherwise it
1147 * should be the MIME type of the data in EXTRA_STREAM. Use {@literal *}/*
1148 * if the MIME type is unknown (this will only allow senders that can
Dianne Hackbornacb69bb2012-04-13 15:36:06 -07001149 * handle generic data streams). If using {@link #EXTRA_TEXT}, you can
1150 * also optionally supply {@link #EXTRA_HTML_TEXT} for clients to retrieve
1151 * your text with HTML formatting.
1152 * <p>
1153 * As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN}, the data
1154 * being sent can be supplied through {@link #setClipData(ClipData)}. This
1155 * allows you to use {@link #FLAG_GRANT_READ_URI_PERMISSION} when sharing
1156 * content: URIs and other advanced features of {@link ClipData}. If
1157 * using this approach, you still must supply the same data through the
1158 * {@link #EXTRA_TEXT} or {@link #EXTRA_STREAM} fields described below
1159 * for compatibility with old applications. If you don't set a ClipData,
1160 * it will be copied there for you when calling {@link Context#startActivity(Intent)}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001161 * <p>
Tomasz Mikolajewskid8a2e192016-12-15 16:10:46 +09001162 * Starting from {@link android.os.Build.VERSION_CODES#O}, if
1163 * {@link #CATEGORY_TYPED_OPENABLE} is passed, then the Uris passed in
1164 * either {@link #EXTRA_STREAM} or via {@link #setClipData(ClipData)} may
1165 * be openable only as asset typed files using
1166 * {@link ContentResolver#openTypedAssetFileDescriptor(Uri, String, Bundle)}.
1167 * <p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001168 * Optional standard extras, which may be interpreted by some recipients as
1169 * appropriate, are: {@link #EXTRA_EMAIL}, {@link #EXTRA_CC},
1170 * {@link #EXTRA_BCC}, {@link #EXTRA_SUBJECT}.
1171 * <p>
1172 * Output: nothing.
1173 */
1174 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1175 public static final String ACTION_SEND = "android.intent.action.SEND";
1176 /**
Wu-cheng Li649f99e2009-06-17 14:29:57 +08001177 * Activity Action: Deliver multiple data to someone else.
1178 * <p>
Dianne Hackbornacb69bb2012-04-13 15:36:06 -07001179 * Like {@link #ACTION_SEND}, except the data is multiple.
Wu-cheng Li649f99e2009-06-17 14:29:57 +08001180 * <p>
1181 * Input: {@link #getType} is the MIME type of the data being sent.
1182 * get*ArrayListExtra can have either a {@link #EXTRA_TEXT} or {@link
Dianne Hackbornacb69bb2012-04-13 15:36:06 -07001183 * #EXTRA_STREAM} field, containing the data to be sent. If using
1184 * {@link #EXTRA_TEXT}, you can also optionally supply {@link #EXTRA_HTML_TEXT}
1185 * for clients to retrieve your text with HTML formatting.
Wu-cheng Li649f99e2009-06-17 14:29:57 +08001186 * <p>
Chih-Chung Chang5962d272009-09-04 14:36:01 +08001187 * Multiple types are supported, and receivers should handle mixed types
1188 * whenever possible. The right way for the receiver to check them is to
1189 * use the content resolver on each URI. The intent sender should try to
1190 * put the most concrete mime type in the intent type, but it can fall
1191 * back to {@literal <type>/*} or {@literal *}/* as needed.
1192 * <p>
1193 * e.g. if you are sending image/jpg and image/jpg, the intent's type can
1194 * be image/jpg, but if you are sending image/jpg and image/png, then the
1195 * intent's type should be image/*.
1196 * <p>
Dianne Hackbornacb69bb2012-04-13 15:36:06 -07001197 * As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN}, the data
1198 * being sent can be supplied through {@link #setClipData(ClipData)}. This
1199 * allows you to use {@link #FLAG_GRANT_READ_URI_PERMISSION} when sharing
1200 * content: URIs and other advanced features of {@link ClipData}. If
1201 * using this approach, you still must supply the same data through the
1202 * {@link #EXTRA_TEXT} or {@link #EXTRA_STREAM} fields described below
1203 * for compatibility with old applications. If you don't set a ClipData,
1204 * it will be copied there for you when calling {@link Context#startActivity(Intent)}.
1205 * <p>
Tomasz Mikolajewskid8a2e192016-12-15 16:10:46 +09001206 * Starting from {@link android.os.Build.VERSION_CODES#O}, if
1207 * {@link #CATEGORY_TYPED_OPENABLE} is passed, then the Uris passed in
1208 * either {@link #EXTRA_STREAM} or via {@link #setClipData(ClipData)} may
1209 * be openable only as asset typed files using
1210 * {@link ContentResolver#openTypedAssetFileDescriptor(Uri, String, Bundle)}.
1211 * <p>
Wu-cheng Li649f99e2009-06-17 14:29:57 +08001212 * Optional standard extras, which may be interpreted by some recipients as
1213 * appropriate, are: {@link #EXTRA_EMAIL}, {@link #EXTRA_CC},
1214 * {@link #EXTRA_BCC}, {@link #EXTRA_SUBJECT}.
1215 * <p>
1216 * Output: nothing.
1217 */
1218 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1219 public static final String ACTION_SEND_MULTIPLE = "android.intent.action.SEND_MULTIPLE";
1220 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001221 * Activity Action: Handle an incoming phone call.
1222 * <p>Input: nothing.
1223 * <p>Output: nothing.
1224 */
1225 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1226 public static final String ACTION_ANSWER = "android.intent.action.ANSWER";
1227 /**
1228 * Activity Action: Insert an empty item into the given container.
1229 * <p>Input: {@link #getData} is URI of the directory (vnd.android.cursor.dir/*)
1230 * in which to place the data.
1231 * <p>Output: URI of the new data that was created.
1232 */
1233 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1234 public static final String ACTION_INSERT = "android.intent.action.INSERT";
1235 /**
Dianne Hackborn23fdaf62010-08-06 12:16:55 -07001236 * Activity Action: Create a new item in the given container, initializing it
1237 * from the current contents of the clipboard.
1238 * <p>Input: {@link #getData} is URI of the directory (vnd.android.cursor.dir/*)
1239 * in which to place the data.
1240 * <p>Output: URI of the new data that was created.
1241 */
1242 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1243 public static final String ACTION_PASTE = "android.intent.action.PASTE";
1244 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001245 * Activity Action: Delete the given data from its container.
1246 * <p>Input: {@link #getData} is URI of data to be deleted.
1247 * <p>Output: nothing.
1248 */
1249 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1250 public static final String ACTION_DELETE = "android.intent.action.DELETE";
1251 /**
1252 * Activity Action: Run the data, whatever that means.
1253 * <p>Input: ? (Note: this is currently specific to the test harness.)
1254 * <p>Output: nothing.
1255 */
1256 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1257 public static final String ACTION_RUN = "android.intent.action.RUN";
1258 /**
1259 * Activity Action: Perform a data synchronization.
1260 * <p>Input: ?
1261 * <p>Output: ?
1262 */
1263 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1264 public static final String ACTION_SYNC = "android.intent.action.SYNC";
1265 /**
1266 * Activity Action: Pick an activity given an intent, returning the class
1267 * selected.
1268 * <p>Input: get*Extra field {@link #EXTRA_INTENT} is an Intent
1269 * used with {@link PackageManager#queryIntentActivities} to determine the
1270 * set of activities from which to pick.
1271 * <p>Output: Class name of the activity that was selected.
1272 */
1273 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1274 public static final String ACTION_PICK_ACTIVITY = "android.intent.action.PICK_ACTIVITY";
1275 /**
1276 * Activity Action: Perform a search.
1277 * <p>Input: {@link android.app.SearchManager#QUERY getStringExtra(SearchManager.QUERY)}
1278 * is the text to search for. If empty, simply
1279 * enter your search results Activity with the search UI activated.
1280 * <p>Output: nothing.
1281 */
1282 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1283 public static final String ACTION_SEARCH = "android.intent.action.SEARCH";
1284 /**
Jim Miller7e4ad352009-03-25 18:16:41 -07001285 * Activity Action: Start the platform-defined tutorial
1286 * <p>Input: {@link android.app.SearchManager#QUERY getStringExtra(SearchManager.QUERY)}
1287 * is the text to search for. If empty, simply
1288 * enter your search results Activity with the search UI activated.
1289 * <p>Output: nothing.
1290 */
1291 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1292 public static final String ACTION_SYSTEM_TUTORIAL = "android.intent.action.SYSTEM_TUTORIAL";
1293 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001294 * Activity Action: Perform a web search.
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08001295 * <p>
1296 * Input: {@link android.app.SearchManager#QUERY
1297 * getStringExtra(SearchManager.QUERY)} is the text to search for. If it is
1298 * a url starts with http or https, the site will be opened. If it is plain
1299 * text, Google search will be applied.
1300 * <p>
1301 * Output: nothing.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001302 */
1303 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1304 public static final String ACTION_WEB_SEARCH = "android.intent.action.WEB_SEARCH";
Dianne Hackbornf9c5e0f2013-01-23 14:39:13 -08001305
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001306 /**
Jim Miller07994402012-05-02 14:22:27 -07001307 * Activity Action: Perform assist action.
1308 * <p>
Adam Skory7140a252013-09-11 12:04:58 +01001309 * Input: {@link #EXTRA_ASSIST_PACKAGE}, {@link #EXTRA_ASSIST_CONTEXT}, can provide
1310 * additional optional contextual information about where the user was when they
Dianne Hackborna3acdb32015-06-08 17:07:40 -07001311 * requested the assist; {@link #EXTRA_REFERRER} may be set with additional referrer
1312 * information.
Jim Miller07994402012-05-02 14:22:27 -07001313 * Output: nothing.
1314 */
1315 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1316 public static final String ACTION_ASSIST = "android.intent.action.ASSIST";
Dianne Hackbornf9c5e0f2013-01-23 14:39:13 -08001317
1318 /**
Bjorn Bringertbc086862013-03-01 12:59:24 +00001319 * Activity Action: Perform voice assist action.
1320 * <p>
Adam Skory7140a252013-09-11 12:04:58 +01001321 * Input: {@link #EXTRA_ASSIST_PACKAGE}, {@link #EXTRA_ASSIST_CONTEXT}, can provide
1322 * additional optional contextual information about where the user was when they
Adam Skorydfc7fd72013-08-05 19:23:41 -07001323 * requested the voice assist.
Bjorn Bringertbc086862013-03-01 12:59:24 +00001324 * Output: nothing.
Adam Skory7140a252013-09-11 12:04:58 +01001325 * @hide
Bjorn Bringertbc086862013-03-01 12:59:24 +00001326 */
Amith Yamasani16452032017-03-03 10:15:57 -08001327 @SystemApi
Bjorn Bringertbc086862013-03-01 12:59:24 +00001328 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1329 public static final String ACTION_VOICE_ASSIST = "android.intent.action.VOICE_ASSIST";
1330
1331 /**
Adam Skory7140a252013-09-11 12:04:58 +01001332 * An optional field on {@link #ACTION_ASSIST} containing the name of the current foreground
1333 * application package at the time the assist was invoked.
Dianne Hackbornf9c5e0f2013-01-23 14:39:13 -08001334 */
1335 public static final String EXTRA_ASSIST_PACKAGE
1336 = "android.intent.extra.ASSIST_PACKAGE";
1337
1338 /**
Dianne Hackborna83ce1d2015-03-11 15:16:13 -07001339 * An optional field on {@link #ACTION_ASSIST} containing the uid of the current foreground
1340 * application package at the time the assist was invoked.
1341 */
1342 public static final String EXTRA_ASSIST_UID
1343 = "android.intent.extra.ASSIST_UID";
1344
1345 /**
Adam Skory7140a252013-09-11 12:04:58 +01001346 * An optional field on {@link #ACTION_ASSIST} and containing additional contextual
1347 * information supplied by the current foreground app at the time of the assist request.
1348 * This is a {@link Bundle} of additional data.
Dianne Hackbornf9c5e0f2013-01-23 14:39:13 -08001349 */
1350 public static final String EXTRA_ASSIST_CONTEXT
1351 = "android.intent.extra.ASSIST_CONTEXT";
1352
Jim Miller07994402012-05-02 14:22:27 -07001353 /**
Michael Wright8ab940a2014-09-01 11:01:27 -07001354 * An optional field on {@link #ACTION_ASSIST} suggesting that the user will likely use a
1355 * keyboard as the primary input device for assistance.
1356 */
1357 public static final String EXTRA_ASSIST_INPUT_HINT_KEYBOARD =
1358 "android.intent.extra.ASSIST_INPUT_HINT_KEYBOARD";
1359
1360 /**
Tim Kilbourn0e5f1102015-06-05 16:18:09 -07001361 * An optional field on {@link #ACTION_ASSIST} containing the InputDevice id
1362 * that was used to invoke the assist.
1363 */
1364 public static final String EXTRA_ASSIST_INPUT_DEVICE_ID =
1365 "android.intent.extra.ASSIST_INPUT_DEVICE_ID";
1366
1367 /**
Trevor Johns682c24e2016-04-12 10:13:47 -07001368 * Activity Action: List all available applications.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001369 * <p>Input: Nothing.
1370 * <p>Output: nothing.
1371 */
1372 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1373 public static final String ACTION_ALL_APPS = "android.intent.action.ALL_APPS";
1374 /**
Trevor Johns682c24e2016-04-12 10:13:47 -07001375 * Activity Action: Show settings for choosing wallpaper.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001376 * <p>Input: Nothing.
1377 * <p>Output: Nothing.
1378 */
1379 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1380 public static final String ACTION_SET_WALLPAPER = "android.intent.action.SET_WALLPAPER";
1381
1382 /**
1383 * Activity Action: Show activity for reporting a bug.
1384 * <p>Input: Nothing.
1385 * <p>Output: Nothing.
1386 */
1387 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1388 public static final String ACTION_BUG_REPORT = "android.intent.action.BUG_REPORT";
1389
1390 /**
1391 * Activity Action: Main entry point for factory tests. Only used when
1392 * the device is booting in factory test node. The implementing package
1393 * must be installed in the system image.
1394 * <p>Input: nothing
1395 * <p>Output: nothing
1396 */
1397 public static final String ACTION_FACTORY_TEST = "android.intent.action.FACTORY_TEST";
1398
1399 /**
1400 * Activity Action: The user pressed the "call" button to go to the dialer
1401 * or other appropriate UI for placing a call.
1402 * <p>Input: Nothing.
1403 * <p>Output: Nothing.
1404 */
1405 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1406 public static final String ACTION_CALL_BUTTON = "android.intent.action.CALL_BUTTON";
1407
1408 /**
1409 * Activity Action: Start Voice Command.
1410 * <p>Input: Nothing.
1411 * <p>Output: Nothing.
1412 */
1413 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1414 public static final String ACTION_VOICE_COMMAND = "android.intent.action.VOICE_COMMAND";
The Android Open Source Projectba87e3e2009-03-13 13:04:22 -07001415
1416 /**
1417 * Activity Action: Start action associated with long pressing on the
1418 * search key.
1419 * <p>Input: Nothing.
1420 * <p>Output: Nothing.
1421 */
1422 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1423 public static final String ACTION_SEARCH_LONG_PRESS = "android.intent.action.SEARCH_LONG_PRESS";
The Android Open Source Project10592532009-03-18 17:39:46 -07001424
Jacek Surazski86b6c532009-05-13 14:38:28 +02001425 /**
1426 * Activity Action: The user pressed the "Report" button in the crash/ANR dialog.
1427 * This intent is delivered to the package which installed the application, usually
Dirk Dougherty4d7bc6552012-01-27 17:56:49 -08001428 * Google Play.
Jacek Surazski86b6c532009-05-13 14:38:28 +02001429 * <p>Input: No data is specified. The bug report is passed in using
1430 * an {@link #EXTRA_BUG_REPORT} field.
1431 * <p>Output: Nothing.
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001432 *
1433 * @see #EXTRA_BUG_REPORT
Jacek Surazski86b6c532009-05-13 14:38:28 +02001434 */
1435 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1436 public static final String ACTION_APP_ERROR = "android.intent.action.APP_ERROR";
Dianne Hackborn3d74bb42009-06-19 10:35:21 -07001437
1438 /**
1439 * Activity Action: Show power usage information to the user.
1440 * <p>Input: Nothing.
1441 * <p>Output: Nothing.
1442 */
1443 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1444 public static final String ACTION_POWER_USAGE_SUMMARY = "android.intent.action.POWER_USAGE_SUMMARY";
Tom Taylord4a47292009-12-21 13:59:18 -08001445
Dianne Hackbornd7cd29d2009-07-01 11:22:45 -07001446 /**
1447 * Activity Action: Setup wizard to launch after a platform update. This
1448 * activity should have a string meta-data field associated with it,
1449 * {@link #METADATA_SETUP_VERSION}, which defines the current version of
1450 * the platform for setup. The activity will be launched only if
1451 * {@link android.provider.Settings.Secure#LAST_SETUP_SHOWN} is not the
1452 * same value.
1453 * <p>Input: Nothing.
1454 * <p>Output: Nothing.
1455 * @hide
1456 */
1457 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1458 public static final String ACTION_UPGRADE_SETUP = "android.intent.action.UPGRADE_SETUP";
Tom Taylord4a47292009-12-21 13:59:18 -08001459
Dianne Hackbornd7cd29d2009-07-01 11:22:45 -07001460 /**
Clara Bayarrieb3c2d32016-04-01 14:37:32 +01001461 * Activity Action: Start the Keyboard Shortcuts Helper screen.
1462 * <p>Input: Nothing.
1463 * <p>Output: Nothing.
1464 * @hide
1465 */
1466 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1467 public static final String ACTION_SHOW_KEYBOARD_SHORTCUTS =
1468 "android.intent.action.SHOW_KEYBOARD_SHORTCUTS";
1469
1470 /**
Andrei Stingaceanu0bf096f2016-04-14 18:11:57 +01001471 * Activity Action: Dismiss the Keyboard Shortcuts Helper screen.
1472 * <p>Input: Nothing.
1473 * <p>Output: Nothing.
1474 * @hide
1475 */
1476 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1477 public static final String ACTION_DISMISS_KEYBOARD_SHORTCUTS =
1478 "android.intent.action.DISMISS_KEYBOARD_SHORTCUTS";
1479
1480 /**
Jeff Sharkey7f868272011-06-05 16:05:02 -07001481 * Activity Action: Show settings for managing network data usage of a
1482 * specific application. Applications should define an activity that offers
1483 * options to control data usage.
1484 */
1485 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1486 public static final String ACTION_MANAGE_NETWORK_USAGE =
1487 "android.intent.action.MANAGE_NETWORK_USAGE";
1488
1489 /**
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001490 * Activity Action: Launch application installer.
1491 * <p>
Todd Kennedy9cc589a2016-08-18 16:23:17 -07001492 * Input: The data must be a content: URI at which the application
Dianne Hackborneba784ff2012-09-19 12:42:37 -07001493 * can be retrieved. As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN_MR1},
1494 * you can also use "package:<package-name>" to install an application for the
1495 * current user that is already installed for another user. You can optionally supply
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001496 * {@link #EXTRA_INSTALLER_PACKAGE_NAME}, {@link #EXTRA_NOT_UNKNOWN_SOURCE},
1497 * {@link #EXTRA_ALLOW_REPLACE}, and {@link #EXTRA_RETURN_RESULT}.
1498 * <p>
1499 * Output: If {@link #EXTRA_RETURN_RESULT}, returns whether the install
1500 * succeeded.
Svet Ganov86877e42015-05-28 08:19:48 -07001501 * <p>
1502 * <strong>Note:</strong>If your app is targeting API level higher than 22 you
1503 * need to hold {@link android.Manifest.permission#REQUEST_INSTALL_PACKAGES}
1504 * in order to launch the application installer.
1505 * </p>
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001506 *
1507 * @see #EXTRA_INSTALLER_PACKAGE_NAME
1508 * @see #EXTRA_NOT_UNKNOWN_SOURCE
1509 * @see #EXTRA_RETURN_RESULT
1510 */
1511 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1512 public static final String ACTION_INSTALL_PACKAGE = "android.intent.action.INSTALL_PACKAGE";
1513
1514 /**
Todd Kennedyb8a279e2015-11-18 09:59:47 -08001515 * Activity Action: Launch ephemeral installer.
1516 * <p>
1517 * Input: The data must be a http: URI that the ephemeral application is registered
1518 * to handle.
1519 * <p class="note">
1520 * This is a protected intent that can only be sent by the system.
1521 * </p>
1522 *
1523 * @hide
1524 */
Todd Kennedyb8a279e2015-11-18 09:59:47 -08001525 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1526 public static final String ACTION_INSTALL_EPHEMERAL_PACKAGE
1527 = "android.intent.action.INSTALL_EPHEMERAL_PACKAGE";
1528
1529 /**
1530 * Service Action: Resolve ephemeral application.
1531 * <p>
1532 * The system will have a persistent connection to this service.
1533 * This is a protected intent that can only be sent by the system.
1534 * </p>
1535 *
1536 * @hide
1537 */
Todd Kennedyb8a279e2015-11-18 09:59:47 -08001538 @SdkConstant(SdkConstantType.SERVICE_ACTION)
1539 public static final String ACTION_RESOLVE_EPHEMERAL_PACKAGE
1540 = "android.intent.action.RESOLVE_EPHEMERAL_PACKAGE";
1541
1542 /**
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001543 * Used as a string extra field with {@link #ACTION_INSTALL_PACKAGE} to install a
1544 * package. Specifies the installer package name; this package will receive the
1545 * {@link #ACTION_APP_ERROR} intent.
1546 */
1547 public static final String EXTRA_INSTALLER_PACKAGE_NAME
1548 = "android.intent.extra.INSTALLER_PACKAGE_NAME";
1549
1550 /**
1551 * Used as a boolean extra field with {@link #ACTION_INSTALL_PACKAGE} to install a
1552 * package. Specifies that the application being installed should not be
1553 * treated as coming from an unknown source, but as coming from the app
1554 * invoking the Intent. For this to work you must start the installer with
1555 * startActivityForResult().
1556 */
1557 public static final String EXTRA_NOT_UNKNOWN_SOURCE
1558 = "android.intent.extra.NOT_UNKNOWN_SOURCE";
1559
1560 /**
rich cannings706e8ba2012-08-20 13:20:14 -07001561 * Used as a URI extra field with {@link #ACTION_INSTALL_PACKAGE} and
1562 * {@link #ACTION_VIEW} to indicate the URI from which the local APK in the Intent
rich cannings368ed012012-06-07 15:37:57 -07001563 * data field originated from.
1564 */
rich cannings706e8ba2012-08-20 13:20:14 -07001565 public static final String EXTRA_ORIGINATING_URI
1566 = "android.intent.extra.ORIGINATING_URI";
rich cannings368ed012012-06-07 15:37:57 -07001567
1568 /**
Dianne Hackborn85d558c2014-11-04 10:31:54 -08001569 * This extra can be used with any Intent used to launch an activity, supplying information
1570 * about who is launching that activity. This field contains a {@link android.net.Uri}
1571 * object, typically an http: or https: URI of the web site that the referral came from;
1572 * it can also use the {@link #URI_ANDROID_APP_SCHEME android-app:} scheme to identify
1573 * a native application that it came from.
1574 *
1575 * <p>To retrieve this value in a client, use {@link android.app.Activity#getReferrer}
1576 * instead of directly retrieving the extra. It is also valid for applications to
1577 * instead supply {@link #EXTRA_REFERRER_NAME} for cases where they can only create
1578 * a string, not a Uri; the field here, if supplied, will always take precedence,
1579 * however.</p>
1580 *
1581 * @see #EXTRA_REFERRER_NAME
rich cannings368ed012012-06-07 15:37:57 -07001582 */
1583 public static final String EXTRA_REFERRER
1584 = "android.intent.extra.REFERRER";
1585
1586 /**
Dianne Hackborn85d558c2014-11-04 10:31:54 -08001587 * Alternate version of {@link #EXTRA_REFERRER} that supplies the URI as a String rather
1588 * than a {@link android.net.Uri} object. Only for use in cases where Uri objects can
1589 * not be created, in particular when Intent extras are supplied through the
1590 * {@link #URI_INTENT_SCHEME intent:} or {@link #URI_ANDROID_APP_SCHEME android-app:}
1591 * schemes.
1592 *
1593 * @see #EXTRA_REFERRER
1594 */
1595 public static final String EXTRA_REFERRER_NAME
1596 = "android.intent.extra.REFERRER_NAME";
1597
1598 /**
Ben Gruver37d83a32012-09-27 13:02:06 -07001599 * Used as an int extra field with {@link #ACTION_INSTALL_PACKAGE} and
Gina Dimino98ad8882016-05-31 17:25:48 -07001600 * {@link #ACTION_VIEW} to indicate the uid of the package that initiated the install
Ben Gruver37d83a32012-09-27 13:02:06 -07001601 * @hide
1602 */
Svet Ganovae0e03a2016-02-25 18:22:10 -08001603 @SystemApi
Ben Gruver37d83a32012-09-27 13:02:06 -07001604 public static final String EXTRA_ORIGINATING_UID
1605 = "android.intent.extra.ORIGINATING_UID";
1606
1607 /**
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001608 * Used as a boolean extra field with {@link #ACTION_INSTALL_PACKAGE} to install a
1609 * package. Tells the installer UI to skip the confirmation with the user
1610 * if the .apk is replacing an existing one.
Dianne Hackborn0e128bb2012-05-01 14:40:15 -07001611 * @deprecated As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN}, Android
1612 * will no longer show an interstitial message about updating existing
1613 * applications so this is no longer needed.
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001614 */
Dianne Hackborn0e128bb2012-05-01 14:40:15 -07001615 @Deprecated
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001616 public static final String EXTRA_ALLOW_REPLACE
1617 = "android.intent.extra.ALLOW_REPLACE";
1618
1619 /**
1620 * Used as a boolean extra field with {@link #ACTION_INSTALL_PACKAGE} or
1621 * {@link #ACTION_UNINSTALL_PACKAGE}. Specifies that the installer UI should
1622 * return to the application the result code of the install/uninstall. The returned result
1623 * code will be {@link android.app.Activity#RESULT_OK} on success or
1624 * {@link android.app.Activity#RESULT_FIRST_USER} on failure.
1625 */
1626 public static final String EXTRA_RETURN_RESULT
1627 = "android.intent.extra.RETURN_RESULT";
1628
1629 /**
1630 * Package manager install result code. @hide because result codes are not
1631 * yet ready to be exposed.
1632 */
1633 public static final String EXTRA_INSTALL_RESULT
1634 = "android.intent.extra.INSTALL_RESULT";
1635
1636 /**
1637 * Activity Action: Launch application uninstaller.
1638 * <p>
1639 * Input: The data must be a package: URI whose scheme specific part is
1640 * the package name of the current installed package to be uninstalled.
1641 * You can optionally supply {@link #EXTRA_RETURN_RESULT}.
1642 * <p>
1643 * Output: If {@link #EXTRA_RETURN_RESULT}, returns whether the install
1644 * succeeded.
1645 */
1646 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1647 public static final String ACTION_UNINSTALL_PACKAGE = "android.intent.action.UNINSTALL_PACKAGE";
1648
1649 /**
msnider3c191b82017-01-23 14:23:16 -08001650 * Activity Action: Launch application uninstaller.
1651 * <p>
1652 * Input: The data must be a package: URI whose scheme specific part is
1653 * the package name of the current installed package to be uninstalled.
1654 * You can optionally supply {@link #EXTRA_RETURN_RESULT}.
1655 * <p>
1656 * Output: Nothing.
1657 * </p>
1658 */
1659 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1660 public static final String ACTION_CLEAR_PACKAGE = "android.intent.action.CLEAR_PACKAGE";
1661
1662 /**
Dianne Hackborn6d235d82012-09-16 18:25:40 -07001663 * Specify whether the package should be uninstalled for all users.
1664 * @hide because these should not be part of normal application flow.
1665 */
1666 public static final String EXTRA_UNINSTALL_ALL_USERS
1667 = "android.intent.extra.UNINSTALL_ALL_USERS";
1668
1669 /**
Dianne Hackbornd7cd29d2009-07-01 11:22:45 -07001670 * A string associated with a {@link #ACTION_UPGRADE_SETUP} activity
1671 * describing the last run version of the platform that was setup.
1672 * @hide
1673 */
1674 public static final String METADATA_SETUP_VERSION = "android.SETUP_VERSION";
1675
Svet Ganov3695b8a2015-03-24 16:30:25 -07001676 /**
1677 * Activity action: Launch UI to manage the permissions of an app.
1678 * <p>
1679 * Input: {@link #EXTRA_PACKAGE_NAME} specifies the package whose permissions
1680 * will be managed by the launched UI.
1681 * </p>
1682 * <p>
1683 * Output: Nothing.
1684 * </p>
1685 *
1686 * @see #EXTRA_PACKAGE_NAME
1687 *
1688 * @hide
1689 */
Svet Ganovae0e03a2016-02-25 18:22:10 -08001690 @SystemApi
Svet Ganov3695b8a2015-03-24 16:30:25 -07001691 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1692 public static final String ACTION_MANAGE_APP_PERMISSIONS =
1693 "android.intent.action.MANAGE_APP_PERMISSIONS";
1694
1695 /**
Svet Ganov321f0152015-05-16 22:51:50 -07001696 * Activity action: Launch UI to manage permissions.
1697 * <p>
1698 * Input: Nothing.
1699 * </p>
1700 * <p>
1701 * Output: Nothing.
1702 * </p>
1703 *
1704 * @hide
1705 */
Svet Ganovae0e03a2016-02-25 18:22:10 -08001706 @SystemApi
Svet Ganov321f0152015-05-16 22:51:50 -07001707 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1708 public static final String ACTION_MANAGE_PERMISSIONS =
1709 "android.intent.action.MANAGE_PERMISSIONS";
1710
1711 /**
Svet Ganov9c165d72015-12-01 19:52:26 -08001712 * Activity action: Launch UI to review permissions for an app.
1713 * The system uses this intent if permission review for apps not
1714 * supporting the new runtime permissions model is enabled. In
1715 * this mode a permission review is required before any of the
1716 * app components can run.
1717 * <p>
1718 * Input: {@link #EXTRA_PACKAGE_NAME} specifies the package whose
1719 * permissions will be reviewed (mandatory).
1720 * </p>
1721 * <p>
1722 * Input: {@link #EXTRA_INTENT} specifies a pending intent to
1723 * be fired after the permission review (optional).
1724 * </p>
1725 * <p>
1726 * Input: {@link #EXTRA_REMOTE_CALLBACK} specifies a callback to
1727 * be invoked after the permission review (optional).
1728 * </p>
1729 * <p>
1730 * Input: {@link #EXTRA_RESULT_NEEDED} specifies whether the intent
1731 * passed via {@link #EXTRA_INTENT} needs a result (optional).
1732 * </p>
1733 * <p>
1734 * Output: Nothing.
1735 * </p>
1736 *
1737 * @see #EXTRA_PACKAGE_NAME
1738 * @see #EXTRA_INTENT
1739 * @see #EXTRA_REMOTE_CALLBACK
1740 * @see #EXTRA_RESULT_NEEDED
1741 *
1742 * @hide
1743 */
Svet Ganovae0e03a2016-02-25 18:22:10 -08001744 @SystemApi
Svet Ganov9c165d72015-12-01 19:52:26 -08001745 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1746 public static final String ACTION_REVIEW_PERMISSIONS =
1747 "android.intent.action.REVIEW_PERMISSIONS";
1748
1749 /**
1750 * Intent extra: A callback for reporting remote result as a bundle.
1751 * <p>
1752 * Type: IRemoteCallback
1753 * </p>
1754 *
1755 * @hide
1756 */
Svet Ganovae0e03a2016-02-25 18:22:10 -08001757 @SystemApi
Svet Ganov9c165d72015-12-01 19:52:26 -08001758 public static final String EXTRA_REMOTE_CALLBACK = "android.intent.extra.REMOTE_CALLBACK";
1759
1760 /**
Svet Ganov3695b8a2015-03-24 16:30:25 -07001761 * Intent extra: An app package name.
1762 * <p>
1763 * Type: String
Svet Ganov0b316702015-05-23 13:25:11 -07001764 * </p>
Svet Ganov3695b8a2015-03-24 16:30:25 -07001765 *
Svet Ganov3695b8a2015-03-24 16:30:25 -07001766 */
Svet Ganov3695b8a2015-03-24 16:30:25 -07001767 public static final String EXTRA_PACKAGE_NAME = "android.intent.extra.PACKAGE_NAME";
1768
1769 /**
Todd Kennedye5195dd2016-10-19 15:29:19 -07001770 * Intent extra: An app split name.
1771 * <p>
1772 * Type: String
1773 * </p>
1774 * @hide
1775 */
1776 @SystemApi
1777 public static final String EXTRA_SPLIT_NAME = "android.intent.extra.SPLIT_NAME";
1778
1779 /**
Svet Ganov9c165d72015-12-01 19:52:26 -08001780 * Intent extra: An extra for specifying whether a result is needed.
1781 * <p>
1782 * Type: boolean
1783 * </p>
1784 *
1785 * @hide
1786 */
Svet Ganovae0e03a2016-02-25 18:22:10 -08001787 @SystemApi
Svet Ganov9c165d72015-12-01 19:52:26 -08001788 public static final String EXTRA_RESULT_NEEDED = "android.intent.extra.RESULT_NEEDED";
1789
1790 /**
Svet Ganov3695b8a2015-03-24 16:30:25 -07001791 * Activity action: Launch UI to manage which apps have a given permission.
1792 * <p>
1793 * Input: {@link #EXTRA_PERMISSION_NAME} specifies the permission access
1794 * to which will be managed by the launched UI.
1795 * </p>
1796 * <p>
1797 * Output: Nothing.
1798 * </p>
1799 *
1800 * @see #EXTRA_PERMISSION_NAME
1801 *
1802 * @hide
1803 */
Svet Ganovae0e03a2016-02-25 18:22:10 -08001804 @SystemApi
Svet Ganov3695b8a2015-03-24 16:30:25 -07001805 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1806 public static final String ACTION_MANAGE_PERMISSION_APPS =
1807 "android.intent.action.MANAGE_PERMISSION_APPS";
1808
1809 /**
1810 * Intent extra: The name of a permission.
1811 * <p>
1812 * Type: String
1813 * </p>
1814 *
1815 * @hide
1816 */
1817 @SystemApi
1818 public static final String EXTRA_PERMISSION_NAME = "android.intent.extra.PERMISSION_NAME";
1819
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001820 // ---------------------------------------------------------------------
1821 // ---------------------------------------------------------------------
1822 // Standard intent broadcast actions (see action variable).
1823
1824 /**
Jeff Brown037c33e2014-04-09 00:31:55 -07001825 * Broadcast Action: Sent when the device goes to sleep and becomes non-interactive.
1826 * <p>
1827 * For historical reasons, the name of this broadcast action refers to the power
1828 * state of the screen but it is actually sent in response to changes in the
1829 * overall interactive state of the device.
1830 * </p><p>
1831 * This broadcast is sent when the device becomes non-interactive which may have
1832 * nothing to do with the screen turning off. To determine the
1833 * actual state of the screen, use {@link android.view.Display#getState}.
1834 * </p><p>
1835 * See {@link android.os.PowerManager#isInteractive} for details.
1836 * </p>
Casey Hodbf6785c2015-03-17 15:59:39 -07001837 * You <em>cannot</em> receive this through components declared in
1838 * manifests, only by explicitly registering for it with
1839 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
1840 * Context.registerReceiver()}.
Tom Taylord4a47292009-12-21 13:59:18 -08001841 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001842 * <p class="note">This is a protected intent that can only be sent
1843 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001844 */
1845 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1846 public static final String ACTION_SCREEN_OFF = "android.intent.action.SCREEN_OFF";
Jeff Brown037c33e2014-04-09 00:31:55 -07001847
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001848 /**
Jeff Brown037c33e2014-04-09 00:31:55 -07001849 * Broadcast Action: Sent when the device wakes up and becomes interactive.
1850 * <p>
1851 * For historical reasons, the name of this broadcast action refers to the power
1852 * state of the screen but it is actually sent in response to changes in the
1853 * overall interactive state of the device.
1854 * </p><p>
1855 * This broadcast is sent when the device becomes interactive which may have
1856 * nothing to do with the screen turning on. To determine the
1857 * actual state of the screen, use {@link android.view.Display#getState}.
1858 * </p><p>
1859 * See {@link android.os.PowerManager#isInteractive} for details.
1860 * </p>
Casey Hodbf6785c2015-03-17 15:59:39 -07001861 * You <em>cannot</em> receive this through components declared in
1862 * manifests, only by explicitly registering for it with
1863 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
1864 * Context.registerReceiver()}.
Tom Taylord4a47292009-12-21 13:59:18 -08001865 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001866 * <p class="note">This is a protected intent that can only be sent
1867 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001868 */
1869 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1870 public static final String ACTION_SCREEN_ON = "android.intent.action.SCREEN_ON";
The Android Open Source Projectb2a3dd82009-03-09 11:52:12 -07001871
1872 /**
Dianne Hackbornbe87e2f2012-09-28 16:31:34 -07001873 * Broadcast Action: Sent after the system stops dreaming.
1874 *
1875 * <p class="note">This is a protected intent that can only be sent by the system.
1876 * It is only sent to registered receivers.</p>
1877 */
1878 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1879 public static final String ACTION_DREAMING_STOPPED = "android.intent.action.DREAMING_STOPPED";
1880
1881 /**
1882 * Broadcast Action: Sent after the system starts dreaming.
1883 *
1884 * <p class="note">This is a protected intent that can only be sent by the system.
1885 * It is only sent to registered receivers.</p>
1886 */
1887 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1888 public static final String ACTION_DREAMING_STARTED = "android.intent.action.DREAMING_STARTED";
1889
1890 /**
The Android Open Source Project10592532009-03-18 17:39:46 -07001891 * 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 -07001892 * keyguard is gone).
Tom Taylord4a47292009-12-21 13:59:18 -08001893 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001894 * <p class="note">This is a protected intent that can only be sent
1895 * by the system.
The Android Open Source Projectb2a3dd82009-03-09 11:52:12 -07001896 */
1897 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Dianne Hackborn1c633fc2009-12-08 19:45:14 -08001898 public static final String ACTION_USER_PRESENT = "android.intent.action.USER_PRESENT";
The Android Open Source Projectb2a3dd82009-03-09 11:52:12 -07001899
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001900 /**
1901 * Broadcast Action: The current time has changed. Sent every
Casey Hodbf6785c2015-03-17 15:59:39 -07001902 * minute. You <em>cannot</em> receive this through components declared
John Spurlock6098c5d2013-06-17 10:32:46 -04001903 * in manifests, only by explicitly registering for it with
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001904 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
1905 * Context.registerReceiver()}.
Tom Taylord4a47292009-12-21 13:59:18 -08001906 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001907 * <p class="note">This is a protected intent that can only be sent
1908 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001909 */
1910 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1911 public static final String ACTION_TIME_TICK = "android.intent.action.TIME_TICK";
1912 /**
1913 * Broadcast Action: The time was set.
1914 */
1915 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1916 public static final String ACTION_TIME_CHANGED = "android.intent.action.TIME_SET";
1917 /**
1918 * Broadcast Action: The date has changed.
1919 */
1920 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1921 public static final String ACTION_DATE_CHANGED = "android.intent.action.DATE_CHANGED";
1922 /**
1923 * Broadcast Action: The timezone has changed. The intent will have the following extra values:</p>
1924 * <ul>
1925 * <li><em>time-zone</em> - The java.util.TimeZone.getID() value identifying the new time zone.</li>
1926 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08001927 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001928 * <p class="note">This is a protected intent that can only be sent
1929 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001930 */
1931 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1932 public static final String ACTION_TIMEZONE_CHANGED = "android.intent.action.TIMEZONE_CHANGED";
1933 /**
Robert Greenwalt03595d02010-11-02 14:08:23 -07001934 * Clear DNS Cache Action: This is broadcast when networks have changed and old
1935 * DNS entries should be tossed.
1936 * @hide
1937 */
1938 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1939 public static final String ACTION_CLEAR_DNS_CACHE = "android.intent.action.CLEAR_DNS_CACHE";
1940 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001941 * Alarm Changed Action: This is broadcast when the AlarmClock
1942 * application's alarm is set or unset. It is used by the
1943 * AlarmClock application and the StatusBar service.
1944 * @hide
1945 */
1946 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1947 public static final String ACTION_ALARM_CHANGED = "android.intent.action.ALARM_CHANGED";
Jeff Sharkeybedbaa92015-12-02 16:42:25 -07001948
1949 /**
Jeff Sharkeycf3f0a12016-03-17 19:57:58 -06001950 * Broadcast Action: This is broadcast once, after the user has finished
1951 * booting, but while still in the "locked" state. It can be used to perform
1952 * application-specific initialization, such as installing alarms. You must
1953 * hold the {@link android.Manifest.permission#RECEIVE_BOOT_COMPLETED}
1954 * permission in order to receive this broadcast.
Jeff Sharkeybedbaa92015-12-02 16:42:25 -07001955 * <p>
Jeff Sharkeycf3f0a12016-03-17 19:57:58 -06001956 * This broadcast is sent immediately at boot by all devices (regardless of
1957 * direct boot support) running {@link android.os.Build.VERSION_CODES#N} or
1958 * higher. Upon receipt of this broadcast, the user is still locked and only
1959 * device-protected storage can be accessed safely. If you want to access
1960 * credential-protected storage, you need to wait for the user to be
1961 * unlocked (typically by entering their lock pattern or PIN for the first
1962 * time), after which the {@link #ACTION_USER_UNLOCKED} and
1963 * {@link #ACTION_BOOT_COMPLETED} broadcasts are sent.
1964 * <p>
1965 * To receive this broadcast, your receiver component must be marked as
1966 * being {@link ComponentInfo#directBootAware}.
Jeff Sharkeybedbaa92015-12-02 16:42:25 -07001967 * <p class="note">
1968 * This is a protected intent that can only be sent by the system.
Jeff Sharkeycf3f0a12016-03-17 19:57:58 -06001969 *
1970 * @see Context#createDeviceProtectedStorageContext()
Jeff Sharkeybedbaa92015-12-02 16:42:25 -07001971 */
1972 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1973 public static final String ACTION_LOCKED_BOOT_COMPLETED = "android.intent.action.LOCKED_BOOT_COMPLETED";
1974
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001975 /**
Jeff Sharkeycf3f0a12016-03-17 19:57:58 -06001976 * Broadcast Action: This is broadcast once, after the user has finished
1977 * booting. It can be used to perform application-specific initialization,
1978 * such as installing alarms. You must hold the
1979 * {@link android.Manifest.permission#RECEIVE_BOOT_COMPLETED} permission in
1980 * order to receive this broadcast.
1981 * <p>
1982 * This broadcast is sent at boot by all devices (both with and without
1983 * direct boot support). Upon receipt of this broadcast, the user is
1984 * unlocked and both device-protected and credential-protected storage can
1985 * accessed safely.
1986 * <p>
1987 * If you need to run while the user is still locked (before they've entered
1988 * their lock pattern or PIN for the first time), you can listen for the
1989 * {@link #ACTION_LOCKED_BOOT_COMPLETED} broadcast.
1990 * <p class="note">
1991 * This is a protected intent that can only be sent by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001992 */
1993 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1994 public static final String ACTION_BOOT_COMPLETED = "android.intent.action.BOOT_COMPLETED";
Jeff Sharkeybedbaa92015-12-02 16:42:25 -07001995
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001996 /**
1997 * Broadcast Action: This is broadcast when a user action should request a
1998 * temporary system dialog to dismiss. Some examples of temporary system
1999 * dialogs are the notification window-shade and the recent tasks dialog.
2000 */
2001 public static final String ACTION_CLOSE_SYSTEM_DIALOGS = "android.intent.action.CLOSE_SYSTEM_DIALOGS";
2002 /**
2003 * Broadcast Action: Trigger the download and eventual installation
2004 * of a package.
2005 * <p>Input: {@link #getData} is the URI of the package file to download.
Tom Taylord4a47292009-12-21 13:59:18 -08002006 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002007 * <p class="note">This is a protected intent that can only be sent
2008 * by the system.
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07002009 *
2010 * @deprecated This constant has never been used.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002011 */
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07002012 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002013 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2014 public static final String ACTION_PACKAGE_INSTALL = "android.intent.action.PACKAGE_INSTALL";
2015 /**
2016 * Broadcast Action: A new application package has been installed on the
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07002017 * device. The data contains the name of the package. Note that the
2018 * newly installed package does <em>not</em> receive this broadcast.
Jeff Sharkeyd0c6ccb2012-09-14 16:26:37 -07002019 * <p>May include the following extras:
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002020 * <ul>
2021 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the new package.
2022 * <li> {@link #EXTRA_REPLACING} is set to true if this is following
2023 * an {@link #ACTION_PACKAGE_REMOVED} broadcast for the same package.
2024 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002025 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002026 * <p class="note">This is a protected intent that can only be sent
2027 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002028 */
2029 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2030 public static final String ACTION_PACKAGE_ADDED = "android.intent.action.PACKAGE_ADDED";
2031 /**
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07002032 * Broadcast Action: A new version of an application package has been
2033 * installed, replacing an existing version that was previously installed.
2034 * The data contains the name of the package.
Jeff Sharkeyd0c6ccb2012-09-14 16:26:37 -07002035 * <p>May include the following extras:
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07002036 * <ul>
2037 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the new package.
2038 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002039 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002040 * <p class="note">This is a protected intent that can only be sent
2041 * by the system.
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07002042 */
2043 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2044 public static final String ACTION_PACKAGE_REPLACED = "android.intent.action.PACKAGE_REPLACED";
2045 /**
Dianne Hackborne7f97212011-02-24 14:40:20 -08002046 * Broadcast Action: A new version of your application has been installed
2047 * over an existing one. This is only sent to the application that was
2048 * replaced. It does not contain any additional data; to receive it, just
2049 * use an intent filter for this action.
2050 *
2051 * <p class="note">This is a protected intent that can only be sent
2052 * by the system.
2053 */
2054 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2055 public static final String ACTION_MY_PACKAGE_REPLACED = "android.intent.action.MY_PACKAGE_REPLACED";
2056 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002057 * Broadcast Action: An existing application package has been removed from
2058 * the device. The data contains the name of the package. The package
Trevor Johns682c24e2016-04-12 10:13:47 -07002059 * that is being removed does <em>not</em> receive this Intent.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002060 * <ul>
2061 * <li> {@link #EXTRA_UID} containing the integer uid previously assigned
2062 * to the package.
2063 * <li> {@link #EXTRA_DATA_REMOVED} is set to true if the entire
2064 * application -- data and code -- is being removed.
2065 * <li> {@link #EXTRA_REPLACING} is set to true if this will be followed
2066 * by an {@link #ACTION_PACKAGE_ADDED} broadcast for the same package.
2067 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002068 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002069 * <p class="note">This is a protected intent that can only be sent
2070 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002071 */
2072 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2073 public static final String ACTION_PACKAGE_REMOVED = "android.intent.action.PACKAGE_REMOVED";
2074 /**
Dianne Hackbornf9abb402011-08-10 15:00:59 -07002075 * Broadcast Action: An existing application package has been completely
2076 * removed from the device. The data contains the name of the package.
2077 * This is like {@link #ACTION_PACKAGE_REMOVED}, but only set when
2078 * {@link #EXTRA_DATA_REMOVED} is true and
2079 * {@link #EXTRA_REPLACING} is false of that broadcast.
2080 *
2081 * <ul>
2082 * <li> {@link #EXTRA_UID} containing the integer uid previously assigned
2083 * to the package.
2084 * </ul>
2085 *
2086 * <p class="note">This is a protected intent that can only be sent
2087 * by the system.
2088 */
2089 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2090 public static final String ACTION_PACKAGE_FULLY_REMOVED
2091 = "android.intent.action.PACKAGE_FULLY_REMOVED";
2092 /**
Trevor Johns682c24e2016-04-12 10:13:47 -07002093 * Broadcast Action: An existing application package has been changed (for
2094 * example, a component has been enabled or disabled). The data contains
2095 * the name of the package.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002096 * <ul>
2097 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
Dianne Hackborn86a72da2009-11-11 20:12:41 -08002098 * <li> {@link #EXTRA_CHANGED_COMPONENT_NAME_LIST} containing the class name
Dianne Hackbornfd7aded2013-01-22 17:10:23 -08002099 * of the changed components (or the package name itself).
Dianne Hackborn86a72da2009-11-11 20:12:41 -08002100 * <li> {@link #EXTRA_DONT_KILL_APP} containing boolean field to override the
2101 * default action of restarting the application.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002102 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002103 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002104 * <p class="note">This is a protected intent that can only be sent
2105 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002106 */
2107 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2108 public static final String ACTION_PACKAGE_CHANGED = "android.intent.action.PACKAGE_CHANGED";
2109 /**
Dianne Hackborn21f1bd12010-02-19 17:02:21 -08002110 * @hide
2111 * Broadcast Action: Ask system services if there is any reason to
2112 * restart the given package. The data contains the name of the
2113 * package.
2114 * <ul>
2115 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
2116 * <li> {@link #EXTRA_PACKAGES} String array of all packages to check.
2117 * </ul>
2118 *
2119 * <p class="note">This is a protected intent that can only be sent
2120 * by the system.
2121 */
Soonil Nagarkar0e8fd092015-02-10 10:37:36 -08002122 @SystemApi
Dianne Hackborn21f1bd12010-02-19 17:02:21 -08002123 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2124 public static final String ACTION_QUERY_PACKAGE_RESTART = "android.intent.action.QUERY_PACKAGE_RESTART";
2125 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002126 * Broadcast Action: The user has restarted a package, and all of its
2127 * processes have been killed. All runtime state
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002128 * associated with it (processes, alarms, notifications, etc) should
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07002129 * be removed. Note that the restarted package does <em>not</em>
2130 * receive this broadcast.
2131 * The data contains the name of the package.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002132 * <ul>
2133 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
2134 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002135 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002136 * <p class="note">This is a protected intent that can only be sent
2137 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002138 */
2139 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2140 public static final String ACTION_PACKAGE_RESTARTED = "android.intent.action.PACKAGE_RESTARTED";
2141 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002142 * Broadcast Action: The user has cleared the data of a package. This should
2143 * be preceded by {@link #ACTION_PACKAGE_RESTARTED}, after which all of
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07002144 * its persistent data is erased and this broadcast sent.
2145 * Note that the cleared package does <em>not</em>
2146 * receive this broadcast. The data contains the name of the package.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002147 * <ul>
2148 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
2149 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002150 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002151 * <p class="note">This is a protected intent that can only be sent
2152 * by the system.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002153 */
2154 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2155 public static final String ACTION_PACKAGE_DATA_CLEARED = "android.intent.action.PACKAGE_DATA_CLEARED";
2156 /**
Andrei Stingaceanu69d5ebc2016-01-14 12:59:03 +00002157 * Broadcast Action: Packages have been suspended.
2158 * <p>Includes the following extras:
2159 * <ul>
2160 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages which have been suspended
2161 * </ul>
2162 *
2163 * <p class="note">This is a protected intent that can only be sent
2164 * by the system. It is only sent to registered receivers.
2165 */
2166 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2167 public static final String ACTION_PACKAGES_SUSPENDED = "android.intent.action.PACKAGES_SUSPENDED";
2168 /**
2169 * Broadcast Action: Packages have been unsuspended.
2170 * <p>Includes the following extras:
2171 * <ul>
2172 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages which have been unsuspended
2173 * </ul>
2174 *
2175 * <p class="note">This is a protected intent that can only be sent
2176 * by the system. It is only sent to registered receivers.
2177 */
2178 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2179 public static final String ACTION_PACKAGES_UNSUSPENDED = "android.intent.action.PACKAGES_UNSUSPENDED";
2180 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002181 * Broadcast Action: A user ID has been removed from the system. The user
2182 * ID number is stored in the extra data under {@link #EXTRA_UID}.
Tom Taylord4a47292009-12-21 13:59:18 -08002183 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002184 * <p class="note">This is a protected intent that can only be sent
2185 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002186 */
2187 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2188 public static final String ACTION_UID_REMOVED = "android.intent.action.UID_REMOVED";
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002189
2190 /**
Trevor Johns682c24e2016-04-12 10:13:47 -07002191 * Broadcast Action: Sent to the installer package of an application when
2192 * that application is first launched (that is the first time it is moved
2193 * out of the stopped state). The data contains the name of the package.
Dianne Hackborne7f97212011-02-24 14:40:20 -08002194 *
2195 * <p class="note">This is a protected intent that can only be sent
2196 * by the system.
2197 */
2198 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2199 public static final String ACTION_PACKAGE_FIRST_LAUNCH = "android.intent.action.PACKAGE_FIRST_LAUNCH";
2200
2201 /**
Kenny Root5ab21572011-07-27 11:11:19 -07002202 * Broadcast Action: Sent to the system package verifier when a package
2203 * needs to be verified. The data contains the package URI.
2204 * <p class="note">
2205 * This is a protected intent that can only be sent by the system.
2206 * </p>
Kenny Root5ab21572011-07-27 11:11:19 -07002207 */
2208 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2209 public static final String ACTION_PACKAGE_NEEDS_VERIFICATION = "android.intent.action.PACKAGE_NEEDS_VERIFICATION";
2210
2211 /**
rich canningsd1b5cfc2012-08-29 14:49:51 -07002212 * Broadcast Action: Sent to the system package verifier when a package is
2213 * verified. The data contains the package URI.
2214 * <p class="note">
2215 * This is a protected intent that can only be sent by the system.
2216 */
2217 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2218 public static final String ACTION_PACKAGE_VERIFIED = "android.intent.action.PACKAGE_VERIFIED";
2219
2220 /**
Trevor Johns682c24e2016-04-12 10:13:47 -07002221 * Broadcast Action: Sent to the system intent filter verifier when an
2222 * intent filter needs to be verified. The data contains the filter data
2223 * hosts to be verified against.
Fabrice Di Meglio1c1b4712014-11-19 17:12:32 -08002224 * <p class="note">
2225 * This is a protected intent that can only be sent by the system.
2226 * </p>
2227 *
2228 * @hide
2229 */
2230 @SystemApi
2231 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2232 public static final String ACTION_INTENT_FILTER_NEEDS_VERIFICATION = "android.intent.action.INTENT_FILTER_NEEDS_VERIFICATION";
2233
2234 /**
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002235 * Broadcast Action: Resources for a set of packages (which were
2236 * previously unavailable) are currently
2237 * available since the media on which they exist is available.
2238 * The extra data {@link #EXTRA_CHANGED_PACKAGE_LIST} contains a
2239 * list of packages whose availability changed.
2240 * The extra data {@link #EXTRA_CHANGED_UID_LIST} contains a
2241 * list of uids of packages whose availability changed.
2242 * Note that the
2243 * packages in this list do <em>not</em> receive this broadcast.
2244 * The specified set of packages are now available on the system.
2245 * <p>Includes the following extras:
2246 * <ul>
2247 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages
2248 * whose resources(were previously unavailable) are currently available.
2249 * {@link #EXTRA_CHANGED_UID_LIST} is the set of uids of the
2250 * packages whose resources(were previously unavailable)
2251 * are currently available.
2252 * </ul>
2253 *
2254 * <p class="note">This is a protected intent that can only be sent
2255 * by the system.
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002256 */
2257 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08002258 public static final String ACTION_EXTERNAL_APPLICATIONS_AVAILABLE =
2259 "android.intent.action.EXTERNAL_APPLICATIONS_AVAILABLE";
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002260
2261 /**
2262 * Broadcast Action: Resources for a set of packages are currently
2263 * unavailable since the media on which they exist is unavailable.
2264 * The extra data {@link #EXTRA_CHANGED_PACKAGE_LIST} contains a
2265 * list of packages whose availability changed.
2266 * The extra data {@link #EXTRA_CHANGED_UID_LIST} contains a
2267 * list of uids of packages whose availability changed.
2268 * The specified set of packages can no longer be
2269 * launched and are practically unavailable on the system.
2270 * <p>Inclues the following extras:
2271 * <ul>
2272 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages
2273 * whose resources are no longer available.
2274 * {@link #EXTRA_CHANGED_UID_LIST} is the set of packages
2275 * whose resources are no longer available.
2276 * </ul>
2277 *
2278 * <p class="note">This is a protected intent that can only be sent
2279 * by the system.
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002280 */
2281 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08002282 public static final String ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE =
Joe Onorato8a051a42010-03-04 15:54:50 -05002283 "android.intent.action.EXTERNAL_APPLICATIONS_UNAVAILABLE";
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002284
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002285 /**
Makoto Onuki10305202016-07-14 18:14:08 -07002286 * Broadcast Action: preferred activities have changed *explicitly*.
2287 *
2288 * <p>Note there are cases where a preferred activity is invalidated *implicitly*, e.g.
2289 * when an app is installed or uninstalled, but in such cases this broadcast will *not*
2290 * be sent.
2291 *
2292 * {@link #EXTRA_USER_HANDLE} contains the user ID in question.
2293 *
2294 * @hide
2295 */
2296 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2297 public static final String ACTION_PREFERRED_ACTIVITY_CHANGED =
2298 "android.intent.action.ACTION_PREFERRED_ACTIVITY_CHANGED";
2299
2300
2301 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002302 * Broadcast Action: The current system wallpaper has changed. See
Scott Main8b2e0002009-09-29 18:17:31 -07002303 * {@link android.app.WallpaperManager} for retrieving the new wallpaper.
Dianne Hackbornc5bf7582012-04-25 19:12:07 -07002304 * This should <em>only</em> be used to determine when the wallpaper
2305 * has changed to show the new wallpaper to the user. You should certainly
2306 * never, in response to this, change the wallpaper or other attributes of
2307 * it such as the suggested size. That would be crazy, right? You'd cause
2308 * all kinds of loops, especially if other apps are doing similar things,
2309 * right? Of course. So please don't do this.
2310 *
2311 * @deprecated Modern applications should use
2312 * {@link android.view.WindowManager.LayoutParams#FLAG_SHOW_WALLPAPER
2313 * WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER} to have the wallpaper
2314 * shown behind their UI, rather than watching for this broadcast and
2315 * rendering the wallpaper on their own.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002316 */
Dianne Hackbornc5bf7582012-04-25 19:12:07 -07002317 @Deprecated @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002318 public static final String ACTION_WALLPAPER_CHANGED = "android.intent.action.WALLPAPER_CHANGED";
2319 /**
2320 * Broadcast Action: The current device {@link android.content.res.Configuration}
2321 * (orientation, locale, etc) has changed. When such a change happens, the
2322 * UIs (view hierarchy) will need to be rebuilt based on this new
2323 * information; for the most part, applications don't need to worry about
2324 * this, because the system will take care of stopping and restarting the
2325 * application to make sure it sees the new changes. Some system code that
2326 * can not be restarted will need to watch for this action and handle it
2327 * appropriately.
Tom Taylord4a47292009-12-21 13:59:18 -08002328 *
Dianne Hackborn362d5b92009-11-11 18:04:39 -08002329 * <p class="note">
Casey Hodbf6785c2015-03-17 15:59:39 -07002330 * You <em>cannot</em> receive this through components declared
Dianne Hackborn362d5b92009-11-11 18:04:39 -08002331 * in manifests, only by explicitly registering for it with
2332 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
2333 * Context.registerReceiver()}.
Tom Taylord4a47292009-12-21 13:59:18 -08002334 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002335 * <p class="note">This is a protected intent that can only be sent
2336 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002337 *
2338 * @see android.content.res.Configuration
2339 */
2340 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2341 public static final String ACTION_CONFIGURATION_CHANGED = "android.intent.action.CONFIGURATION_CHANGED";
2342 /**
Dianne Hackborn362d5b92009-11-11 18:04:39 -08002343 * Broadcast Action: The current device's locale has changed.
Tom Taylord4a47292009-12-21 13:59:18 -08002344 *
Dianne Hackborn362d5b92009-11-11 18:04:39 -08002345 * <p class="note">This is a protected intent that can only be sent
2346 * by the system.
2347 */
2348 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2349 public static final String ACTION_LOCALE_CHANGED = "android.intent.action.LOCALE_CHANGED";
2350 /**
Dianne Hackbornedd93162009-09-19 14:03:05 -07002351 * Broadcast Action: This is a <em>sticky broadcast</em> containing the
2352 * charging state, level, and other information about the battery.
2353 * See {@link android.os.BatteryManager} for documentation on the
2354 * contents of the Intent.
The Android Open Source Project10592532009-03-18 17:39:46 -07002355 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002356 * <p class="note">
Casey Hodbf6785c2015-03-17 15:59:39 -07002357 * You <em>cannot</em> receive this through components declared
Dianne Hackborn854060af2009-07-09 18:14:31 -07002358 * in manifests, only by explicitly registering for it with
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002359 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
Dianne Hackbornedd93162009-09-19 14:03:05 -07002360 * Context.registerReceiver()}. See {@link #ACTION_BATTERY_LOW},
2361 * {@link #ACTION_BATTERY_OKAY}, {@link #ACTION_POWER_CONNECTED},
2362 * and {@link #ACTION_POWER_DISCONNECTED} for distinct battery-related
2363 * broadcasts that are sent and can be received through manifest
2364 * receivers.
Tom Taylord4a47292009-12-21 13:59:18 -08002365 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002366 * <p class="note">This is a protected intent that can only be sent
2367 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002368 */
2369 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2370 public static final String ACTION_BATTERY_CHANGED = "android.intent.action.BATTERY_CHANGED";
2371 /**
2372 * Broadcast Action: Indicates low battery condition on the device.
2373 * This broadcast corresponds to the "Low battery warning" system dialog.
Tom Taylord4a47292009-12-21 13:59:18 -08002374 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002375 * <p class="note">This is a protected intent that can only be sent
2376 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002377 */
2378 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2379 public static final String ACTION_BATTERY_LOW = "android.intent.action.BATTERY_LOW";
2380 /**
Dianne Hackborn1dac2772009-06-26 18:16:48 -07002381 * Broadcast Action: Indicates the battery is now okay after being low.
2382 * This will be sent after {@link #ACTION_BATTERY_LOW} once the battery has
2383 * gone back up to an okay state.
Tom Taylord4a47292009-12-21 13:59:18 -08002384 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002385 * <p class="note">This is a protected intent that can only be sent
2386 * by the system.
Dianne Hackborn1dac2772009-06-26 18:16:48 -07002387 */
2388 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2389 public static final String ACTION_BATTERY_OKAY = "android.intent.action.BATTERY_OKAY";
2390 /**
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002391 * Broadcast Action: External power has been connected to the device.
2392 * This is intended for applications that wish to register specifically to this notification.
2393 * Unlike ACTION_BATTERY_CHANGED, applications will be woken for this and so do not have to
2394 * stay active to receive this notification. This action can be used to implement actions
2395 * that wait until power is available to trigger.
Tom Taylord4a47292009-12-21 13:59:18 -08002396 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002397 * <p class="note">This is a protected intent that can only be sent
2398 * by the system.
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002399 */
2400 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Dianne Hackbornfe240ec2009-08-27 12:51:11 -07002401 public static final String ACTION_POWER_CONNECTED = "android.intent.action.ACTION_POWER_CONNECTED";
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002402 /**
2403 * Broadcast Action: External power has been removed from the device.
2404 * This is intended for applications that wish to register specifically to this notification.
2405 * Unlike ACTION_BATTERY_CHANGED, applications will be woken for this and so do not have to
2406 * stay active to receive this notification. This action can be used to implement actions
Romain Guy4969af72009-06-17 10:53:19 -07002407 * that wait until power is available to trigger.
Tom Taylord4a47292009-12-21 13:59:18 -08002408 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002409 * <p class="note">This is a protected intent that can only be sent
2410 * by the system.
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002411 */
2412 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jean-Baptiste Queru1ef45642008-10-24 11:49:25 -07002413 public static final String ACTION_POWER_DISCONNECTED =
Dianne Hackbornfe240ec2009-08-27 12:51:11 -07002414 "android.intent.action.ACTION_POWER_DISCONNECTED";
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002415 /**
Dianne Hackborn55280a92009-05-07 15:53:46 -07002416 * Broadcast Action: Device is shutting down.
2417 * This is broadcast when the device is being shut down (completely turned
2418 * off, not sleeping). Once the broadcast is complete, the final shutdown
2419 * will proceed and all unsaved data lost. Apps will not normally need
Dianne Hackbornfe240ec2009-08-27 12:51:11 -07002420 * to handle this, since the foreground activity will be paused as well.
Tom Taylord4a47292009-12-21 13:59:18 -08002421 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002422 * <p class="note">This is a protected intent that can only be sent
2423 * by the system.
Dianne Hackborn57a7f592013-07-22 18:21:32 -07002424 * <p>May include the following extras:
2425 * <ul>
2426 * <li> {@link #EXTRA_SHUTDOWN_USERSPACE_ONLY} a boolean that is set to true if this
2427 * shutdown is only for userspace processes. If not set, assumed to be false.
2428 * </ul>
Dianne Hackborn55280a92009-05-07 15:53:46 -07002429 */
2430 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Romain Guy4969af72009-06-17 10:53:19 -07002431 public static final String ACTION_SHUTDOWN = "android.intent.action.ACTION_SHUTDOWN";
Dianne Hackborn55280a92009-05-07 15:53:46 -07002432 /**
Mike Lockwoodbad80e02009-07-30 01:21:08 -07002433 * Activity Action: Start this activity to request system shutdown.
2434 * The optional boolean extra field {@link #EXTRA_KEY_CONFIRM} can be set to true
Yusuke Sato705ffd12015-07-21 15:52:11 -07002435 * to request confirmation from the user before shutting down. The optional boolean
2436 * extra field {@link #EXTRA_USER_REQUESTED_SHUTDOWN} can be set to true to
2437 * indicate that the shutdown is requested by the user.
Mike Lockwoodbad80e02009-07-30 01:21:08 -07002438 *
2439 * <p class="note">This is a protected intent that can only be sent
2440 * by the system.
2441 *
2442 * {@hide}
2443 */
2444 public static final String ACTION_REQUEST_SHUTDOWN = "android.intent.action.ACTION_REQUEST_SHUTDOWN";
2445 /**
Dianne Hackbornedd93162009-09-19 14:03:05 -07002446 * Broadcast Action: A sticky broadcast that indicates low memory
2447 * condition on the device
Tom Taylord4a47292009-12-21 13:59:18 -08002448 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002449 * <p class="note">This is a protected intent that can only be sent
2450 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002451 */
2452 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2453 public static final String ACTION_DEVICE_STORAGE_LOW = "android.intent.action.DEVICE_STORAGE_LOW";
2454 /**
2455 * Broadcast Action: Indicates low memory condition on the device no longer exists
Tom Taylord4a47292009-12-21 13:59:18 -08002456 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002457 * <p class="note">This is a protected intent that can only be sent
2458 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002459 */
2460 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2461 public static final String ACTION_DEVICE_STORAGE_OK = "android.intent.action.DEVICE_STORAGE_OK";
2462 /**
Jake Hambybb371632010-08-23 18:16:48 -07002463 * Broadcast Action: A sticky broadcast that indicates a memory full
2464 * condition on the device. This is intended for activities that want
2465 * to be able to fill the data partition completely, leaving only
2466 * enough free space to prevent system-wide SQLite failures.
2467 *
2468 * <p class="note">This is a protected intent that can only be sent
2469 * by the system.
2470 *
2471 * {@hide}
2472 */
2473 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2474 public static final String ACTION_DEVICE_STORAGE_FULL = "android.intent.action.DEVICE_STORAGE_FULL";
2475 /**
2476 * Broadcast Action: Indicates memory full condition on the device
2477 * no longer exists.
2478 *
2479 * <p class="note">This is a protected intent that can only be sent
2480 * by the system.
2481 *
2482 * {@hide}
2483 */
2484 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2485 public static final String ACTION_DEVICE_STORAGE_NOT_FULL = "android.intent.action.DEVICE_STORAGE_NOT_FULL";
2486 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002487 * Broadcast Action: Indicates low memory condition notification acknowledged by user
2488 * and package management should be started.
2489 * This is triggered by the user from the ACTION_DEVICE_STORAGE_LOW
2490 * notification.
2491 */
2492 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2493 public static final String ACTION_MANAGE_PACKAGE_STORAGE = "android.intent.action.MANAGE_PACKAGE_STORAGE";
2494 /**
2495 * Broadcast Action: The device has entered USB Mass Storage mode.
2496 * This is used mainly for the USB Settings panel.
2497 * Apps should listen for ACTION_MEDIA_MOUNTED and ACTION_MEDIA_UNMOUNTED broadcasts to be notified
2498 * when the SD card file system is mounted or unmounted
Mike Lockwood7e4db372011-06-07 11:23:44 -07002499 * @deprecated replaced by android.os.storage.StorageEventListener
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002500 */
Mike Lockwoodda85e522011-06-07 09:08:34 -07002501 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002502 public static final String ACTION_UMS_CONNECTED = "android.intent.action.UMS_CONNECTED";
2503
2504 /**
2505 * Broadcast Action: The device has exited USB Mass Storage mode.
2506 * This is used mainly for the USB Settings panel.
2507 * Apps should listen for ACTION_MEDIA_MOUNTED and ACTION_MEDIA_UNMOUNTED broadcasts to be notified
2508 * when the SD card file system is mounted or unmounted
Mike Lockwood7e4db372011-06-07 11:23:44 -07002509 * @deprecated replaced by android.os.storage.StorageEventListener
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002510 */
Mike Lockwoodda85e522011-06-07 09:08:34 -07002511 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002512 public static final String ACTION_UMS_DISCONNECTED = "android.intent.action.UMS_DISCONNECTED";
2513
2514 /**
2515 * Broadcast Action: External media has been removed.
2516 * The path to the mount point for the removed media is contained in the Intent.mData field.
2517 */
2518 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2519 public static final String ACTION_MEDIA_REMOVED = "android.intent.action.MEDIA_REMOVED";
2520
2521 /**
2522 * Broadcast Action: External media is present, but not mounted at its mount point.
suyi Yuanbe7af832013-01-04 21:21:59 +08002523 * 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 -07002524 */
2525 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2526 public static final String ACTION_MEDIA_UNMOUNTED = "android.intent.action.MEDIA_UNMOUNTED";
2527
2528 /**
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08002529 * Broadcast Action: External media is present, and being disk-checked
2530 * 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 -08002531 */
2532 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2533 public static final String ACTION_MEDIA_CHECKING = "android.intent.action.MEDIA_CHECKING";
2534
2535 /**
2536 * Broadcast Action: External media is present, but is using an incompatible fs (or is blank)
2537 * 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 -08002538 */
2539 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2540 public static final String ACTION_MEDIA_NOFS = "android.intent.action.MEDIA_NOFS";
2541
2542 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002543 * Broadcast Action: External media is present and mounted at its mount point.
suyi Yuanbe7af832013-01-04 21:21:59 +08002544 * 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 -07002545 * The Intent contains an extra with name "read-only" and Boolean value to indicate if the
2546 * media was mounted read only.
2547 */
2548 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2549 public static final String ACTION_MEDIA_MOUNTED = "android.intent.action.MEDIA_MOUNTED";
2550
2551 /**
2552 * Broadcast Action: External media is unmounted because it is being shared via USB mass storage.
Mike Lockwoodbf2dd442010-03-03 06:16:52 -05002553 * 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 -07002554 */
2555 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2556 public static final String ACTION_MEDIA_SHARED = "android.intent.action.MEDIA_SHARED";
2557
2558 /**
Mike Lockwoodbf2dd442010-03-03 06:16:52 -05002559 * Broadcast Action: External media is no longer being shared via USB mass storage.
2560 * The path to the mount point for the previously shared media is contained in the Intent.mData field.
2561 *
2562 * @hide
2563 */
2564 public static final String ACTION_MEDIA_UNSHARED = "android.intent.action.MEDIA_UNSHARED";
2565
2566 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002567 * Broadcast Action: External media was removed from SD card slot, but mount point was not unmounted.
2568 * The path to the mount point for the removed media is contained in the Intent.mData field.
2569 */
2570 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2571 public static final String ACTION_MEDIA_BAD_REMOVAL = "android.intent.action.MEDIA_BAD_REMOVAL";
2572
2573 /**
2574 * Broadcast Action: External media is present but cannot be mounted.
suyi Yuanbe7af832013-01-04 21:21:59 +08002575 * 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 -07002576 */
2577 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2578 public static final String ACTION_MEDIA_UNMOUNTABLE = "android.intent.action.MEDIA_UNMOUNTABLE";
2579
2580 /**
2581 * Broadcast Action: User has expressed the desire to remove the external storage media.
2582 * Applications should close all files they have open within the mount point when they receive this intent.
2583 * The path to the mount point for the media to be ejected is contained in the Intent.mData field.
2584 */
2585 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2586 public static final String ACTION_MEDIA_EJECT = "android.intent.action.MEDIA_EJECT";
2587
2588 /**
2589 * Broadcast Action: The media scanner has started scanning a directory.
2590 * The path to the directory being scanned is contained in the Intent.mData field.
2591 */
2592 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2593 public static final String ACTION_MEDIA_SCANNER_STARTED = "android.intent.action.MEDIA_SCANNER_STARTED";
2594
2595 /**
2596 * Broadcast Action: The media scanner has finished scanning a directory.
2597 * The path to the scanned directory is contained in the Intent.mData field.
2598 */
2599 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2600 public static final String ACTION_MEDIA_SCANNER_FINISHED = "android.intent.action.MEDIA_SCANNER_FINISHED";
2601
2602 /**
2603 * Broadcast Action: Request the media scanner to scan a file and add it to the media database.
2604 * The path to the file is contained in the Intent.mData field.
2605 */
2606 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2607 public static final String ACTION_MEDIA_SCANNER_SCAN_FILE = "android.intent.action.MEDIA_SCANNER_SCAN_FILE";
2608
2609 /**
2610 * Broadcast Action: The "Media Button" was pressed. Includes a single
2611 * extra field, {@link #EXTRA_KEY_EVENT}, containing the key event that
2612 * caused the broadcast.
2613 */
2614 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2615 public static final String ACTION_MEDIA_BUTTON = "android.intent.action.MEDIA_BUTTON";
2616
2617 /**
2618 * Broadcast Action: The "Camera Button" was pressed. Includes a single
2619 * extra field, {@link #EXTRA_KEY_EVENT}, containing the key event that
2620 * caused the broadcast.
2621 */
2622 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2623 public static final String ACTION_CAMERA_BUTTON = "android.intent.action.CAMERA_BUTTON";
2624
2625 // *** NOTE: @todo(*) The following really should go into a more domain-specific
2626 // location; they are not general-purpose actions.
2627
2628 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09002629 * Broadcast Action: A GTalk connection has been established.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002630 */
2631 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2632 public static final String ACTION_GTALK_SERVICE_CONNECTED =
2633 "android.intent.action.GTALK_CONNECTED";
2634
2635 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09002636 * Broadcast Action: A GTalk connection has been disconnected.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002637 */
2638 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2639 public static final String ACTION_GTALK_SERVICE_DISCONNECTED =
2640 "android.intent.action.GTALK_DISCONNECTED";
The Android Open Source Project10592532009-03-18 17:39:46 -07002641
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08002642 /**
2643 * Broadcast Action: An input method has been changed.
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08002644 */
2645 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2646 public static final String ACTION_INPUT_METHOD_CHANGED =
2647 "android.intent.action.INPUT_METHOD_CHANGED";
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002648
2649 /**
2650 * <p>Broadcast Action: The user has switched the phone into or out of Airplane Mode. One or
2651 * more radios have been turned off or on. The intent will have the following extra value:</p>
2652 * <ul>
2653 * <li><em>state</em> - A boolean value indicating whether Airplane Mode is on. If true,
2654 * then cell radio and possibly other radios such as bluetooth or WiFi may have also been
2655 * turned off</li>
2656 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002657 *
Peng Xua35b5532016-01-20 00:05:45 -08002658 * <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 -07002659 */
2660 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2661 public static final String ACTION_AIRPLANE_MODE_CHANGED = "android.intent.action.AIRPLANE_MODE";
2662
2663 /**
2664 * Broadcast Action: Some content providers have parts of their namespace
2665 * where they publish new events or items that the user may be especially
2666 * interested in. For these things, they may broadcast this action when the
2667 * set of interesting items change.
2668 *
2669 * For example, GmailProvider sends this notification when the set of unread
2670 * mail in the inbox changes.
2671 *
2672 * <p>The data of the intent identifies which part of which provider
2673 * changed. When queried through the content resolver, the data URI will
2674 * return the data set in question.
2675 *
2676 * <p>The intent will have the following extra values:
2677 * <ul>
2678 * <li><em>count</em> - The number of items in the data set. This is the
2679 * same as the number of items in the cursor returned by querying the
2680 * data URI. </li>
2681 * </ul>
2682 *
2683 * This intent will be sent at boot (if the count is non-zero) and when the
2684 * data set changes. It is possible for the data set to change without the
2685 * count changing (for example, if a new unread message arrives in the same
2686 * sync operation in which a message is archived). The phone should still
2687 * ring/vibrate/etc as normal in this case.
2688 */
2689 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2690 public static final String ACTION_PROVIDER_CHANGED =
2691 "android.intent.action.PROVIDER_CHANGED";
2692
2693 /**
2694 * Broadcast Action: Wired Headset plugged in or unplugged.
2695 *
Jean-Michel Trivic5258432014-08-27 15:46:54 -07002696 * Same as {@link android.media.AudioManager#ACTION_HEADSET_PLUG}, to be consulted for value
2697 * and documentation.
2698 * <p>If the minimum SDK version of your application is
Dianne Hackborn955d8d62014-10-07 20:17:19 -07002699 * {@link android.os.Build.VERSION_CODES#LOLLIPOP}, it is recommended to refer
Jean-Michel Trivic5258432014-08-27 15:46:54 -07002700 * to the <code>AudioManager</code> constant in your receiver registration code instead.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002701 */
2702 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jean-Michel Trivic5258432014-08-27 15:46:54 -07002703 public static final String ACTION_HEADSET_PLUG = android.media.AudioManager.ACTION_HEADSET_PLUG;
Eric Laurent59f48272012-04-05 19:42:21 -07002704
2705 /**
Joe Onorato9cdffa12011-04-06 18:27:27 -07002706 * <p>Broadcast Action: The user has switched on advanced settings in the settings app:</p>
2707 * <ul>
2708 * <li><em>state</em> - A boolean value indicating whether the settings is on or off.</li>
2709 * </ul>
2710 *
2711 * <p class="note">This is a protected intent that can only be sent
2712 * by the system.
2713 *
2714 * @hide
2715 */
2716 //@SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2717 public static final String ACTION_ADVANCED_SETTINGS_CHANGED
2718 = "android.intent.action.ADVANCED_SETTINGS";
2719
2720 /**
Robin Lee66e5d962014-04-09 16:44:21 +01002721 * Broadcast Action: Sent after application restrictions are changed.
2722 *
2723 * <p class="note">This is a protected intent that can only be sent
2724 * by the system.</p>
2725 */
2726 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2727 public static final String ACTION_APPLICATION_RESTRICTIONS_CHANGED =
2728 "android.intent.action.APPLICATION_RESTRICTIONS_CHANGED";
2729
2730 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002731 * Broadcast Action: An outgoing call is about to be placed.
2732 *
Dirk Dougherty367ce902013-05-28 17:37:12 -07002733 * <p>The Intent will have the following extra value:</p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002734 * <ul>
The Android Open Source Project10592532009-03-18 17:39:46 -07002735 * <li><em>{@link android.content.Intent#EXTRA_PHONE_NUMBER}</em> -
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002736 * the phone number originally intended to be dialed.</li>
2737 * </ul>
2738 * <p>Once the broadcast is finished, the resultData is used as the actual
2739 * number to call. If <code>null</code>, no call will be placed.</p>
The Android Open Source Project10592532009-03-18 17:39:46 -07002740 * <p>It is perfectly acceptable for multiple receivers to process the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002741 * outgoing call in turn: for example, a parental control application
2742 * might verify that the user is authorized to place the call at that
2743 * time, then a number-rewriting application might add an area code if
2744 * one was not specified.</p>
2745 * <p>For consistency, any receiver whose purpose is to prohibit phone
2746 * calls should have a priority of 0, to ensure it will see the final
2747 * phone number to be dialed.
The Android Open Source Project10592532009-03-18 17:39:46 -07002748 * Any receiver whose purpose is to rewrite phone numbers to be called
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002749 * should have a positive priority.
2750 * Negative priorities are reserved for the system for this broadcast;
2751 * using them may cause problems.</p>
Dirk Dougherty932fbcc2013-05-29 15:19:14 -07002752 * <p>Any BroadcastReceiver receiving this Intent <em>must not</em>
2753 * abort the broadcast.</p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002754 * <p>Emergency calls cannot be intercepted using this mechanism, and
2755 * other calls cannot be modified to call emergency numbers using this
2756 * mechanism.
Santos Cordonba701362013-05-17 14:48:54 -07002757 * <p>Some apps (such as VoIP apps) may want to redirect the outgoing
2758 * call to use their own service instead. Those apps should first prevent
2759 * the call from being placed by setting resultData to <code>null</code>
2760 * and then start their own app to make the call.
The Android Open Source Project10592532009-03-18 17:39:46 -07002761 * <p>You must hold the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002762 * {@link android.Manifest.permission#PROCESS_OUTGOING_CALLS}
2763 * permission to receive this Intent.</p>
Tom Taylord4a47292009-12-21 13:59:18 -08002764 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002765 * <p class="note">This is a protected intent that can only be sent
2766 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002767 */
2768 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2769 public static final String ACTION_NEW_OUTGOING_CALL =
2770 "android.intent.action.NEW_OUTGOING_CALL";
2771
2772 /**
2773 * Broadcast Action: Have the device reboot. This is only for use by
2774 * system code.
Tom Taylord4a47292009-12-21 13:59:18 -08002775 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002776 * <p class="note">This is a protected intent that can only be sent
2777 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002778 */
2779 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2780 public static final String ACTION_REBOOT =
2781 "android.intent.action.REBOOT";
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002782
Wei Huang97ecc9c2009-05-11 17:44:20 -07002783 /**
Dianne Hackborn7299c412010-03-04 18:41:49 -08002784 * Broadcast Action: A sticky broadcast for changes in the physical
2785 * docking state of the device.
Tobias Haamel154f7a12010-02-17 11:56:39 -08002786 *
2787 * <p>The intent will have the following extra values:
2788 * <ul>
2789 * <li><em>{@link #EXTRA_DOCK_STATE}</em> - the current dock
Dianne Hackborn7299c412010-03-04 18:41:49 -08002790 * state, indicating which dock the device is physically in.</li>
Tobias Haamel154f7a12010-02-17 11:56:39 -08002791 * </ul>
Dianne Hackborn7299c412010-03-04 18:41:49 -08002792 * <p>This is intended for monitoring the current physical dock state.
2793 * See {@link android.app.UiModeManager} for the normal API dealing with
2794 * dock mode changes.
Dianne Hackbornedd93162009-09-19 14:03:05 -07002795 */
2796 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2797 public static final String ACTION_DOCK_EVENT =
2798 "android.intent.action.DOCK_EVENT";
2799
2800 /**
Svetoslavb3038ec2013-02-13 14:39:30 -08002801 * Broadcast Action: A broadcast when idle maintenance can be started.
2802 * This means that the user is not interacting with the device and is
2803 * not expected to do so soon. Typical use of the idle maintenance is
2804 * to perform somehow expensive tasks that can be postponed at a moment
2805 * when they will not degrade user experience.
2806 * <p>
2807 * <p class="note">In order to keep the device responsive in case of an
2808 * unexpected user interaction, implementations of a maintenance task
2809 * should be interruptible. In such a scenario a broadcast with action
2810 * {@link #ACTION_IDLE_MAINTENANCE_END} will be sent. In other words, you
2811 * should not do the maintenance work in
2812 * {@link BroadcastReceiver#onReceive(Context, Intent)}, rather start a
2813 * maintenance service by {@link Context#startService(Intent)}. Also
2814 * you should hold a wake lock while your maintenance service is running
2815 * to prevent the device going to sleep.
2816 * </p>
2817 * <p>
2818 * <p class="note">This is a protected intent that can only be sent by
2819 * the system.
2820 * </p>
2821 *
2822 * @see #ACTION_IDLE_MAINTENANCE_END
Svetoslav6a08a122013-05-03 11:24:26 -07002823 *
2824 * @hide
Svetoslavb3038ec2013-02-13 14:39:30 -08002825 */
2826 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2827 public static final String ACTION_IDLE_MAINTENANCE_START =
2828 "android.intent.action.ACTION_IDLE_MAINTENANCE_START";
2829
2830 /**
2831 * Broadcast Action: A broadcast when idle maintenance should be stopped.
2832 * This means that the user was not interacting with the device as a result
2833 * of which a broadcast with action {@link #ACTION_IDLE_MAINTENANCE_START}
2834 * was sent and now the user started interacting with the device. Typical
2835 * use of the idle maintenance is to perform somehow expensive tasks that
2836 * can be postponed at a moment when they will not degrade user experience.
2837 * <p>
2838 * <p class="note">In order to keep the device responsive in case of an
2839 * unexpected user interaction, implementations of a maintenance task
2840 * should be interruptible. Hence, on receiving a broadcast with this
2841 * action, the maintenance task should be interrupted as soon as possible.
2842 * In other words, you should not do the maintenance work in
2843 * {@link BroadcastReceiver#onReceive(Context, Intent)}, rather stop the
2844 * maintenance service that was started on receiving of
2845 * {@link #ACTION_IDLE_MAINTENANCE_START}.Also you should release the wake
2846 * lock you acquired when your maintenance service started.
2847 * </p>
2848 * <p class="note">This is a protected intent that can only be sent
2849 * by the system.
2850 *
2851 * @see #ACTION_IDLE_MAINTENANCE_START
Svetoslav6a08a122013-05-03 11:24:26 -07002852 *
2853 * @hide
Svetoslavb3038ec2013-02-13 14:39:30 -08002854 */
2855 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2856 public static final String ACTION_IDLE_MAINTENANCE_END =
2857 "android.intent.action.ACTION_IDLE_MAINTENANCE_END";
2858
2859 /**
Wei Huang97ecc9c2009-05-11 17:44:20 -07002860 * Broadcast Action: a remote intent is to be broadcasted.
2861 *
2862 * A remote intent is used for remote RPC between devices. The remote intent
2863 * is serialized and sent from one device to another device. The receiving
2864 * device parses the remote intent and broadcasts it. Note that anyone can
2865 * broadcast a remote intent. However, if the intent receiver of the remote intent
2866 * does not trust intent broadcasts from arbitrary intent senders, it should require
2867 * the sender to hold certain permissions so only trusted sender's broadcast will be
2868 * let through.
Dianne Hackbornedd93162009-09-19 14:03:05 -07002869 * @hide
Wei Huang97ecc9c2009-05-11 17:44:20 -07002870 */
2871 public static final String ACTION_REMOTE_INTENT =
Costin Manolache8d83f9e2010-05-12 16:04:10 -07002872 "com.google.android.c2dm.intent.RECEIVE";
Wei Huang97ecc9c2009-05-11 17:44:20 -07002873
Dianne Hackborn9acc0302009-08-25 00:27:12 -07002874 /**
Jeff Sharkeybd91e2f2016-03-22 15:32:31 -06002875 * Broadcast Action: This is broadcast once when the user is booting after a
2876 * system update. It can be used to perform cleanup or upgrades after a
2877 * system update.
2878 * <p>
2879 * This broadcast is sent after the {@link #ACTION_LOCKED_BOOT_COMPLETED}
2880 * broadcast but before the {@link #ACTION_BOOT_COMPLETED} broadcast. It's
2881 * only sent when the {@link Build#FINGERPRINT} has changed, and it's only
2882 * sent to receivers in the system image.
Dianne Hackborn9acc0302009-08-25 00:27:12 -07002883 *
Dianne Hackborn9acc0302009-08-25 00:27:12 -07002884 * @hide
2885 */
Amith Yamasanicbabb8d2017-02-17 16:50:05 -08002886 @SystemApi
Dianne Hackborn9acc0302009-08-25 00:27:12 -07002887 public static final String ACTION_PRE_BOOT_COMPLETED =
2888 "android.intent.action.PRE_BOOT_COMPLETED";
2889
Amith Yamasani13593602012-03-22 16:16:17 -07002890 /**
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08002891 * Broadcast to a specific application to query any supported restrictions to impose
Amith Yamasani7e99bc02013-04-16 18:24:51 -07002892 * on restricted users. The broadcast intent contains an extra
2893 * {@link #EXTRA_RESTRICTIONS_BUNDLE} with the currently persisted
2894 * restrictions as a Bundle of key/value pairs. The value types can be Boolean, String or
2895 * String[] depending on the restriction type.<p/>
2896 * The response should contain an extra {@link #EXTRA_RESTRICTIONS_LIST},
Amith Yamasani86118ba2013-03-28 14:33:16 -07002897 * which is of type <code>ArrayList&lt;RestrictionEntry&gt;</code>. It can also
2898 * contain an extra {@link #EXTRA_RESTRICTIONS_INTENT}, which is of type <code>Intent</code>.
2899 * The activity specified by that intent will be launched for a result which must contain
Amith Yamasani3b458ad2013-04-18 18:40:07 -07002900 * one of the extras {@link #EXTRA_RESTRICTIONS_LIST} or {@link #EXTRA_RESTRICTIONS_BUNDLE}.
2901 * The keys and values of the returned restrictions will be persisted.
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08002902 * @see RestrictionEntry
2903 */
2904 public static final String ACTION_GET_RESTRICTION_ENTRIES =
2905 "android.intent.action.GET_RESTRICTION_ENTRIES";
2906
2907 /**
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002908 * Sent the first time a user is starting, to allow system apps to
2909 * perform one time initialization. (This will not be seen by third
2910 * party applications because a newly initialized user does not have any
2911 * third party applications installed for it.) This is sent early in
2912 * starting the user, around the time the home app is started, before
Dianne Hackborn36d337a2012-10-08 14:33:47 -07002913 * {@link #ACTION_BOOT_COMPLETED} is sent. This is sent as a foreground
2914 * broadcast, since it is part of a visible user interaction; be as quick
2915 * as possible when handling it.
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002916 */
2917 public static final String ACTION_USER_INITIALIZE =
2918 "android.intent.action.USER_INITIALIZE";
2919
2920 /**
2921 * Sent when a user switch is happening, causing the process's user to be
2922 * brought to the foreground. This is only sent to receivers registered
2923 * through {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
2924 * Context.registerReceiver}. It is sent to the user that is going to the
Dianne Hackborn36d337a2012-10-08 14:33:47 -07002925 * foreground. This is sent as a foreground
2926 * broadcast, since it is part of a visible user interaction; be as quick
2927 * as possible when handling it.
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002928 */
2929 public static final String ACTION_USER_FOREGROUND =
2930 "android.intent.action.USER_FOREGROUND";
2931
2932 /**
2933 * Sent when a user switch is happening, causing the process's user to be
2934 * sent to the background. This is only sent to receivers registered
2935 * through {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
2936 * Context.registerReceiver}. It is sent to the user that is going to the
Dianne Hackborn36d337a2012-10-08 14:33:47 -07002937 * background. This is sent as a foreground
2938 * broadcast, since it is part of a visible user interaction; be as quick
2939 * as possible when handling it.
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002940 */
2941 public static final String ACTION_USER_BACKGROUND =
2942 "android.intent.action.USER_BACKGROUND";
2943
2944 /**
Dianne Hackborn36d337a2012-10-08 14:33:47 -07002945 * Broadcast sent to the system when a user is added. Carries an extra
2946 * EXTRA_USER_HANDLE that has the userHandle of the new user. It is sent to
2947 * all running users. You must hold
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002948 * {@link android.Manifest.permission#MANAGE_USERS} to receive this broadcast.
Amith Yamasani13593602012-03-22 16:16:17 -07002949 * @hide
2950 */
2951 public static final String ACTION_USER_ADDED =
2952 "android.intent.action.USER_ADDED";
2953
2954 /**
Dianne Hackborn36d337a2012-10-08 14:33:47 -07002955 * Broadcast sent by the system when a user is started. Carries an extra
2956 * EXTRA_USER_HANDLE that has the userHandle of the user. This is only sent to
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002957 * registered receivers, not manifest receivers. It is sent to the user
Dianne Hackborn36d337a2012-10-08 14:33:47 -07002958 * that has been started. This is sent as a foreground
2959 * broadcast, since it is part of a visible user interaction; be as quick
2960 * as possible when handling it.
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002961 * @hide
2962 */
2963 public static final String ACTION_USER_STARTED =
2964 "android.intent.action.USER_STARTED";
2965
2966 /**
Dianne Hackborn36d337a2012-10-08 14:33:47 -07002967 * Broadcast sent when a user is in the process of starting. Carries an extra
2968 * EXTRA_USER_HANDLE that has the userHandle of the user. This is only
2969 * sent to registered receivers, not manifest receivers. It is sent to all
2970 * users (including the one that is being started). You must hold
2971 * {@link android.Manifest.permission#INTERACT_ACROSS_USERS} to receive
2972 * this broadcast. This is sent as a background broadcast, since
2973 * its result is not part of the primary UX flow; to safely keep track of
2974 * started/stopped state of a user you can use this in conjunction with
2975 * {@link #ACTION_USER_STOPPING}. It is <b>not</b> generally safe to use with
2976 * other user state broadcasts since those are foreground broadcasts so can
2977 * execute in a different order.
2978 * @hide
2979 */
2980 public static final String ACTION_USER_STARTING =
2981 "android.intent.action.USER_STARTING";
2982
2983 /**
2984 * Broadcast sent when a user is going to be stopped. Carries an extra
2985 * EXTRA_USER_HANDLE that has the userHandle of the user. This is only
2986 * sent to registered receivers, not manifest receivers. It is sent to all
2987 * users (including the one that is being stopped). You must hold
2988 * {@link android.Manifest.permission#INTERACT_ACROSS_USERS} to receive
2989 * this broadcast. The user will not stop until all receivers have
2990 * handled the broadcast. This is sent as a background broadcast, since
2991 * its result is not part of the primary UX flow; to safely keep track of
2992 * started/stopped state of a user you can use this in conjunction with
2993 * {@link #ACTION_USER_STARTING}. It is <b>not</b> generally safe to use with
2994 * other user state broadcasts since those are foreground broadcasts so can
2995 * execute in a different order.
2996 * @hide
2997 */
2998 public static final String ACTION_USER_STOPPING =
2999 "android.intent.action.USER_STOPPING";
3000
3001 /**
3002 * Broadcast sent to the system when a user is stopped. Carries an extra
3003 * EXTRA_USER_HANDLE that has the userHandle of the user. This is similar to
3004 * {@link #ACTION_PACKAGE_RESTARTED}, but for an entire user instead of a
3005 * specific package. This is only sent to registered receivers, not manifest
3006 * receivers. It is sent to all running users <em>except</em> the one that
3007 * has just been stopped (which is no longer running).
Dianne Hackborn80a4af22012-08-27 19:18:31 -07003008 * @hide
3009 */
3010 public static final String ACTION_USER_STOPPED =
3011 "android.intent.action.USER_STOPPED";
3012
3013 /**
Amith Yamasani2a003292012-08-14 18:25:45 -07003014 * 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 -07003015 * the userHandle of the user. It is sent to all running users except the
Amith Yamasanidb6a14c2012-10-17 21:16:52 -07003016 * one that has been removed. The user will not be completely removed until all receivers have
3017 * handled the broadcast. You must hold
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07003018 * {@link android.Manifest.permission#MANAGE_USERS} to receive this broadcast.
Amith Yamasani13593602012-03-22 16:16:17 -07003019 * @hide
3020 */
3021 public static final String ACTION_USER_REMOVED =
3022 "android.intent.action.USER_REMOVED";
3023
3024 /**
Amith Yamasani2a003292012-08-14 18:25:45 -07003025 * Broadcast sent to the system when the user switches. Carries an extra EXTRA_USER_HANDLE that has
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07003026 * the userHandle of the user to become the current one. This is only sent to
3027 * registered receivers, not manifest receivers. It is sent to all running users.
3028 * You must hold
3029 * {@link android.Manifest.permission#MANAGE_USERS} to receive this broadcast.
Amith Yamasani13593602012-03-22 16:16:17 -07003030 * @hide
3031 */
3032 public static final String ACTION_USER_SWITCHED =
3033 "android.intent.action.USER_SWITCHED";
3034
Amith Yamasanie928d7d2012-09-17 21:46:51 -07003035 /**
Jeff Sharkey8924e872015-11-30 12:52:10 -07003036 * Broadcast Action: Sent when the credential-encrypted private storage has
3037 * become unlocked for the target user. This is only sent to registered
3038 * receivers, not manifest receivers.
3039 */
3040 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3041 public static final String ACTION_USER_UNLOCKED = "android.intent.action.USER_UNLOCKED";
3042
3043 /**
Amith Yamasanie928d7d2012-09-17 21:46:51 -07003044 * Broadcast sent to the system when a user's information changes. Carries an extra
3045 * {@link #EXTRA_USER_HANDLE} to indicate which user's information changed.
Amith Yamasani6fc1d4e2013-05-08 16:43:58 -07003046 * This is only sent to registered receivers, not manifest receivers. It is sent to all users.
Amith Yamasanie928d7d2012-09-17 21:46:51 -07003047 * @hide
3048 */
3049 public static final String ACTION_USER_INFO_CHANGED =
3050 "android.intent.action.USER_INFO_CHANGED";
3051
Daniel Sandler2e7d25b2012-10-01 16:43:26 -04003052 /**
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01003053 * Broadcast sent to the primary user when an associated managed profile is added (the profile
3054 * was created and is ready to be used). Carries an extra {@link #EXTRA_USER} that specifies
Adam Connorsd4b584e2014-06-09 13:55:47 +01003055 * the UserHandle of the profile that was added. Only applications (for example Launchers)
3056 * that need to display merged content across both primary and managed profiles need to
3057 * worry about this broadcast. This is only sent to registered receivers,
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01003058 * not manifest receivers.
3059 */
3060 public static final String ACTION_MANAGED_PROFILE_ADDED =
3061 "android.intent.action.MANAGED_PROFILE_ADDED";
3062
3063 /**
3064 * Broadcast sent to the primary user when an associated managed profile is removed. Carries an
Adam Connorsd4b584e2014-06-09 13:55:47 +01003065 * extra {@link #EXTRA_USER} that specifies the UserHandle of the profile that was removed.
3066 * Only applications (for example Launchers) that need to display merged content across both
3067 * primary and managed profiles need to worry about this broadcast. This is only sent to
3068 * registered receivers, not manifest receivers.
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01003069 */
3070 public static final String ACTION_MANAGED_PROFILE_REMOVED =
3071 "android.intent.action.MANAGED_PROFILE_REMOVED";
3072
3073 /**
Kenny Guyb1b30262016-02-09 16:02:35 +00003074 * Broadcast sent to the primary user when the credential-encrypted private storage for
3075 * an associated managed profile is unlocked. Carries an extra {@link #EXTRA_USER} that
3076 * specifies the UserHandle of the profile that was unlocked. Only applications (for example
3077 * Launchers) that need to display merged content across both primary and managed profiles
3078 * need to worry about this broadcast. This is only sent to registered receivers,
3079 * not manifest receivers.
3080 */
3081 public static final String ACTION_MANAGED_PROFILE_UNLOCKED =
3082 "android.intent.action.MANAGED_PROFILE_UNLOCKED";
3083
3084 /**
Rubin Xue95057a2016-04-01 16:49:25 +01003085 * Broadcast sent to the primary user when an associated managed profile has become available.
3086 * Currently this includes when the user disables quiet mode for the profile. Carries an extra
Rubin Xuf13c9802016-01-21 18:06:00 +00003087 * {@link #EXTRA_USER} that specifies the UserHandle of the profile. When quiet mode is changed,
3088 * this broadcast will carry a boolean extra {@link #EXTRA_QUIET_MODE} indicating the new state
3089 * of quiet mode. This is only sent to registered receivers, not manifest receivers.
Rubin Xu0a29ecd2015-11-04 15:11:48 +00003090 */
Rubin Xue95057a2016-04-01 16:49:25 +01003091 public static final String ACTION_MANAGED_PROFILE_AVAILABLE =
3092 "android.intent.action.MANAGED_PROFILE_AVAILABLE";
3093
3094 /**
3095 * Broadcast sent to the primary user when an associated managed profile has become unavailable.
3096 * Currently this includes when the user enables quiet mode for the profile. Carries an extra
3097 * {@link #EXTRA_USER} that specifies the UserHandle of the profile. When quiet mode is changed,
3098 * this broadcast will carry a boolean extra {@link #EXTRA_QUIET_MODE} indicating the new state
3099 * of quiet mode. This is only sent to registered receivers, not manifest receivers.
3100 */
3101 public static final String ACTION_MANAGED_PROFILE_UNAVAILABLE =
3102 "android.intent.action.MANAGED_PROFILE_UNAVAILABLE";
Rubin Xu0a29ecd2015-11-04 15:11:48 +00003103
3104 /**
Robin Lee92b83c62016-08-31 13:27:51 +01003105 * Broadcast sent to the system user when the 'device locked' state changes for any user.
3106 * Carries an extra {@link #EXTRA_USER_HANDLE} that specifies the ID of the user for which
3107 * the device was locked or unlocked.
3108 *
3109 * This is only sent to registered receivers.
3110 *
3111 * @hide
3112 */
3113 public static final String ACTION_DEVICE_LOCKED_CHANGED =
3114 "android.intent.action.DEVICE_LOCKED_CHANGED";
3115
3116 /**
Daniel Sandler2e7d25b2012-10-01 16:43:26 -04003117 * Sent when the user taps on the clock widget in the system's "quick settings" area.
3118 */
3119 public static final String ACTION_QUICK_CLOCK =
3120 "android.intent.action.QUICK_CLOCK";
3121
Michael Wright0087a142013-02-05 16:29:39 -08003122 /**
Alan Viverette5a399492014-07-14 16:19:38 -07003123 * Activity Action: Shows the brightness setting dialog.
Michael Wright0087a142013-02-05 16:29:39 -08003124 * @hide
3125 */
3126 public static final String ACTION_SHOW_BRIGHTNESS_DIALOG =
3127 "android.intent.action.SHOW_BRIGHTNESS_DIALOG";
3128
Justin Kohd378ad72013-04-01 12:18:26 -07003129 /**
3130 * Broadcast Action: A global button was pressed. Includes a single
3131 * extra field, {@link #EXTRA_KEY_EVENT}, containing the key event that
3132 * caused the broadcast.
3133 * @hide
3134 */
3135 public static final String ACTION_GLOBAL_BUTTON = "android.intent.action.GLOBAL_BUTTON";
3136
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003137 /**
Dongwon Kang2034a4c2015-12-14 21:57:34 +09003138 * Broadcast Action: Sent when media resource is granted.
3139 * <p>
3140 * {@link #EXTRA_PACKAGES} specifies the packages on the process holding the media resource
3141 * granted.
3142 * </p>
3143 * <p class="note">
3144 * This is a protected intent that can only be sent by the system.
3145 * </p>
3146 * <p class="note">
Dongwon Kang32cb9ab2016-01-13 18:11:10 -08003147 * This requires {@link android.Manifest.permission#RECEIVE_MEDIA_RESOURCE_USAGE} permission.
Dongwon Kang2034a4c2015-12-14 21:57:34 +09003148 * </p>
3149 *
3150 * @hide
3151 */
3152 public static final String ACTION_MEDIA_RESOURCE_GRANTED =
3153 "android.intent.action.MEDIA_RESOURCE_GRANTED";
3154
3155 /**
MÃ¥rten Kongstadeabc9e92015-12-15 16:40:23 +01003156 * Broadcast Action: An overlay package has been installed. The data
3157 * contains the name of the added overlay package.
3158 * @hide
3159 */
3160 public static final String ACTION_OVERLAY_ADDED = "android.intent.action.OVERLAY_ADDED";
3161
3162 /**
3163 * Broadcast Action: An overlay package has changed. The data contains the
3164 * name of the overlay package which has changed. This is broadcast on all
3165 * changes to the OverlayInfo returned by {@link
3166 * android.content.om.IOverlayManager#getOverlayInfo(String, int)}. The
3167 * most common change is a state change that will change whether the
3168 * overlay is enabled or not.
3169 * @hide
3170 */
3171 public static final String ACTION_OVERLAY_CHANGED = "android.intent.action.OVERLAY_CHANGED";
3172
3173 /**
3174 * Broadcast Action: An overlay package has been removed. The data contains
3175 * the name of the overlay package which has been removed.
3176 * @hide
3177 */
3178 public static final String ACTION_OVERLAY_REMOVED = "android.intent.action.OVERLAY_REMOVED";
3179
3180 /**
3181 * Broadcast Action: The order of a package's list of overlay packages has
3182 * changed. The data contains the package name of the overlay package that
3183 * had its position in the list adjusted.
3184 * @hide
3185 */
3186 public static final String
3187 ACTION_OVERLAY_PRIORITY_CHANGED = "android.intent.action.OVERLAY_PRIORITY_CHANGED";
3188
3189 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003190 * Activity Action: Allow the user to select and return one or more existing
3191 * documents. When invoked, the system will display the various
3192 * {@link DocumentsProvider} instances installed on the device, letting the
3193 * user interactively navigate through them. These documents include local
3194 * media, such as photos and video, and documents provided by installed
3195 * cloud storage providers.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003196 * <p>
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003197 * Each document is represented as a {@code content://} URI backed by a
3198 * {@link DocumentsProvider}, which can be opened as a stream with
3199 * {@link ContentResolver#openFileDescriptor(Uri, String)}, or queried for
3200 * {@link android.provider.DocumentsContract.Document} metadata.
3201 * <p>
3202 * All selected documents are returned to the calling application with
3203 * persistable read and write permission grants. If you want to maintain
3204 * access to the documents across device reboots, you need to explicitly
3205 * take the persistable permissions using
3206 * {@link ContentResolver#takePersistableUriPermission(Uri, int)}.
3207 * <p>
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003208 * Callers must indicate the acceptable document MIME types through
3209 * {@link #setType(String)}. For example, to select photos, use
3210 * {@code image/*}. If multiple disjoint MIME types are acceptable, define
3211 * them in {@link #EXTRA_MIME_TYPES} and {@link #setType(String)} to
3212 * {@literal *}/*.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003213 * <p>
3214 * If the caller can handle multiple returned items (the user performing
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003215 * multiple selection), then you can specify {@link #EXTRA_ALLOW_MULTIPLE}
3216 * to indicate this.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003217 * <p>
Tomasz Mikolajewskia8057a92015-11-16 11:41:28 +09003218 * Callers must include {@link #CATEGORY_OPENABLE} in the Intent to obtain
3219 * URIs that can be opened with
Jeff Sharkeybd3b9022013-08-20 15:20:04 -07003220 * {@link ContentResolver#openFileDescriptor(Uri, String)}.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003221 * <p>
Garfield Tanb44ae612016-11-07 16:46:37 -08003222 * Callers can set a document URI through
3223 * {@link DocumentsContract#EXTRA_INITIAL_URI} to indicate the initial
3224 * location of documents navigator. System will do its best to launch the
3225 * navigator in the specified document if it's a folder, or the folder that
3226 * contains the specified document if not.
Garfield Tan0b3cf662016-10-31 12:59:45 -07003227 * <p>
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003228 * Output: The URI of the item that was picked, returned in
3229 * {@link #getData()}. This must be a {@code content://} URI so that any
3230 * receiver can access it. If multiple documents were selected, they are
3231 * returned in {@link #getClipData()}.
Jeff Sharkeybd3b9022013-08-20 15:20:04 -07003232 *
3233 * @see DocumentsContract
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003234 * @see #ACTION_OPEN_DOCUMENT_TREE
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003235 * @see #ACTION_CREATE_DOCUMENT
3236 * @see #FLAG_GRANT_PERSISTABLE_URI_PERMISSION
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003237 */
3238 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
3239 public static final String ACTION_OPEN_DOCUMENT = "android.intent.action.OPEN_DOCUMENT";
3240
3241 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003242 * Activity Action: Allow the user to create a new document. When invoked,
3243 * the system will display the various {@link DocumentsProvider} instances
3244 * installed on the device, letting the user navigate through them. The
3245 * returned document may be a newly created document with no content, or it
3246 * may be an existing document with the requested MIME type.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003247 * <p>
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003248 * Each document is represented as a {@code content://} URI backed by a
3249 * {@link DocumentsProvider}, which can be opened as a stream with
3250 * {@link ContentResolver#openFileDescriptor(Uri, String)}, or queried for
3251 * {@link android.provider.DocumentsContract.Document} metadata.
3252 * <p>
3253 * Callers must indicate the concrete MIME type of the document being
3254 * created by setting {@link #setType(String)}. This MIME type cannot be
3255 * changed after the document is created.
3256 * <p>
3257 * Callers can provide an initial display name through {@link #EXTRA_TITLE},
3258 * but the user may change this value before creating the file.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003259 * <p>
Tomasz Mikolajewskia8057a92015-11-16 11:41:28 +09003260 * Callers must include {@link #CATEGORY_OPENABLE} in the Intent to obtain
3261 * URIs that can be opened with
Jeff Sharkeybd3b9022013-08-20 15:20:04 -07003262 * {@link ContentResolver#openFileDescriptor(Uri, String)}.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003263 * <p>
Garfield Tanb44ae612016-11-07 16:46:37 -08003264 * Callers can set a document URI through
3265 * {@link DocumentsContract#EXTRA_INITIAL_URI} to indicate the initial
3266 * location of documents navigator. System will do its best to launch the
3267 * navigator in the specified document if it's a folder, or the folder that
3268 * contains the specified document if not.
Garfield Tan0b3cf662016-10-31 12:59:45 -07003269 * <p>
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003270 * Output: The URI of the item that was created. This must be a
3271 * {@code content://} URI so that any receiver can access it.
Jeff Sharkeybd3b9022013-08-20 15:20:04 -07003272 *
3273 * @see DocumentsContract
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003274 * @see #ACTION_OPEN_DOCUMENT
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003275 * @see #ACTION_OPEN_DOCUMENT_TREE
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003276 * @see #FLAG_GRANT_PERSISTABLE_URI_PERMISSION
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003277 */
3278 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
3279 public static final String ACTION_CREATE_DOCUMENT = "android.intent.action.CREATE_DOCUMENT";
3280
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003281 /**
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003282 * Activity Action: Allow the user to pick a directory subtree. When
3283 * invoked, the system will display the various {@link DocumentsProvider}
3284 * instances installed on the device, letting the user navigate through
3285 * them. Apps can fully manage documents within the returned directory.
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003286 * <p>
3287 * To gain access to descendant (child, grandchild, etc) documents, use
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003288 * {@link DocumentsContract#buildDocumentUriUsingTree(Uri, String)} and
3289 * {@link DocumentsContract#buildChildDocumentsUriUsingTree(Uri, String)}
3290 * with the returned URI.
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003291 * <p>
Garfield Tanb44ae612016-11-07 16:46:37 -08003292 * Callers can set a document URI through
3293 * {@link DocumentsContract#EXTRA_INITIAL_URI} to indicate the initial
3294 * location of documents navigator. System will do its best to launch the
3295 * navigator in the specified document if it's a folder, or the folder that
3296 * contains the specified document if not.
Garfield Tan0b3cf662016-10-31 12:59:45 -07003297 * <p>
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003298 * Output: The URI representing the selected directory tree.
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003299 *
3300 * @see DocumentsContract
3301 */
3302 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003303 public static final String
3304 ACTION_OPEN_DOCUMENT_TREE = "android.intent.action.OPEN_DOCUMENT_TREE";
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003305
Felipe Lemec7b1f892016-01-15 15:02:31 -08003306 /**
Peng Xua35b5532016-01-20 00:05:45 -08003307 * Broadcast Action: List of dynamic sensor is changed due to new sensor being connected or
3308 * exisiting sensor being disconnected.
3309 *
3310 * <p class="note">This is a protected intent that can only be sent by the system.</p>
3311 *
3312 * {@hide}
3313 */
3314 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3315 public static final String
3316 ACTION_DYNAMIC_SENSOR_CHANGED = "android.intent.action.DYNAMIC_SENSOR_CHANGED";
3317
Lenka Trochtova73aeea22016-11-18 17:34:34 +01003318 /**
3319 * Deprecated - use {@link #ACTION_FACTORY_RESET} instead.
3320 *
3321 * {@hide}
3322 */
3323 @Deprecated
Jeff Sharkey004a4b22014-09-24 11:45:24 -07003324 public static final String ACTION_MASTER_CLEAR = "android.intent.action.MASTER_CLEAR";
3325
Christopher Tate6597e342015-02-17 12:15:25 -08003326 /**
Amith Yamasanicbabb8d2017-02-17 16:50:05 -08003327 * Broadcast intent sent by the RecoverySystem to inform listeners that a master clear (wipe)
3328 * is about to be performed.
3329 * @hide
3330 */
3331 @SystemApi
3332 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3333 public static final String ACTION_MASTER_CLEAR_NOTIFICATION
3334 = "android.intent.action.MASTER_CLEAR_NOTIFICATION";
3335
3336 /**
Lenka Trochtova73aeea22016-11-18 17:34:34 +01003337 * Boolean intent extra to be used with {@link #ACTION_MASTER_CLEAR} in order to force a factory
3338 * reset even if {@link android.os.UserManager#DISALLOW_FACTORY_RESET} is set.
3339 *
3340 * <p>Deprecated - use {@link #EXTRA_FORCE_FACTORY_RESET} instead.
3341 *
Benjamin Franzf9d5e6a2016-05-26 14:24:29 +01003342 * @hide
3343 */
Lenka Trochtova73aeea22016-11-18 17:34:34 +01003344 @Deprecated
Benjamin Franzf9d5e6a2016-05-26 14:24:29 +01003345 public static final String EXTRA_FORCE_MASTER_CLEAR =
3346 "android.intent.extra.FORCE_MASTER_CLEAR";
3347
3348 /**
Lenka Trochtova73aeea22016-11-18 17:34:34 +01003349 * A broadcast action to trigger a factory reset.
3350 *
3351 * <p> The sender must hold the {@link android.Manifest.permission#MASTER_CLEAR} permission.
3352 *
3353 * <p>Not for use by third-party applications.
3354 *
3355 * @see #EXTRA_FORCE_MASTER_CLEAR
3356 *
3357 * {@hide}
3358 */
3359 @SystemApi
3360 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3361 public static final String ACTION_FACTORY_RESET = "android.intent.action.FACTORY_RESET";
3362
3363 /**
3364 * Boolean intent extra to be used with {@link #ACTION_MASTER_CLEAR} in order to force a factory
3365 * reset even if {@link android.os.UserManager#DISALLOW_FACTORY_RESET} is set.
3366 *
3367 * <p>Not for use by third-party applications.
3368 *
3369 * @hide
3370 */
3371 @SystemApi
3372 public static final String EXTRA_FORCE_FACTORY_RESET =
3373 "android.intent.extra.FORCE_FACTORY_RESET";
3374
3375 /**
Christopher Tate6597e342015-02-17 12:15:25 -08003376 * Broadcast action: report that a settings element is being restored from backup. The intent
3377 * contains three extras: EXTRA_SETTING_NAME is a string naming the restored setting,
3378 * EXTRA_SETTING_NEW_VALUE is the value being restored, and EXTRA_SETTING_PREVIOUS_VALUE
3379 * is the value of that settings entry prior to the restore operation. All of these values are
3380 * represented as strings.
3381 *
3382 * <p>This broadcast is sent only for settings provider entries known to require special handling
3383 * around restore time. These entries are found in the BROADCAST_ON_RESTORE table within
3384 * the provider's backup agent implementation.
3385 *
3386 * @see #EXTRA_SETTING_NAME
3387 * @see #EXTRA_SETTING_PREVIOUS_VALUE
3388 * @see #EXTRA_SETTING_NEW_VALUE
3389 * {@hide}
3390 */
3391 public static final String ACTION_SETTING_RESTORED = "android.os.action.SETTING_RESTORED";
3392
3393 /** {@hide} */
3394 public static final String EXTRA_SETTING_NAME = "setting_name";
3395 /** {@hide} */
3396 public static final String EXTRA_SETTING_PREVIOUS_VALUE = "previous_value";
3397 /** {@hide} */
3398 public static final String EXTRA_SETTING_NEW_VALUE = "new_value";
3399
Clara Bayarri0a26157a2015-03-26 18:38:55 +00003400 /**
3401 * Activity Action: Process a piece of text.
3402 * <p>Input: {@link #EXTRA_PROCESS_TEXT} contains the text to be processed.
3403 * {@link #EXTRA_PROCESS_TEXT_READONLY} states if the resulting text will be read-only.</p>
3404 * <p>Output: {@link #EXTRA_PROCESS_TEXT} contains the processed text.</p>
3405 */
3406 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
3407 public static final String ACTION_PROCESS_TEXT = "android.intent.action.PROCESS_TEXT";
Amith Yamasanicbabb8d2017-02-17 16:50:05 -08003408
3409 /**
3410 * Broadcast Action: The sim card state has changed.
3411 * For more details see TelephonyIntents.ACTION_SIM_STATE_CHANGED. This is here
3412 * because TelephonyIntents is an internal class.
3413 * @hide
3414 */
3415 @SystemApi
3416 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3417 public static final String ACTION_SIM_STATE_CHANGED = "android.intent.action.SIM_STATE_CHANGED";
3418
Clara Bayarri0a26157a2015-03-26 18:38:55 +00003419 /**
Clara Bayarri92c8e6f2015-05-21 17:50:08 +01003420 * The name of the extra used to define the text to be processed, as a
3421 * CharSequence. Note that this may be a styled CharSequence, so you must use
3422 * {@link Bundle#getCharSequence(String) Bundle.getCharSequence()} to retrieve it.
Clara Bayarri0a26157a2015-03-26 18:38:55 +00003423 */
3424 public static final String EXTRA_PROCESS_TEXT = "android.intent.extra.PROCESS_TEXT";
3425 /**
Clara Bayarri92c8e6f2015-05-21 17:50:08 +01003426 * 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 +00003427 */
3428 public static final String EXTRA_PROCESS_TEXT_READONLY =
3429 "android.intent.extra.PROCESS_TEXT_READONLY";
3430
Bryce Leebc58f592015-09-25 16:43:01 -07003431 /**
3432 * Broadcast action: reports when a new thermal event has been reached. When the device
3433 * is reaching its maximum temperatue, the thermal level reported
3434 * {@hide}
3435 */
3436 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
3437 public static final String ACTION_THERMAL_EVENT = "android.intent.action.THERMAL_EVENT";
3438
3439 /** {@hide} */
3440 public static final String EXTRA_THERMAL_STATE = "android.intent.extra.THERMAL_STATE";
3441
3442 /**
3443 * Thermal state when the device is normal. This state is sent in the
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08003444 * {@link #ACTION_THERMAL_EVENT} broadcast as {@link #EXTRA_THERMAL_STATE}.
Bryce Leebc58f592015-09-25 16:43:01 -07003445 * {@hide}
3446 */
3447 public static final int EXTRA_THERMAL_STATE_NORMAL = 0;
3448
3449 /**
3450 * Thermal state where the device is approaching its maximum threshold. This state is sent in
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08003451 * the {@link #ACTION_THERMAL_EVENT} broadcast as {@link #EXTRA_THERMAL_STATE}.
Bryce Leebc58f592015-09-25 16:43:01 -07003452 * {@hide}
3453 */
3454 public static final int EXTRA_THERMAL_STATE_WARNING = 1;
3455
3456 /**
3457 * Thermal state where the device has reached its maximum threshold. This state is sent in the
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08003458 * {@link #ACTION_THERMAL_EVENT} broadcast as {@link #EXTRA_THERMAL_STATE}.
Bryce Leebc58f592015-09-25 16:43:01 -07003459 * {@hide}
3460 */
3461 public static final int EXTRA_THERMAL_STATE_EXCEEDED = 2;
3462
3463
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003464 // ---------------------------------------------------------------------
3465 // ---------------------------------------------------------------------
3466 // Standard intent categories (see addCategory()).
3467
3468 /**
3469 * Set if the activity should be an option for the default action
3470 * (center press) to perform on a piece of data. Setting this will
3471 * hide from the user any activities without it set when performing an
John Spurlock6098c5d2013-06-17 10:32:46 -04003472 * action on some data. Note that this is normally -not- set in the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003473 * Intent when initiating an action -- it is for use in intent filters
3474 * specified in packages.
3475 */
3476 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3477 public static final String CATEGORY_DEFAULT = "android.intent.category.DEFAULT";
3478 /**
3479 * Activities that can be safely invoked from a browser must support this
3480 * category. For example, if the user is viewing a web page or an e-mail
3481 * and clicks on a link in the text, the Intent generated execute that
3482 * link will require the BROWSABLE category, so that only activities
3483 * supporting this category will be considered as possible actions. By
3484 * supporting this category, you are promising that there is nothing
3485 * damaging (without user intervention) that can happen by invoking any
3486 * matching Intent.
3487 */
3488 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3489 public static final String CATEGORY_BROWSABLE = "android.intent.category.BROWSABLE";
3490 /**
Dianne Hackborn91097de2014-04-04 18:02:06 -07003491 * Categories for activities that can participate in voice interaction.
3492 * An activity that supports this category must be prepared to run with
3493 * no UI shown at all (though in some case it may have a UI shown), and
3494 * rely on {@link android.app.VoiceInteractor} to interact with the user.
3495 */
3496 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3497 public static final String CATEGORY_VOICE = "android.intent.category.VOICE";
3498 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003499 * Set if the activity should be considered as an alternative action to
3500 * the data the user is currently viewing. See also
3501 * {@link #CATEGORY_SELECTED_ALTERNATIVE} for an alternative action that
3502 * applies to the selection in a list of items.
3503 *
3504 * <p>Supporting this category means that you would like your activity to be
3505 * displayed in the set of alternative things the user can do, usually as
3506 * part of the current activity's options menu. You will usually want to
3507 * include a specific label in the &lt;intent-filter&gt; of this action
3508 * describing to the user what it does.
3509 *
3510 * <p>The action of IntentFilter with this category is important in that it
3511 * describes the specific action the target will perform. This generally
3512 * should not be a generic action (such as {@link #ACTION_VIEW}, but rather
3513 * a specific name such as "com.android.camera.action.CROP. Only one
3514 * alternative of any particular action will be shown to the user, so using
3515 * a specific action like this makes sure that your alternative will be
3516 * displayed while also allowing other applications to provide their own
3517 * overrides of that particular action.
3518 */
3519 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3520 public static final String CATEGORY_ALTERNATIVE = "android.intent.category.ALTERNATIVE";
3521 /**
3522 * Set if the activity should be considered as an alternative selection
3523 * action to the data the user has currently selected. This is like
3524 * {@link #CATEGORY_ALTERNATIVE}, but is used in activities showing a list
3525 * of items from which the user can select, giving them alternatives to the
3526 * default action that will be performed on it.
3527 */
3528 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3529 public static final String CATEGORY_SELECTED_ALTERNATIVE = "android.intent.category.SELECTED_ALTERNATIVE";
3530 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09003531 * Intended to be used as a tab inside of a containing TabActivity.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003532 */
3533 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3534 public static final String CATEGORY_TAB = "android.intent.category.TAB";
3535 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003536 * Should be displayed in the top-level launcher.
3537 */
3538 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3539 public static final String CATEGORY_LAUNCHER = "android.intent.category.LAUNCHER";
3540 /**
Jose Lima38b75b62014-03-11 10:41:39 -07003541 * Indicates an activity optimized for Leanback mode, and that should
3542 * be displayed in the Leanback launcher.
3543 */
3544 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3545 public static final String CATEGORY_LEANBACK_LAUNCHER = "android.intent.category.LEANBACK_LAUNCHER";
3546 /**
Jose Lima73915cf2014-07-29 17:16:31 -07003547 * Indicates a Leanback settings activity to be displayed in the Leanback launcher.
3548 * @hide
3549 */
3550 @SystemApi
3551 public static final String CATEGORY_LEANBACK_SETTINGS = "android.intent.category.LEANBACK_SETTINGS";
3552 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003553 * Provides information about the package it is in; typically used if
3554 * a package does not contain a {@link #CATEGORY_LAUNCHER} to provide
3555 * a front-door to the user without having to be shown in the all apps list.
3556 */
3557 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3558 public static final String CATEGORY_INFO = "android.intent.category.INFO";
3559 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003560 * This is the home activity, that is the first activity that is displayed
3561 * when the device boots.
3562 */
3563 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3564 public static final String CATEGORY_HOME = "android.intent.category.HOME";
3565 /**
Anthony Hugh979b81a2015-09-29 16:50:35 -07003566 * This is the home activity that is displayed when the device is finished setting up and ready
3567 * for use.
3568 * @hide
3569 */
3570 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3571 public static final String CATEGORY_HOME_MAIN = "android.intent.category.HOME_MAIN";
3572 /**
Svet Ganov50a8bf42015-07-15 11:04:18 -07003573 * This is the setup wizard activity, that is the first activity that is displayed
3574 * when the user sets up the device for the first time.
3575 * @hide
3576 */
3577 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3578 public static final String CATEGORY_SETUP_WIZARD = "android.intent.category.SETUP_WIZARD";
3579 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003580 * This activity is a preference panel.
3581 */
3582 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3583 public static final String CATEGORY_PREFERENCE = "android.intent.category.PREFERENCE";
3584 /**
3585 * This activity is a development preference panel.
3586 */
3587 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3588 public static final String CATEGORY_DEVELOPMENT_PREFERENCE = "android.intent.category.DEVELOPMENT_PREFERENCE";
3589 /**
3590 * Capable of running inside a parent activity container.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003591 */
3592 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3593 public static final String CATEGORY_EMBED = "android.intent.category.EMBED";
3594 /**
Patrick Dubroy6dabe242010-08-30 10:43:47 -07003595 * This activity allows the user to browse and download new applications.
3596 */
3597 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3598 public static final String CATEGORY_APP_MARKET = "android.intent.category.APP_MARKET";
3599 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003600 * This activity may be exercised by the monkey or other automated test tools.
3601 */
3602 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3603 public static final String CATEGORY_MONKEY = "android.intent.category.MONKEY";
3604 /**
3605 * To be used as a test (not part of the normal user experience).
3606 */
3607 public static final String CATEGORY_TEST = "android.intent.category.TEST";
3608 /**
3609 * To be used as a unit test (run through the Test Harness).
3610 */
3611 public static final String CATEGORY_UNIT_TEST = "android.intent.category.UNIT_TEST";
3612 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09003613 * To be used as a sample code example (not part of the normal user
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003614 * experience).
3615 */
3616 public static final String CATEGORY_SAMPLE_CODE = "android.intent.category.SAMPLE_CODE";
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003617
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003618 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003619 * Used to indicate that an intent only wants URIs that can be opened with
3620 * {@link ContentResolver#openFileDescriptor(Uri, String)}. Openable URIs
3621 * must support at least the columns defined in {@link OpenableColumns} when
3622 * queried.
3623 *
3624 * @see #ACTION_GET_CONTENT
3625 * @see #ACTION_OPEN_DOCUMENT
3626 * @see #ACTION_CREATE_DOCUMENT
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003627 */
3628 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3629 public static final String CATEGORY_OPENABLE = "android.intent.category.OPENABLE";
3630
3631 /**
Tomasz Mikolajewski28a815c2016-10-28 15:54:11 +09003632 * Used to indicate that an intent filter can accept files which are not necessarily
3633 * openable by {@link ContentResolver#openFileDescriptor(Uri, String)}, but
3634 * at least streamable via
3635 * {@link ContentResolver#openTypedAssetFileDescriptor(Uri, String, Bundle)}
3636 * using one of the stream types exposed via
3637 * {@link ContentResolver#getStreamTypes(Uri, String)}.
3638 *
3639 * @see #ACTION_SEND
3640 * @see #ACTION_SEND_MULTIPLE
3641 */
3642 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3643 public static final String CATEGORY_TYPED_OPENABLE =
3644 "android.intent.category.TYPED_OPENABLE";
3645
3646 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003647 * To be used as code under test for framework instrumentation tests.
3648 */
3649 public static final String CATEGORY_FRAMEWORK_INSTRUMENTATION_TEST =
3650 "android.intent.category.FRAMEWORK_INSTRUMENTATION_TEST";
Mike Lockwood9092ab42009-09-16 13:01:32 -04003651 /**
3652 * An activity to run when device is inserted into a car dock.
Dianne Hackborn7299c412010-03-04 18:41:49 -08003653 * Used with {@link #ACTION_MAIN} to launch an activity. For more
3654 * information, see {@link android.app.UiModeManager}.
Mike Lockwood9092ab42009-09-16 13:01:32 -04003655 */
3656 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3657 public static final String CATEGORY_CAR_DOCK = "android.intent.category.CAR_DOCK";
3658 /**
3659 * An activity to run when device is inserted into a car dock.
Dianne Hackborn7299c412010-03-04 18:41:49 -08003660 * Used with {@link #ACTION_MAIN} to launch an activity. For more
3661 * information, see {@link android.app.UiModeManager}.
Mike Lockwood9092ab42009-09-16 13:01:32 -04003662 */
3663 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3664 public static final String CATEGORY_DESK_DOCK = "android.intent.category.DESK_DOCK";
Praveen Bharathi21e941b2010-10-06 15:23:14 -05003665 /**
3666 * An activity to run when device is inserted into a analog (low end) dock.
3667 * Used with {@link #ACTION_MAIN} to launch an activity. For more
3668 * information, see {@link android.app.UiModeManager}.
3669 */
3670 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3671 public static final String CATEGORY_LE_DESK_DOCK = "android.intent.category.LE_DESK_DOCK";
3672
3673 /**
3674 * An activity to run when device is inserted into a digital (high end) dock.
3675 * Used with {@link #ACTION_MAIN} to launch an activity. For more
3676 * information, see {@link android.app.UiModeManager}.
3677 */
3678 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3679 public static final String CATEGORY_HE_DESK_DOCK = "android.intent.category.HE_DESK_DOCK";
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05003680
Bernd Holzheyaea4b672010-03-31 09:46:13 +02003681 /**
3682 * Used to indicate that the activity can be used in a car environment.
3683 */
3684 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3685 public static final String CATEGORY_CAR_MODE = "android.intent.category.CAR_MODE";
3686
Zak Cohendb6ca492017-01-26 14:09:00 -08003687 /**
3688 * An activity to use for the launcher when the device is placed in a VR Headset viewer.
3689 * Used with {@link #ACTION_MAIN} to launch an activity. For more
3690 * information, see {@link android.app.UiModeManager}.
3691 */
3692 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3693 public static final String CATEGORY_VR_HOME = "android.intent.category.VR_HOME";
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003694 // ---------------------------------------------------------------------
3695 // ---------------------------------------------------------------------
Jeff Brown6651a632011-11-28 12:59:11 -08003696 // Application launch intent categories (see addCategory()).
3697
3698 /**
3699 * Used with {@link #ACTION_MAIN} to launch the browser application.
3700 * The activity should be able to browse the Internet.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003701 * <p>NOTE: This should not be used as the primary key of an Intent,
3702 * since it will not result in the app launching with the correct
3703 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003704 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003705 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003706 */
3707 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3708 public static final String CATEGORY_APP_BROWSER = "android.intent.category.APP_BROWSER";
3709
3710 /**
3711 * Used with {@link #ACTION_MAIN} to launch the calculator application.
3712 * The activity should be able to perform standard arithmetic operations.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003713 * <p>NOTE: This should not be used as the primary key of an Intent,
3714 * since it will not result in the app launching with the correct
3715 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003716 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003717 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003718 */
3719 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3720 public static final String CATEGORY_APP_CALCULATOR = "android.intent.category.APP_CALCULATOR";
3721
3722 /**
3723 * Used with {@link #ACTION_MAIN} to launch the calendar application.
3724 * The activity should be able to view and manipulate calendar entries.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003725 * <p>NOTE: This should not be used as the primary key of an Intent,
3726 * since it will not result in the app launching with the correct
3727 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003728 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003729 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003730 */
3731 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3732 public static final String CATEGORY_APP_CALENDAR = "android.intent.category.APP_CALENDAR";
3733
3734 /**
3735 * Used with {@link #ACTION_MAIN} to launch the contacts application.
3736 * The activity should be able to view and manipulate address book entries.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003737 * <p>NOTE: This should not be used as the primary key of an Intent,
3738 * since it will not result in the app launching with the correct
3739 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003740 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003741 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003742 */
3743 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3744 public static final String CATEGORY_APP_CONTACTS = "android.intent.category.APP_CONTACTS";
3745
3746 /**
3747 * Used with {@link #ACTION_MAIN} to launch the email application.
3748 * The activity should be able to send and receive email.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003749 * <p>NOTE: This should not be used as the primary key of an Intent,
3750 * since it will not result in the app launching with the correct
3751 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003752 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003753 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003754 */
3755 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3756 public static final String CATEGORY_APP_EMAIL = "android.intent.category.APP_EMAIL";
3757
3758 /**
3759 * Used with {@link #ACTION_MAIN} to launch the gallery application.
3760 * The activity should be able to view and manipulate image and video files
3761 * stored on the device.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003762 * <p>NOTE: This should not be used as the primary key of an Intent,
3763 * since it will not result in the app launching with the correct
3764 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003765 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003766 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003767 */
3768 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3769 public static final String CATEGORY_APP_GALLERY = "android.intent.category.APP_GALLERY";
3770
3771 /**
3772 * Used with {@link #ACTION_MAIN} to launch the maps application.
3773 * The activity should be able to show the user's current location and surroundings.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003774 * <p>NOTE: This should not be used as the primary key of an Intent,
3775 * since it will not result in the app launching with the correct
3776 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003777 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003778 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003779 */
3780 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3781 public static final String CATEGORY_APP_MAPS = "android.intent.category.APP_MAPS";
3782
3783 /**
3784 * Used with {@link #ACTION_MAIN} to launch the messaging application.
3785 * The activity should be able to send and receive text messages.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003786 * <p>NOTE: This should not be used as the primary key of an Intent,
3787 * since it will not result in the app launching with the correct
3788 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003789 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003790 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003791 */
3792 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3793 public static final String CATEGORY_APP_MESSAGING = "android.intent.category.APP_MESSAGING";
3794
3795 /**
3796 * Used with {@link #ACTION_MAIN} to launch the music application.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003797 * The activity should be able to play, browse, or manipulate music files
3798 * stored on the device.
3799 * <p>NOTE: This should not be used as the primary key of an Intent,
3800 * since it will not result in the app launching with the correct
3801 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003802 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003803 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003804 */
3805 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3806 public static final String CATEGORY_APP_MUSIC = "android.intent.category.APP_MUSIC";
3807
3808 // ---------------------------------------------------------------------
3809 // ---------------------------------------------------------------------
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003810 // Standard extra data keys.
3811
3812 /**
3813 * The initial data to place in a newly created record. Use with
3814 * {@link #ACTION_INSERT}. The data here is a Map containing the same
3815 * fields as would be given to the underlying ContentProvider.insert()
3816 * call.
3817 */
3818 public static final String EXTRA_TEMPLATE = "android.intent.extra.TEMPLATE";
3819
3820 /**
3821 * A constant CharSequence that is associated with the Intent, used with
3822 * {@link #ACTION_SEND} to supply the literal data to be sent. Note that
3823 * this may be a styled CharSequence, so you must use
3824 * {@link Bundle#getCharSequence(String) Bundle.getCharSequence()} to
3825 * retrieve it.
3826 */
3827 public static final String EXTRA_TEXT = "android.intent.extra.TEXT";
3828
3829 /**
Dianne Hackbornacb69bb2012-04-13 15:36:06 -07003830 * A constant String that is associated with the Intent, used with
3831 * {@link #ACTION_SEND} to supply an alternative to {@link #EXTRA_TEXT}
3832 * as HTML formatted text. Note that you <em>must</em> also supply
3833 * {@link #EXTRA_TEXT}.
3834 */
3835 public static final String EXTRA_HTML_TEXT = "android.intent.extra.HTML_TEXT";
3836
3837 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003838 * A content: URI holding a stream of data associated with the Intent,
3839 * used with {@link #ACTION_SEND} to supply the data being sent.
3840 */
3841 public static final String EXTRA_STREAM = "android.intent.extra.STREAM";
3842
3843 /**
3844 * A String[] holding e-mail addresses that should be delivered to.
3845 */
3846 public static final String EXTRA_EMAIL = "android.intent.extra.EMAIL";
3847
3848 /**
3849 * A String[] holding e-mail addresses that should be carbon copied.
3850 */
3851 public static final String EXTRA_CC = "android.intent.extra.CC";
3852
3853 /**
3854 * A String[] holding e-mail addresses that should be blind carbon copied.
3855 */
3856 public static final String EXTRA_BCC = "android.intent.extra.BCC";
3857
3858 /**
3859 * A constant string holding the desired subject line of a message.
3860 */
3861 public static final String EXTRA_SUBJECT = "android.intent.extra.SUBJECT";
3862
3863 /**
3864 * An Intent describing the choices you would like shown with
Adam Powell2ed547e2015-04-29 18:45:04 -07003865 * {@link #ACTION_PICK_ACTIVITY} or {@link #ACTION_CHOOSER}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003866 */
3867 public static final String EXTRA_INTENT = "android.intent.extra.INTENT";
3868
3869 /**
Clara Bayarrif7fea162015-10-22 16:09:52 +01003870 * An int representing the user id to be used.
3871 *
3872 * @hide
3873 */
3874 public static final String EXTRA_USER_ID = "android.intent.extra.USER_ID";
3875
3876 /**
Clara Bayarriea9b10e2015-12-04 15:36:26 +00003877 * An int representing the task id to be retrieved. This is used when a launch from recents is
3878 * intercepted by another action such as credentials confirmation to remember which task should
3879 * be resumed when complete.
3880 *
3881 * @hide
3882 */
3883 public static final String EXTRA_TASK_ID = "android.intent.extra.TASK_ID";
3884
3885 /**
Adam Powell2ed547e2015-04-29 18:45:04 -07003886 * An Intent[] describing additional, alternate choices you would like shown with
3887 * {@link #ACTION_CHOOSER}.
3888 *
3889 * <p>An app may be capable of providing several different payload types to complete a
3890 * user's intended action. For example, an app invoking {@link #ACTION_SEND} to share photos
3891 * with another app may use EXTRA_ALTERNATE_INTENTS to have the chooser transparently offer
3892 * several different supported sending mechanisms for sharing, such as the actual "image/*"
3893 * photo data or a hosted link where the photos can be viewed.</p>
3894 *
3895 * <p>The intent present in {@link #EXTRA_INTENT} will be treated as the
3896 * first/primary/preferred intent in the set. Additional intents specified in
3897 * this extra are ordered; by default intents that appear earlier in the array will be
3898 * preferred over intents that appear later in the array as matches for the same
3899 * target component. To alter this preference, a calling app may also supply
3900 * {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER}.</p>
3901 */
3902 public static final String EXTRA_ALTERNATE_INTENTS = "android.intent.extra.ALTERNATE_INTENTS";
3903
3904 /**
Adam Powell52c39212016-04-07 15:14:18 -07003905 * A {@link ComponentName ComponentName[]} describing components that should be filtered out
3906 * and omitted from a list of components presented to the user.
3907 *
3908 * <p>When used with {@link #ACTION_CHOOSER}, the chooser will omit any of the components
3909 * in this array if it otherwise would have shown them. Useful for omitting specific targets
3910 * from your own package or other apps from your organization if the idea of sending to those
3911 * targets would be redundant with other app functionality. Filtered components will not
3912 * be able to present targets from an associated <code>ChooserTargetService</code>.</p>
3913 */
3914 public static final String EXTRA_EXCLUDE_COMPONENTS
3915 = "android.intent.extra.EXCLUDE_COMPONENTS";
3916
3917 /**
3918 * A {@link android.service.chooser.ChooserTarget ChooserTarget[]} for {@link #ACTION_CHOOSER}
3919 * describing additional high-priority deep-link targets for the chooser to present to the user.
3920 *
3921 * <p>Targets provided in this way will be presented inline with all other targets provided
3922 * by services from other apps. They will be prioritized before other service targets, but
3923 * after those targets provided by sources that the user has manually pinned to the front.</p>
3924 *
3925 * @see #ACTION_CHOOSER
3926 */
3927 public static final String EXTRA_CHOOSER_TARGETS = "android.intent.extra.CHOOSER_TARGETS";
3928
3929 /**
Adam Powell2ed547e2015-04-29 18:45:04 -07003930 * An {@link IntentSender} for an Activity that will be invoked when the user makes a selection
3931 * from the chooser activity presented by {@link #ACTION_CHOOSER}.
3932 *
3933 * <p>An app preparing an action for another app to complete may wish to allow the user to
3934 * disambiguate between several options for completing the action based on the chosen target
3935 * or otherwise refine the action before it is invoked.
3936 * </p>
3937 *
3938 * <p>When sent, this IntentSender may be filled in with the following extras:</p>
3939 * <ul>
3940 * <li>{@link #EXTRA_INTENT} The first intent that matched the user's chosen target</li>
3941 * <li>{@link #EXTRA_ALTERNATE_INTENTS} Any additional intents that also matched the user's
3942 * chosen target beyond the first</li>
3943 * <li>{@link #EXTRA_RESULT_RECEIVER} A {@link ResultReceiver} that the refinement activity
3944 * should fill in and send once the disambiguation is complete</li>
3945 * </ul>
3946 */
3947 public static final String EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER
3948 = "android.intent.extra.CHOOSER_REFINEMENT_INTENT_SENDER";
3949
3950 /**
Kang Li9fa2a2c2017-01-06 13:33:24 -08003951 * An {@code ArrayList} of {@code String} annotations describing content for
3952 * {@link #ACTION_CHOOSER}.
3953 *
3954 * <p>If {@link #EXTRA_CONTENT_ANNOTATIONS} is present in an intent used to start a
3955 * {@link #ACTION_CHOOSER} activity, the first three annotations will be used to rank apps.</p>
3956 *
3957 * <p>Annotations should describe the major components or topics of the content. It is up to
3958 * apps initiating {@link #ACTION_CHOOSER} to learn and add annotations. Annotations should be
3959 * learned in advance, e.g., when creating or saving content, to avoid increasing latency to
3960 * start {@link #ACTION_CHOOSER}. Performance on customized annotations can suffer, if they are
3961 * rarely used for {@link #ACTION_CHOOSER} in the past 14 days. Therefore, it is recommended to
3962 * use the following annotations when applicable:</p>
3963 * <ul>
3964 * <li>"product": represents that the topic of the content is mainly about products, e.g.,
3965 * health & beauty, and office supplies.</li>
3966 * <li>"emotion": represents that the topic of the content is mainly about emotions, e.g.,
3967 * happy, and sad.</li>
3968 * <li>"person": represents that the topic of the content is mainly about persons, e.g.,
3969 * face, finger, standing, and walking.</li>
3970 * <li>"child": represents that the topic of the content is mainly about children, e.g.,
3971 * child, and baby.</li>
3972 * <li>"selfie": represents that the topic of the content is mainly about selfies.</li>
3973 * <li>"crowd": represents that the topic of the content is mainly about crowds.</li>
3974 * <li>"party": represents that the topic of the content is mainly about parties.</li>
3975 * <li>"animal": represent that the topic of the content is mainly about animals.</li>
3976 * <li>"plant": represents that the topic of the content is mainly about plants, e.g.,
3977 * flowers.</li>
3978 * <li>"vacation": represents that the topic of the content is mainly about vacations.</li>
3979 * <li>"fashion": represents that the topic of the content is mainly about fashion, e.g.
3980 * sunglasses, jewelry, handbags and clothing.</li>
3981 * <li>"material": represents that the topic of the content is mainly about materials, e.g.,
3982 * paper, and silk.</li>
3983 * <li>"vehicle": represents that the topic of the content is mainly about vehicles, like
3984 * cars, and boats.</li>
3985 * <li>"document": represents that the topic of the content is mainly about documents, e.g.
3986 * posters.</li>
3987 * <li>"design": represents that the topic of the content is mainly about design, e.g. arts
3988 * and designs of houses.</li>
3989 * <li>"holiday": represents that the topic of the content is mainly about holidays, e.g.,
3990 * Christmas and Thanksgiving.</li>
3991 * </ul>
3992 */
3993 public static final String EXTRA_CONTENT_ANNOTATIONS
3994 = "android.intent.extra.CONTENT_ANNOTATIONS";
3995
3996 /**
Adam Powell2ed547e2015-04-29 18:45:04 -07003997 * A {@link ResultReceiver} used to return data back to the sender.
3998 *
3999 * <p>Used to complete an app-specific
4000 * {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER refinement} for {@link #ACTION_CHOOSER}.</p>
4001 *
4002 * <p>If {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER} is present in the intent
4003 * used to start a {@link #ACTION_CHOOSER} activity this extra will be
4004 * {@link #fillIn(Intent, int) filled in} to that {@link IntentSender} and sent
4005 * when the user selects a target component from the chooser. It is up to the recipient
4006 * to send a result to this ResultReceiver to signal that disambiguation is complete
4007 * and that the chooser should invoke the user's choice.</p>
4008 *
4009 * <p>The disambiguator should provide a Bundle to the ResultReceiver with an intent
4010 * assigned to the key {@link #EXTRA_INTENT}. This supplied intent will be used by the chooser
4011 * to match and fill in the final Intent or ChooserTarget before starting it.
4012 * The supplied intent must {@link #filterEquals(Intent) match} one of the intents from
4013 * {@link #EXTRA_INTENT} or {@link #EXTRA_ALTERNATE_INTENTS} passed to
4014 * {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER} to be accepted.</p>
4015 *
4016 * <p>The result code passed to the ResultReceiver should be
4017 * {@link android.app.Activity#RESULT_OK} if the refinement succeeded and the supplied intent's
4018 * target in the chooser should be started, or {@link android.app.Activity#RESULT_CANCELED} if
4019 * the chooser should finish without starting a target.</p>
4020 */
4021 public static final String EXTRA_RESULT_RECEIVER
4022 = "android.intent.extra.RESULT_RECEIVER";
4023
4024 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004025 * A CharSequence dialog title to provide to the user when used with a
Jim Miller4d64746d2014-08-13 21:08:41 +00004026 * {@link #ACTION_CHOOSER}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004027 */
4028 public static final String EXTRA_TITLE = "android.intent.extra.TITLE";
4029
4030 /**
Dianne Hackborneb034652009-09-07 00:49:58 -07004031 * A Parcelable[] of {@link Intent} or
4032 * {@link android.content.pm.LabeledIntent} objects as set with
4033 * {@link #putExtra(String, Parcelable[])} of additional activities to place
4034 * a the front of the list of choices, when shown to the user with a
4035 * {@link #ACTION_CHOOSER}.
4036 */
4037 public static final String EXTRA_INITIAL_INTENTS = "android.intent.extra.INITIAL_INTENTS";
4038
4039 /**
Todd Kennedy7440f172015-12-09 14:31:22 -08004040 * A {@link IntentSender} to start after ephemeral installation success.
4041 * @hide
4042 */
Todd Kennedy7440f172015-12-09 14:31:22 -08004043 public static final String EXTRA_EPHEMERAL_SUCCESS = "android.intent.extra.EPHEMERAL_SUCCESS";
4044
4045 /**
4046 * A {@link IntentSender} to start after ephemeral installation failure.
4047 * @hide
4048 */
Todd Kennedy7440f172015-12-09 14:31:22 -08004049 public static final String EXTRA_EPHEMERAL_FAILURE = "android.intent.extra.EPHEMERAL_FAILURE";
4050
4051 /**
Todd Kennedy01ad0c72016-11-11 15:33:12 -08004052 * The host name that triggered an ephemeral resolution.
4053 * @hide
4054 */
4055 public static final String EXTRA_EPHEMERAL_HOSTNAME = "android.intent.extra.EPHEMERAL_HOSTNAME";
4056
4057 /**
4058 * An opaque token to track ephemeral resolution.
4059 * @hide
4060 */
4061 public static final String EXTRA_EPHEMERAL_TOKEN = "android.intent.extra.EPHEMERAL_TOKEN";
4062
4063 /**
Todd Kennedy316c2f22017-01-23 15:40:07 -08004064 * The version code of the app to install components from.
4065 * @hide
4066 */
4067 public static final String EXTRA_VERSION_CODE = "android.intent.extra.VERSION_CODE";
4068
4069 /**
Adam Powelle49d9392014-07-17 18:45:19 -07004070 * A Bundle forming a mapping of potential target package names to different extras Bundles
4071 * to add to the default intent extras in {@link #EXTRA_INTENT} when used with
4072 * {@link #ACTION_CHOOSER}. Each key should be a package name. The package need not
4073 * be currently installed on the device.
4074 *
4075 * <p>An application may choose to provide alternate extras for the case where a user
4076 * selects an activity from a predetermined set of target packages. If the activity
4077 * the user selects from the chooser belongs to a package with its package name as
4078 * a key in this bundle, the corresponding extras for that package will be merged with
4079 * the extras already present in the intent at {@link #EXTRA_INTENT}. If a replacement
4080 * extra has the same key as an extra already present in the intent it will overwrite
4081 * the extra from the intent.</p>
4082 *
4083 * <p><em>Examples:</em>
4084 * <ul>
4085 * <li>An application may offer different {@link #EXTRA_TEXT} to an application
4086 * when sharing with it via {@link #ACTION_SEND}, augmenting a link with additional query
4087 * parameters for that target.</li>
4088 * <li>An application may offer additional metadata for known targets of a given intent
4089 * to pass along information only relevant to that target such as account or content
4090 * identifiers already known to that application.</li>
4091 * </ul></p>
4092 */
4093 public static final String EXTRA_REPLACEMENT_EXTRAS =
4094 "android.intent.extra.REPLACEMENT_EXTRAS";
4095
4096 /**
Adam Powell0b3c1122014-10-09 12:50:14 -07004097 * An {@link IntentSender} that will be notified if a user successfully chooses a target
4098 * component to handle an action in an {@link #ACTION_CHOOSER} activity. The IntentSender
4099 * will have the extra {@link #EXTRA_CHOSEN_COMPONENT} appended to it containing the
4100 * {@link ComponentName} of the chosen component.
4101 *
4102 * <p>In some situations this callback may never come, for example if the user abandons
4103 * the chooser, switches to another task or any number of other reasons. Apps should not
4104 * be written assuming that this callback will always occur.</p>
4105 */
4106 public static final String EXTRA_CHOSEN_COMPONENT_INTENT_SENDER =
4107 "android.intent.extra.CHOSEN_COMPONENT_INTENT_SENDER";
4108
4109 /**
4110 * The {@link ComponentName} chosen by the user to complete an action.
4111 *
4112 * @see #EXTRA_CHOSEN_COMPONENT_INTENT_SENDER
4113 */
4114 public static final String EXTRA_CHOSEN_COMPONENT = "android.intent.extra.CHOSEN_COMPONENT";
4115
4116 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004117 * A {@link android.view.KeyEvent} object containing the event that
4118 * triggered the creation of the Intent it is in.
4119 */
4120 public static final String EXTRA_KEY_EVENT = "android.intent.extra.KEY_EVENT";
4121
4122 /**
Mike Lockwoodbad80e02009-07-30 01:21:08 -07004123 * Set to true in {@link #ACTION_REQUEST_SHUTDOWN} to request confirmation from the user
4124 * before shutting down.
4125 *
4126 * {@hide}
4127 */
4128 public static final String EXTRA_KEY_CONFIRM = "android.intent.extra.KEY_CONFIRM";
4129
4130 /**
Yusuke Sato705ffd12015-07-21 15:52:11 -07004131 * Set to true in {@link #ACTION_REQUEST_SHUTDOWN} to indicate that the shutdown is
4132 * requested by the user.
4133 *
4134 * {@hide}
4135 */
4136 public static final String EXTRA_USER_REQUESTED_SHUTDOWN =
4137 "android.intent.extra.USER_REQUESTED_SHUTDOWN";
4138
4139 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09004140 * 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 -07004141 * {@link android.content.Intent#ACTION_PACKAGE_CHANGED} intents to override the default action
4142 * of restarting the application.
4143 */
4144 public static final String EXTRA_DONT_KILL_APP = "android.intent.extra.DONT_KILL_APP";
4145
4146 /**
4147 * A String holding the phone number originally entered in
4148 * {@link android.content.Intent#ACTION_NEW_OUTGOING_CALL}, or the actual
4149 * number to call in a {@link android.content.Intent#ACTION_CALL}.
4150 */
4151 public static final String EXTRA_PHONE_NUMBER = "android.intent.extra.PHONE_NUMBER";
Bernd Holzheyaea4b672010-03-31 09:46:13 +02004152
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004153 /**
4154 * Used as an int extra field in {@link android.content.Intent#ACTION_UID_REMOVED}
4155 * intents to supply the uid the package had been assigned. Also an optional
4156 * extra in {@link android.content.Intent#ACTION_PACKAGE_REMOVED} or
4157 * {@link android.content.Intent#ACTION_PACKAGE_CHANGED} for the same
4158 * purpose.
4159 */
4160 public static final String EXTRA_UID = "android.intent.extra.UID";
4161
4162 /**
Dianne Hackborn21f1bd12010-02-19 17:02:21 -08004163 * @hide String array of package names.
4164 */
Soonil Nagarkar0e8fd092015-02-10 10:37:36 -08004165 @SystemApi
Dianne Hackborn21f1bd12010-02-19 17:02:21 -08004166 public static final String EXTRA_PACKAGES = "android.intent.extra.PACKAGES";
4167
4168 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004169 * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED}
4170 * intents to indicate whether this represents a full uninstall (removing
4171 * both the code and its data) or a partial uninstall (leaving its data,
4172 * implying that this is an update).
4173 */
4174 public static final String EXTRA_DATA_REMOVED = "android.intent.extra.DATA_REMOVED";
The Android Open Source Project10592532009-03-18 17:39:46 -07004175
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004176 /**
Dianne Hackbornc72fc672012-09-20 13:12:03 -07004177 * @hide
4178 * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED}
4179 * intents to indicate that at this point the package has been removed for
4180 * all users on the device.
4181 */
4182 public static final String EXTRA_REMOVED_FOR_ALL_USERS
4183 = "android.intent.extra.REMOVED_FOR_ALL_USERS";
4184
4185 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004186 * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED}
4187 * intents to indicate that this is a replacement of the package, so this
4188 * broadcast will immediately be followed by an add broadcast for a
4189 * different version of the same package.
4190 */
4191 public static final String EXTRA_REPLACING = "android.intent.extra.REPLACING";
The Android Open Source Project10592532009-03-18 17:39:46 -07004192
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004193 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004194 * Used as an int extra field in {@link android.app.AlarmManager} intents
4195 * to tell the application being invoked how many pending alarms are being
4196 * delievered with the intent. For one-shot alarms this will always be 1.
4197 * For recurring alarms, this might be greater than 1 if the device was
4198 * asleep or powered off at the time an earlier alarm would have been
4199 * delivered.
4200 */
4201 public static final String EXTRA_ALARM_COUNT = "android.intent.extra.ALARM_COUNT";
Romain Guy4969af72009-06-17 10:53:19 -07004202
Jacek Surazski86b6c532009-05-13 14:38:28 +02004203 /**
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05004204 * Used as an int extra field in {@link android.content.Intent#ACTION_DOCK_EVENT}
4205 * intents to request the dock state. Possible values are
Mike Lockwood725fcbf2009-08-24 13:09:20 -07004206 * {@link android.content.Intent#EXTRA_DOCK_STATE_UNDOCKED},
4207 * {@link android.content.Intent#EXTRA_DOCK_STATE_DESK}, or
Praveen Bharathi21e941b2010-10-06 15:23:14 -05004208 * {@link android.content.Intent#EXTRA_DOCK_STATE_CAR}, or
4209 * {@link android.content.Intent#EXTRA_DOCK_STATE_LE_DESK}, or
4210 * {@link android.content.Intent#EXTRA_DOCK_STATE_HE_DESK}.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05004211 */
4212 public static final String EXTRA_DOCK_STATE = "android.intent.extra.DOCK_STATE";
4213
4214 /**
4215 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
4216 * to represent that the phone is not in any dock.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05004217 */
4218 public static final int EXTRA_DOCK_STATE_UNDOCKED = 0;
4219
4220 /**
4221 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
4222 * to represent that the phone is in a desk dock.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05004223 */
4224 public static final int EXTRA_DOCK_STATE_DESK = 1;
4225
4226 /**
4227 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
4228 * to represent that the phone is in a car dock.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05004229 */
4230 public static final int EXTRA_DOCK_STATE_CAR = 2;
4231
4232 /**
Praveen Bharathi21e941b2010-10-06 15:23:14 -05004233 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
4234 * to represent that the phone is in a analog (low end) dock.
4235 */
4236 public static final int EXTRA_DOCK_STATE_LE_DESK = 3;
4237
4238 /**
4239 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
4240 * to represent that the phone is in a digital (high end) dock.
4241 */
4242 public static final int EXTRA_DOCK_STATE_HE_DESK = 4;
4243
4244 /**
Dianne Hackborn9bfb7072009-09-22 11:37:40 -07004245 * Boolean that can be supplied as meta-data with a dock activity, to
4246 * indicate that the dock should take over the home key when it is active.
4247 */
4248 public static final String METADATA_DOCK_HOME = "android.dock_home";
Tom Taylord4a47292009-12-21 13:59:18 -08004249
Dianne Hackborn9bfb7072009-09-22 11:37:40 -07004250 /**
Jacek Surazski86b6c532009-05-13 14:38:28 +02004251 * Used as a parcelable extra field in {@link #ACTION_APP_ERROR}, containing
4252 * the bug report.
Jacek Surazski86b6c532009-05-13 14:38:28 +02004253 */
4254 public static final String EXTRA_BUG_REPORT = "android.intent.extra.BUG_REPORT";
4255
4256 /**
Wei Huang97ecc9c2009-05-11 17:44:20 -07004257 * Used in the extra field in the remote intent. It's astring token passed with the
4258 * remote intent.
4259 */
4260 public static final String EXTRA_REMOTE_INTENT_TOKEN =
4261 "android.intent.extra.remote_intent_token";
4262
Suchi Amalapurapu0214e942009-09-02 11:03:18 -07004263 /**
Dianne Hackborn1d62ea92009-11-17 12:49:50 -08004264 * @deprecated See {@link #EXTRA_CHANGED_COMPONENT_NAME_LIST}; this field
Dianne Hackborn86a72da2009-11-11 20:12:41 -08004265 * will contain only the first name in the list.
Suchi Amalapurapu0214e942009-09-02 11:03:18 -07004266 */
Dianne Hackborn1d62ea92009-11-17 12:49:50 -08004267 @Deprecated public static final String EXTRA_CHANGED_COMPONENT_NAME =
Suchi Amalapurapu0214e942009-09-02 11:03:18 -07004268 "android.intent.extra.changed_component_name";
4269
Dianne Hackborndd9b82c2009-09-03 00:18:47 -07004270 /**
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08004271 * This field is part of {@link android.content.Intent#ACTION_PACKAGE_CHANGED},
Dianne Hackbornfd7aded2013-01-22 17:10:23 -08004272 * and contains a string array of all of the components that have changed. If
4273 * the state of the overall package has changed, then it will contain an entry
4274 * with the package name itself.
Dianne Hackborn86a72da2009-11-11 20:12:41 -08004275 */
4276 public static final String EXTRA_CHANGED_COMPONENT_NAME_LIST =
4277 "android.intent.extra.changed_component_name_list";
4278
4279 /**
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08004280 * This field is part of
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08004281 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_AVAILABLE},
Andrei Stingaceanu69d5ebc2016-01-14 12:59:03 +00004282 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE},
4283 * {@link android.content.Intent#ACTION_PACKAGES_SUSPENDED},
4284 * {@link android.content.Intent#ACTION_PACKAGES_UNSUSPENDED}
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08004285 * and contains a string array of all of the components that have changed.
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08004286 */
4287 public static final String EXTRA_CHANGED_PACKAGE_LIST =
4288 "android.intent.extra.changed_package_list";
4289
4290 /**
4291 * This field is part of
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08004292 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_AVAILABLE},
4293 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE}
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08004294 * and contains an integer array of uids of all of the components
4295 * that have changed.
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08004296 */
4297 public static final String EXTRA_CHANGED_UID_LIST =
4298 "android.intent.extra.changed_uid_list";
4299
4300 /**
Dianne Hackborndd9b82c2009-09-03 00:18:47 -07004301 * @hide
4302 * Magic extra system code can use when binding, to give a label for
4303 * who it is that has bound to a service. This is an integer giving
4304 * a framework string resource that can be displayed to the user.
4305 */
4306 public static final String EXTRA_CLIENT_LABEL =
4307 "android.intent.extra.client_label";
4308
4309 /**
4310 * @hide
4311 * Magic extra system code can use when binding, to give a PendingIntent object
4312 * that can be launched for the user to disable the system's use of this
4313 * service.
4314 */
4315 public static final String EXTRA_CLIENT_INTENT =
4316 "android.intent.extra.client_intent";
4317
Dianne Hackbornc4d0e6f2011-01-25 14:55:06 -08004318 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004319 * Extra used to indicate that an intent should only return data that is on
4320 * the local device. This is a boolean extra; the default is false. If true,
4321 * an implementation should only allow the user to select data that is
4322 * already on the device, not requiring it be downloaded from a remote
4323 * service when opened.
4324 *
4325 * @see #ACTION_GET_CONTENT
4326 * @see #ACTION_OPEN_DOCUMENT
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07004327 * @see #ACTION_OPEN_DOCUMENT_TREE
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004328 * @see #ACTION_CREATE_DOCUMENT
Dianne Hackbornc4d0e6f2011-01-25 14:55:06 -08004329 */
4330 public static final String EXTRA_LOCAL_ONLY =
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004331 "android.intent.extra.LOCAL_ONLY";
Daniel Lehmanna5b58df2011-10-12 16:24:22 -07004332
Amith Yamasani13593602012-03-22 16:16:17 -07004333 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004334 * Extra used to indicate that an intent can allow the user to select and
4335 * return multiple items. This is a boolean extra; the default is false. If
4336 * true, an implementation is allowed to present the user with a UI where
4337 * they can pick multiple items that are all returned to the caller. When
4338 * this happens, they should be returned as the {@link #getClipData()} part
4339 * of the result Intent.
4340 *
4341 * @see #ACTION_GET_CONTENT
4342 * @see #ACTION_OPEN_DOCUMENT
Dianne Hackbornfdb3f092013-01-28 15:10:48 -08004343 */
4344 public static final String EXTRA_ALLOW_MULTIPLE =
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004345 "android.intent.extra.ALLOW_MULTIPLE";
Dianne Hackbornfdb3f092013-01-28 15:10:48 -08004346
4347 /**
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01004348 * The integer userHandle carried with broadcast intents related to addition, removal and
4349 * switching of users and managed profiles - {@link #ACTION_USER_ADDED},
4350 * {@link #ACTION_USER_REMOVED} and {@link #ACTION_USER_SWITCHED}.
4351 *
Amith Yamasani13593602012-03-22 16:16:17 -07004352 * @hide
4353 */
Amith Yamasani2a003292012-08-14 18:25:45 -07004354 public static final String EXTRA_USER_HANDLE =
4355 "android.intent.extra.user_handle";
Jean-Michel Trivi3114ce32012-06-11 15:03:52 -07004356
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08004357 /**
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01004358 * The UserHandle carried with broadcasts intents related to addition and removal of managed
4359 * profiles - {@link #ACTION_MANAGED_PROFILE_ADDED} and {@link #ACTION_MANAGED_PROFILE_REMOVED}.
4360 */
4361 public static final String EXTRA_USER =
Alexandra Gherghina3315f6b2014-09-05 15:48:06 +01004362 "android.intent.extra.USER";
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01004363
4364 /**
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08004365 * Extra used in the response from a BroadcastReceiver that handles
Amith Yamasani7e99bc02013-04-16 18:24:51 -07004366 * {@link #ACTION_GET_RESTRICTION_ENTRIES}. The type of the extra is
4367 * <code>ArrayList&lt;RestrictionEntry&gt;</code>.
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08004368 */
Amith Yamasani7e99bc02013-04-16 18:24:51 -07004369 public static final String EXTRA_RESTRICTIONS_LIST = "android.intent.extra.restrictions_list";
4370
4371 /**
4372 * Extra sent in the intent to the BroadcastReceiver that handles
4373 * {@link #ACTION_GET_RESTRICTION_ENTRIES}. The type of the extra is a Bundle containing
4374 * the restrictions as key/value pairs.
4375 */
4376 public static final String EXTRA_RESTRICTIONS_BUNDLE =
4377 "android.intent.extra.restrictions_bundle";
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08004378
Amith Yamasani86118ba2013-03-28 14:33:16 -07004379 /**
4380 * Extra used in the response from a BroadcastReceiver that handles
4381 * {@link #ACTION_GET_RESTRICTION_ENTRIES}.
4382 */
4383 public static final String EXTRA_RESTRICTIONS_INTENT =
4384 "android.intent.extra.restrictions_intent";
4385
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07004386 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004387 * Extra used to communicate a set of acceptable MIME types. The type of the
4388 * extra is {@code String[]}. Values may be a combination of concrete MIME
4389 * types (such as "image/png") and/or partial MIME types (such as
4390 * "audio/*").
4391 *
4392 * @see #ACTION_GET_CONTENT
4393 * @see #ACTION_OPEN_DOCUMENT
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07004394 */
4395 public static final String EXTRA_MIME_TYPES = "android.intent.extra.MIME_TYPES";
4396
Dianne Hackborn57a7f592013-07-22 18:21:32 -07004397 /**
4398 * Optional extra for {@link #ACTION_SHUTDOWN} that allows the sender to qualify that
4399 * this shutdown is only for the user space of the system, not a complete shutdown.
Dianne Hackbornd318e0b2013-09-03 14:34:12 -07004400 * When this is true, hardware devices can use this information to determine that
4401 * they shouldn't do a complete shutdown of their device since this is not a
4402 * complete shutdown down to the kernel, but only user space restarting.
4403 * The default if not supplied is false.
Dianne Hackborn57a7f592013-07-22 18:21:32 -07004404 */
4405 public static final String EXTRA_SHUTDOWN_USERSPACE_ONLY
4406 = "android.intent.extra.SHUTDOWN_USERSPACE_ONLY";
4407
Narayan Kamathccb2a0862013-12-19 14:49:36 +00004408 /**
Neil Fullerb7146fe2016-11-15 16:52:15 +00004409 * Optional int extra for {@link #ACTION_TIME_CHANGED} that indicates the
4410 * user has set their time format preference. See {@link #EXTRA_TIME_PREF_VALUE_USE_12_HOUR},
4411 * {@link #EXTRA_TIME_PREF_VALUE_USE_24_HOUR} and
4412 * {@link #EXTRA_TIME_PREF_VALUE_USE_LOCALE_DEFAULT}. The value must not be negative.
Narayan Kamathccb2a0862013-12-19 14:49:36 +00004413 *
4414 * @hide for internal use only.
4415 */
4416 public static final String EXTRA_TIME_PREF_24_HOUR_FORMAT =
4417 "android.intent.extra.TIME_PREF_24_HOUR_FORMAT";
Neil Fullerb7146fe2016-11-15 16:52:15 +00004418 /** @hide */
4419 public static final int EXTRA_TIME_PREF_VALUE_USE_12_HOUR = 0;
4420 /** @hide */
4421 public static final int EXTRA_TIME_PREF_VALUE_USE_24_HOUR = 1;
4422 /** @hide */
4423 public static final int EXTRA_TIME_PREF_VALUE_USE_LOCALE_DEFAULT = 2;
Narayan Kamathccb2a0862013-12-19 14:49:36 +00004424
Jeff Sharkey004a4b22014-09-24 11:45:24 -07004425 /** {@hide} */
4426 public static final String EXTRA_REASON = "android.intent.extra.REASON";
4427
Rubin Xue8490f12015-06-25 12:17:48 +01004428 /** {@hide} */
4429 public static final String EXTRA_WIPE_EXTERNAL_STORAGE = "android.intent.extra.WIPE_EXTERNAL_STORAGE";
4430
Santos Cordon15a13782015-03-31 18:32:31 -07004431 /**
4432 * Optional {@link android.app.PendingIntent} extra used to deliver the result of the SIM
4433 * activation request.
4434 * TODO: Add information about the structure and response data used with the pending intent.
4435 * @hide
4436 */
4437 public static final String EXTRA_SIM_ACTIVATION_RESPONSE =
4438 "android.intent.extra.SIM_ACTIVATION_RESPONSE";
4439
Tomasz Mikolajewski319fb492016-01-20 12:24:01 +09004440 /**
4441 * Optional index with semantics depending on the intent action.
Tomasz Mikolajewskife023132016-03-10 17:42:35 +09004442 *
4443 * <p>The value must be an integer greater or equal to 0.
Tomasz Mikolajewski867addf2017-02-01 14:16:39 +09004444 * @see ACTION_QUICK_VIEW
Tomasz Mikolajewski319fb492016-01-20 12:24:01 +09004445 */
Steve McKay6eaf38632015-08-04 10:11:01 -07004446 public static final String EXTRA_INDEX = "android.intent.extra.INDEX";
4447
Rubin Xu0a29ecd2015-11-04 15:11:48 +00004448 /**
Tomasz Mikolajewski17c50da2017-02-16 14:38:04 +09004449 * Tells the quick viewer to show additional UI actions suitable for the passed Uris,
4450 * such as opening in other apps, sharing, opening, editing, printing, deleting,
4451 * casting, etc.
Tomasz Mikolajewski867addf2017-02-01 14:16:39 +09004452 *
4453 * <p>The value is boolean. By default false.
4454 * @see ACTION_QUICK_VIEW
4455 */
Tomasz Mikolajewski17c50da2017-02-16 14:38:04 +09004456 public static final String EXTRA_QUICK_VIEW_ADVANCED =
4457 "android.intent.extra.QUICK_VIEW_ADVANCED";
Tomasz Mikolajewski867addf2017-02-01 14:16:39 +09004458
4459 /**
Rubin Xu0a29ecd2015-11-04 15:11:48 +00004460 * Optional boolean extra indicating whether quiet mode has been switched on or off.
Rubin Xue95057a2016-04-01 16:49:25 +01004461 * When a profile goes into quiet mode, all apps in the profile are killed and the
4462 * profile user is stopped. Widgets originating from the profile are masked, and app
4463 * launcher icons are grayed out.
Rubin Xu0a29ecd2015-11-04 15:11:48 +00004464 */
4465 public static final String EXTRA_QUIET_MODE = "android.intent.extra.QUIET_MODE";
Dongwon Kang2034a4c2015-12-14 21:57:34 +09004466
4467 /**
Dongwon Kang32cb9ab2016-01-13 18:11:10 -08004468 * Used as an int extra field in {@link #ACTION_MEDIA_RESOURCE_GRANTED}
Dongwon Kang2034a4c2015-12-14 21:57:34 +09004469 * intents to specify the resource type granted. Possible values are
Dongwon Kang32cb9ab2016-01-13 18:11:10 -08004470 * {@link #EXTRA_MEDIA_RESOURCE_TYPE_VIDEO_CODEC} or
4471 * {@link #EXTRA_MEDIA_RESOURCE_TYPE_AUDIO_CODEC}.
Dongwon Kang2034a4c2015-12-14 21:57:34 +09004472 *
4473 * @hide
4474 */
4475 public static final String EXTRA_MEDIA_RESOURCE_TYPE =
4476 "android.intent.extra.MEDIA_RESOURCE_TYPE";
4477
4478 /**
Ben Lin145b0ca2016-10-14 14:23:40 -07004479 * Used as a boolean extra field in {@link #ACTION_CHOOSER} intents to specify
4480 * whether to show the chooser or not when there is only one application available
4481 * to choose from.
4482 *
4483 * @hide
4484 */
4485 public static final String EXTRA_AUTO_LAUNCH_SINGLE_CHOICE =
4486 "android.intent.extra.AUTO_LAUNCH_SINGLE_CHOICE";
4487
4488 /**
Dongwon Kang32cb9ab2016-01-13 18:11:10 -08004489 * Used as an int value for {@link #EXTRA_MEDIA_RESOURCE_TYPE}
Dongwon Kang2034a4c2015-12-14 21:57:34 +09004490 * to represent that a video codec is allowed to use.
4491 *
4492 * @hide
4493 */
4494 public static final int EXTRA_MEDIA_RESOURCE_TYPE_VIDEO_CODEC = 0;
4495
4496 /**
Dongwon Kang32cb9ab2016-01-13 18:11:10 -08004497 * Used as an int value for {@link #EXTRA_MEDIA_RESOURCE_TYPE}
Dongwon Kang2034a4c2015-12-14 21:57:34 +09004498 * to represent that a audio codec is allowed to use.
4499 *
4500 * @hide
4501 */
4502 public static final int EXTRA_MEDIA_RESOURCE_TYPE_AUDIO_CODEC = 1;
4503
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004504 // ---------------------------------------------------------------------
4505 // ---------------------------------------------------------------------
4506 // Intent flags (see mFlags variable).
4507
Tor Norbyed9273d62013-05-30 15:59:53 -07004508 /** @hide */
Jeff Sharkey846318a2014-04-04 12:12:41 -07004509 @IntDef(flag = true, value = {
4510 FLAG_GRANT_READ_URI_PERMISSION, FLAG_GRANT_WRITE_URI_PERMISSION,
4511 FLAG_GRANT_PERSISTABLE_URI_PERMISSION, FLAG_GRANT_PREFIX_URI_PERMISSION })
Tor Norbyed9273d62013-05-30 15:59:53 -07004512 @Retention(RetentionPolicy.SOURCE)
4513 public @interface GrantUriMode {}
4514
Jeff Sharkey846318a2014-04-04 12:12:41 -07004515 /** @hide */
4516 @IntDef(flag = true, value = {
4517 FLAG_GRANT_READ_URI_PERMISSION, FLAG_GRANT_WRITE_URI_PERMISSION })
4518 @Retention(RetentionPolicy.SOURCE)
4519 public @interface AccessUriMode {}
4520
4521 /**
4522 * Test if given mode flags specify an access mode, which must be at least
4523 * read and/or write.
4524 *
4525 * @hide
4526 */
4527 public static boolean isAccessUriMode(int modeFlags) {
4528 return (modeFlags & (Intent.FLAG_GRANT_READ_URI_PERMISSION
4529 | Intent.FLAG_GRANT_WRITE_URI_PERMISSION)) != 0;
4530 }
4531
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004532 /**
4533 * If set, the recipient of this Intent will be granted permission to
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004534 * perform read operations on the URI in the Intent's data and any URIs
Dianne Hackborn21c241e2012-03-08 13:57:23 -08004535 * specified in its ClipData. When applying to an Intent's ClipData,
4536 * all URIs as well as recursive traversals through data or other ClipData
4537 * in Intent items will be granted; only the grant flags of the top-level
4538 * Intent are used.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004539 */
4540 public static final int FLAG_GRANT_READ_URI_PERMISSION = 0x00000001;
4541 /**
4542 * If set, the recipient of this Intent will be granted permission to
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004543 * perform write operations on the URI in the Intent's data and any URIs
Dianne Hackborn21c241e2012-03-08 13:57:23 -08004544 * specified in its ClipData. When applying to an Intent's ClipData,
4545 * all URIs as well as recursive traversals through data or other ClipData
4546 * in Intent items will be granted; only the grant flags of the top-level
4547 * Intent are used.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004548 */
4549 public static final int FLAG_GRANT_WRITE_URI_PERMISSION = 0x00000002;
4550 /**
4551 * Can be set by the caller to indicate that this Intent is coming from
4552 * a background operation, not from direct user interaction.
4553 */
4554 public static final int FLAG_FROM_BACKGROUND = 0x00000004;
4555 /**
4556 * A flag you can enable for debugging: when set, log messages will be
4557 * printed during the resolution of this intent to show you what has
4558 * been found to create the final resolved list.
4559 */
4560 public static final int FLAG_DEBUG_LOG_RESOLUTION = 0x00000008;
Dianne Hackborne7f97212011-02-24 14:40:20 -08004561 /**
4562 * If set, this intent will not match any components in packages that
4563 * are currently stopped. If this is not set, then the default behavior
4564 * is to include such applications in the result.
4565 */
4566 public static final int FLAG_EXCLUDE_STOPPED_PACKAGES = 0x00000010;
4567 /**
4568 * If set, this intent will always match any components in packages that
4569 * are currently stopped. This is the default behavior when
4570 * {@link #FLAG_EXCLUDE_STOPPED_PACKAGES} is not set. If both of these
4571 * flags are set, this one wins (it allows overriding of exclude for
4572 * places where the framework may automatically set the exclude flag).
4573 */
4574 public static final int FLAG_INCLUDE_STOPPED_PACKAGES = 0x00000020;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004575
4576 /**
Jeff Sharkey328ebf22013-03-21 18:09:39 -07004577 * When combined with {@link #FLAG_GRANT_READ_URI_PERMISSION} and/or
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004578 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, the URI permission grant can be
Jeff Sharkeye66c1772013-09-20 14:30:59 -07004579 * persisted across device reboots until explicitly revoked with
4580 * {@link Context#revokeUriPermission(Uri, int)}. This flag only offers the
4581 * grant for possible persisting; the receiving application must call
4582 * {@link ContentResolver#takePersistableUriPermission(Uri, int)} to
4583 * actually persist.
4584 *
4585 * @see ContentResolver#takePersistableUriPermission(Uri, int)
4586 * @see ContentResolver#releasePersistableUriPermission(Uri, int)
4587 * @see ContentResolver#getPersistedUriPermissions()
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004588 * @see ContentResolver#getOutgoingPersistedUriPermissions()
Jeff Sharkey328ebf22013-03-21 18:09:39 -07004589 */
Jeff Sharkeye66c1772013-09-20 14:30:59 -07004590 public static final int FLAG_GRANT_PERSISTABLE_URI_PERMISSION = 0x00000040;
Jeff Sharkey328ebf22013-03-21 18:09:39 -07004591
4592 /**
Jeff Sharkey846318a2014-04-04 12:12:41 -07004593 * When combined with {@link #FLAG_GRANT_READ_URI_PERMISSION} and/or
4594 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, the URI permission grant
4595 * applies to any URI that is a prefix match against the original granted
4596 * URI. (Without this flag, the URI must match exactly for access to be
4597 * granted.) Another URI is considered a prefix match only when scheme,
4598 * authority, and all path segments defined by the prefix are an exact
4599 * match.
4600 */
4601 public static final int FLAG_GRANT_PREFIX_URI_PERMISSION = 0x00000080;
4602
4603 /**
Jeff Sharkey2a9e3f82015-12-18 10:57:58 -07004604 * Internal flag used to indicate that a system component has done their
Jeff Sharkey2f3e3532015-12-21 14:16:43 -07004605 * homework and verified that they correctly handle packages and components
4606 * that come and go over time. In particular:
4607 * <ul>
4608 * <li>Apps installed on external storage, which will appear to be
4609 * uninstalled while the the device is ejected.
4610 * <li>Apps with encryption unaware components, which will appear to not
4611 * exist while the device is locked.
4612 * </ul>
Jeff Sharkey2a9e3f82015-12-18 10:57:58 -07004613 *
4614 * @hide
4615 */
Jeff Sharkey2f3e3532015-12-21 14:16:43 -07004616 public static final int FLAG_DEBUG_TRIAGED_MISSING = 0x00000100;
Jeff Sharkey2a9e3f82015-12-18 10:57:58 -07004617
4618 /**
Todd Kennedy8e2d9d12016-06-28 14:09:55 -07004619 * Internal flag used to indicate ephemeral applications should not be
4620 * considered when resolving the intent.
4621 *
4622 * @hide
4623 */
4624 public static final int FLAG_IGNORE_EPHEMERAL = 0x00000200;
4625
4626 /**
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08004627 * If set, the new activity is not kept in the history stack. As soon as
4628 * the user navigates away from it, the activity is finished. This may also
4629 * be set with the {@link android.R.styleable#AndroidManifestActivity_noHistory
4630 * noHistory} attribute.
Ricardo Cervera92f6a742014-04-04 11:17:06 -07004631 *
4632 * <p>If set, {@link android.app.Activity#onActivityResult onActivityResult()}
4633 * is never invoked when the current activity starts a new activity which
4634 * sets a result and finishes.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004635 */
4636 public static final int FLAG_ACTIVITY_NO_HISTORY = 0x40000000;
4637 /**
4638 * If set, the activity will not be launched if it is already running
4639 * at the top of the history stack.
4640 */
4641 public static final int FLAG_ACTIVITY_SINGLE_TOP = 0x20000000;
4642 /**
4643 * If set, this activity will become the start of a new task on this
4644 * history stack. A task (from the activity that started it to the
4645 * next task activity) defines an atomic group of activities that the
4646 * user can move to. Tasks can be moved to the foreground and background;
4647 * all of the activities inside of a particular task always remain in
The Android Open Source Project10592532009-03-18 17:39:46 -07004648 * the same order. See
Scott Main7aee61f2011-02-08 11:25:01 -08004649 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
4650 * Stack</a> for more information about tasks.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004651 *
4652 * <p>This flag is generally used by activities that want
4653 * to present a "launcher" style behavior: they give the user a list of
4654 * separate things that can be done, which otherwise run completely
4655 * independently of the activity launching them.
4656 *
4657 * <p>When using this flag, if a task is already running for the activity
4658 * you are now starting, then a new activity will not be started; instead,
4659 * the current task will simply be brought to the front of the screen with
4660 * the state it was last in. See {@link #FLAG_ACTIVITY_MULTIPLE_TASK} for a flag
4661 * to disable this behavior.
4662 *
4663 * <p>This flag can not be used when the caller is requesting a result from
4664 * the activity being launched.
4665 */
4666 public static final int FLAG_ACTIVITY_NEW_TASK = 0x10000000;
4667 /**
Craig Mautnerd00f4742014-03-12 14:17:26 -07004668 * This flag is used to create a new task and launch an activity into it.
4669 * This flag is always paired with either {@link #FLAG_ACTIVITY_NEW_DOCUMENT}
4670 * or {@link #FLAG_ACTIVITY_NEW_TASK}. In both cases these flags alone would
4671 * search through existing tasks for ones matching this Intent. Only if no such
4672 * task is found would a new task be created. When paired with
4673 * FLAG_ACTIVITY_MULTIPLE_TASK both of these behaviors are modified to skip
4674 * the search for a matching task and unconditionally start a new task.
4675 *
4676 * <strong>When used with {@link #FLAG_ACTIVITY_NEW_TASK} do not use this
4677 * flag unless you are implementing your own
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004678 * top-level application launcher.</strong> Used in conjunction with
4679 * {@link #FLAG_ACTIVITY_NEW_TASK} to disable the
4680 * behavior of bringing an existing task to the foreground. When set,
4681 * a new task is <em>always</em> started to host the Activity for the
4682 * Intent, regardless of whether there is already an existing task running
4683 * the same thing.
4684 *
4685 * <p><strong>Because the default system does not include graphical task management,
4686 * you should not use this flag unless you provide some way for a user to
4687 * return back to the tasks you have launched.</strong>
The Android Open Source Project10592532009-03-18 17:39:46 -07004688 *
Craig Mautnerd00f4742014-03-12 14:17:26 -07004689 * See {@link #FLAG_ACTIVITY_NEW_DOCUMENT} for details of this flag's use for
4690 * creating new document tasks.
4691 *
4692 * <p>This flag is ignored if one of {@link #FLAG_ACTIVITY_NEW_TASK} or
Paul Soulos628cb742014-09-19 11:00:52 -07004693 * {@link #FLAG_ACTIVITY_NEW_DOCUMENT} is not also set.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004694 *
Scott Main7aee61f2011-02-08 11:25:01 -08004695 * <p>See
4696 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
4697 * Stack</a> for more information about tasks.
Craig Mautnerd00f4742014-03-12 14:17:26 -07004698 *
4699 * @see #FLAG_ACTIVITY_NEW_DOCUMENT
4700 * @see #FLAG_ACTIVITY_NEW_TASK
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004701 */
4702 public static final int FLAG_ACTIVITY_MULTIPLE_TASK = 0x08000000;
4703 /**
4704 * If set, and the activity being launched is already running in the
4705 * current task, then instead of launching a new instance of that activity,
4706 * all of the other activities on top of it will be closed and this Intent
4707 * will be delivered to the (now on top) old activity as a new Intent.
4708 *
4709 * <p>For example, consider a task consisting of the activities: A, B, C, D.
4710 * If D calls startActivity() with an Intent that resolves to the component
4711 * of activity B, then C and D will be finished and B receive the given
4712 * Intent, resulting in the stack now being: A, B.
4713 *
Dianne Hackbornaa52f9a2009-08-25 16:01:15 -07004714 * <p>The currently running instance of activity B in the above example will
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004715 * either receive the new intent you are starting here in its
4716 * onNewIntent() method, or be itself finished and restarted with the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004717 * new intent. If it has declared its launch mode to be "multiple" (the
Dianne Hackbornaa52f9a2009-08-25 16:01:15 -07004718 * default) and you have not set {@link #FLAG_ACTIVITY_SINGLE_TOP} in
4719 * the same intent, then it will be finished and re-created; for all other
4720 * launch modes or if {@link #FLAG_ACTIVITY_SINGLE_TOP} is set then this
4721 * Intent will be delivered to the current instance's onNewIntent().
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004722 *
4723 * <p>This launch mode can also be used to good effect in conjunction with
4724 * {@link #FLAG_ACTIVITY_NEW_TASK}: if used to start the root activity
4725 * of a task, it will bring any currently running instance of that task
4726 * to the foreground, and then clear it to its root state. This is
4727 * especially useful, for example, when launching an activity from the
4728 * notification manager.
4729 *
Scott Main7aee61f2011-02-08 11:25:01 -08004730 * <p>See
4731 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
4732 * Stack</a> for more information about tasks.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004733 */
4734 public static final int FLAG_ACTIVITY_CLEAR_TOP = 0x04000000;
4735 /**
4736 * If set and this intent is being used to launch a new activity from an
4737 * existing one, then the reply target of the existing activity will be
4738 * transfered to the new activity. This way the new activity can call
4739 * {@link android.app.Activity#setResult} and have that result sent back to
4740 * the reply target of the original activity.
4741 */
4742 public static final int FLAG_ACTIVITY_FORWARD_RESULT = 0x02000000;
4743 /**
4744 * If set and this intent is being used to launch a new activity from an
4745 * existing one, the current activity will not be counted as the top
4746 * activity for deciding whether the new intent should be delivered to
4747 * the top instead of starting a new one. The previous activity will
4748 * be used as the top, with the assumption being that the current activity
4749 * will finish itself immediately.
4750 */
4751 public static final int FLAG_ACTIVITY_PREVIOUS_IS_TOP = 0x01000000;
4752 /**
4753 * If set, the new activity is not kept in the list of recently launched
4754 * activities.
4755 */
4756 public static final int FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS = 0x00800000;
4757 /**
4758 * This flag is not normally set by application code, but set for you by
4759 * the system as described in the
4760 * {@link android.R.styleable#AndroidManifestActivity_launchMode
4761 * launchMode} documentation for the singleTask mode.
4762 */
4763 public static final int FLAG_ACTIVITY_BROUGHT_TO_FRONT = 0x00400000;
4764 /**
4765 * If set, and this activity is either being started in a new task or
4766 * bringing to the top an existing task, then it will be launched as
4767 * the front door of the task. This will result in the application of
4768 * any affinities needed to have that task in the proper state (either
4769 * moving activities to or from it), or simply resetting that task to
4770 * its initial state if needed.
4771 */
4772 public static final int FLAG_ACTIVITY_RESET_TASK_IF_NEEDED = 0x00200000;
4773 /**
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08004774 * This flag is not normally set by application code, but set for you by
4775 * the system if this activity is being launched from history
4776 * (longpress home key).
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004777 */
4778 public static final int FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY = 0x00100000;
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08004779 /**
Craig Mautnerf357c0c2014-06-09 09:23:27 -07004780 * @deprecated As of API 21 this performs identically to
4781 * {@link #FLAG_ACTIVITY_NEW_DOCUMENT} which should be used instead of this.
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08004782 */
Aurimas Liutikas514c5ef2016-05-24 15:22:55 -07004783 @Deprecated
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08004784 public static final int FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET = 0x00080000;
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08004785 /**
Craig Mautner026596b2014-05-21 15:35:44 -07004786 * This flag is used to open a document into a new task rooted at the activity launched
4787 * by this Intent. Through the use of this flag, or its equivalent attribute,
4788 * {@link android.R.attr#documentLaunchMode} multiple instances of the same activity
Chet Haase0d1c27a2014-11-03 18:35:16 +00004789 * containing different documents will appear in the recent tasks list.
Craig Mautnerd00f4742014-03-12 14:17:26 -07004790 *
Craig Mautner026596b2014-05-21 15:35:44 -07004791 * <p>The use of the activity attribute form of this,
4792 * {@link android.R.attr#documentLaunchMode}, is
4793 * preferred over the Intent flag described here. The attribute form allows the
4794 * Activity to specify multiple document behavior for all launchers of the Activity
4795 * whereas using this flag requires each Intent that launches the Activity to specify it.
Craig Mautnerd00f4742014-03-12 14:17:26 -07004796 *
Dianne Hackborn13420f22014-07-18 15:43:56 -07004797 * <p>Note that the default semantics of this flag w.r.t. whether the recents entry for
4798 * it is kept after the activity is finished is different than the use of
4799 * {@link #FLAG_ACTIVITY_NEW_TASK} and {@link android.R.attr#documentLaunchMode} -- if
4800 * this flag is being used to create a new recents entry, then by default that entry
4801 * will be removed once the activity is finished. You can modify this behavior with
4802 * {@link #FLAG_ACTIVITY_RETAIN_IN_RECENTS}.
4803 *
Craig Mautner026596b2014-05-21 15:35:44 -07004804 * <p>FLAG_ACTIVITY_NEW_DOCUMENT may be used in conjunction with {@link
4805 * #FLAG_ACTIVITY_MULTIPLE_TASK}. When used alone it is the
4806 * equivalent of the Activity manifest specifying {@link
4807 * android.R.attr#documentLaunchMode}="intoExisting". When used with
4808 * FLAG_ACTIVITY_MULTIPLE_TASK it is the equivalent of the Activity manifest specifying
4809 * {@link android.R.attr#documentLaunchMode}="always".
Craig Mautnerd00f4742014-03-12 14:17:26 -07004810 *
Craig Mautner026596b2014-05-21 15:35:44 -07004811 * Refer to {@link android.R.attr#documentLaunchMode} for more information.
Craig Mautnerd00f4742014-03-12 14:17:26 -07004812 *
Craig Mautner026596b2014-05-21 15:35:44 -07004813 * @see android.R.attr#documentLaunchMode
Craig Mautnerd00f4742014-03-12 14:17:26 -07004814 * @see #FLAG_ACTIVITY_MULTIPLE_TASK
4815 */
Craig Mautnerf357c0c2014-06-09 09:23:27 -07004816 public static final int FLAG_ACTIVITY_NEW_DOCUMENT = FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET;
Craig Mautnerd00f4742014-03-12 14:17:26 -07004817 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004818 * If set, this flag will prevent the normal {@link android.app.Activity#onUserLeaveHint}
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08004819 * callback from occurring on the current frontmost activity before it is
4820 * paused as the newly-started activity is brought to the front.
The Android Open Source Project10592532009-03-18 17:39:46 -07004821 *
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08004822 * <p>Typically, an activity can rely on that callback to indicate that an
4823 * explicit user action has caused their activity to be moved out of the
4824 * foreground. The callback marks an appropriate point in the activity's
4825 * lifecycle for it to dismiss any notifications that it intends to display
4826 * "until the user has seen them," such as a blinking LED.
The Android Open Source Project10592532009-03-18 17:39:46 -07004827 *
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08004828 * <p>If an activity is ever started via any non-user-driven events such as
4829 * phone-call receipt or an alarm handler, this flag should be passed to {@link
4830 * Context#startActivity Context.startActivity}, ensuring that the pausing
The Android Open Source Project10592532009-03-18 17:39:46 -07004831 * activity does not think the user has acknowledged its notification.
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08004832 */
4833 public static final int FLAG_ACTIVITY_NO_USER_ACTION = 0x00040000;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004834 /**
4835 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
4836 * this flag will cause the launched activity to be brought to the front of its
4837 * task's history stack if it is already running.
The Android Open Source Project10592532009-03-18 17:39:46 -07004838 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004839 * <p>For example, consider a task consisting of four activities: A, B, C, D.
4840 * If D calls startActivity() with an Intent that resolves to the component
4841 * of activity B, then B will be brought to the front of the history stack,
4842 * with this resulting order: A, C, D, B.
The Android Open Source Project10592532009-03-18 17:39:46 -07004843 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004844 * This flag will be ignored if {@link #FLAG_ACTIVITY_CLEAR_TOP} is also
The Android Open Source Project10592532009-03-18 17:39:46 -07004845 * specified.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004846 */
4847 public static final int FLAG_ACTIVITY_REORDER_TO_FRONT = 0X00020000;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004848 /**
Dianne Hackbornbfe319e2009-09-21 00:34:05 -07004849 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
4850 * this flag will prevent the system from applying an activity transition
4851 * animation to go to the next activity state. This doesn't mean an
4852 * animation will never run -- if another activity change happens that doesn't
4853 * specify this flag before the activity started here is displayed, then
Dianne Hackborn621e17d2010-11-22 15:59:56 -08004854 * that transition will be used. This flag can be put to good use
Dianne Hackbornbfe319e2009-09-21 00:34:05 -07004855 * when you are going to do a series of activity operations but the
4856 * animation seen by the user shouldn't be driven by the first activity
4857 * change but rather a later one.
4858 */
4859 public static final int FLAG_ACTIVITY_NO_ANIMATION = 0X00010000;
4860 /**
Dianne Hackborn621e17d2010-11-22 15:59:56 -08004861 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
4862 * this flag will cause any existing task that would be associated with the
4863 * activity to be cleared before the activity is started. That is, the activity
4864 * becomes the new root of an otherwise empty task, and any old activities
4865 * are finished. This can only be used in conjunction with {@link #FLAG_ACTIVITY_NEW_TASK}.
4866 */
4867 public static final int FLAG_ACTIVITY_CLEAR_TASK = 0X00008000;
4868 /**
4869 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
4870 * this flag will cause a newly launching task to be placed on top of the current
4871 * home activity task (if there is one). That is, pressing back from the task
4872 * will always return the user to home even if that was not the last activity they
4873 * saw. This can only be used in conjunction with {@link #FLAG_ACTIVITY_NEW_TASK}.
4874 */
4875 public static final int FLAG_ACTIVITY_TASK_ON_HOME = 0X00004000;
4876 /**
Dianne Hackborn13420f22014-07-18 15:43:56 -07004877 * By default a document created by {@link #FLAG_ACTIVITY_NEW_DOCUMENT} will
4878 * have its entry in recent tasks removed when the user closes it (with back
Jeff Sharkey9f991a22014-08-13 11:37:41 -07004879 * or however else it may finish()). If you would like to instead allow the
Dianne Hackborn13420f22014-07-18 15:43:56 -07004880 * document to be kept in recents so that it can be re-launched, you can use
Jeff Sharkey9f991a22014-08-13 11:37:41 -07004881 * this flag. When set and the task's activity is finished, the recents
4882 * entry will remain in the interface for the user to re-launch it, like a
4883 * recents entry for a top-level application.
4884 * <p>
4885 * The receiving activity can override this request with
4886 * {@link android.R.attr#autoRemoveFromRecents} or by explcitly calling
4887 * {@link android.app.Activity#finishAndRemoveTask()
Dianne Hackborn13420f22014-07-18 15:43:56 -07004888 * Activity.finishAndRemoveTask()}.
Craig Mautner2dac0562014-05-06 09:06:44 -07004889 */
Dianne Hackborn13420f22014-07-18 15:43:56 -07004890 public static final int FLAG_ACTIVITY_RETAIN_IN_RECENTS = 0x00002000;
Craig Mautnera228ae92014-07-09 05:44:55 -07004891
4892 /**
Wale Ogunwale2a25a622016-01-30 11:27:21 -08004893 * This flag is only used in split-screen multi-window mode. The new activity will be displayed
4894 * adjacent to the one launching it. This can only be used in conjunction with
Wale Ogunwale6bdf2572016-03-11 15:22:38 -08004895 * {@link #FLAG_ACTIVITY_NEW_TASK}. Also, setting {@link #FLAG_ACTIVITY_MULTIPLE_TASK} is
4896 * required if you want a new instance of an existing activity to be created.
Filip Gruszczynski80e29f12015-12-14 14:58:30 -08004897 */
Wale Ogunwale2a25a622016-01-30 11:27:21 -08004898 public static final int FLAG_ACTIVITY_LAUNCH_ADJACENT = 0x00001000;
Filip Gruszczynski80e29f12015-12-14 14:58:30 -08004899
4900 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004901 * If set, when sending a broadcast only registered receivers will be
4902 * called -- no BroadcastReceiver components will be launched.
4903 */
4904 public static final int FLAG_RECEIVER_REGISTERED_ONLY = 0x40000000;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004905 /**
Dianne Hackborn1c633fc2009-12-08 19:45:14 -08004906 * If set, when sending a broadcast the new broadcast will replace
4907 * any existing pending broadcast that matches it. Matching is defined
4908 * by {@link Intent#filterEquals(Intent) Intent.filterEquals} returning
4909 * true for the intents of the two broadcasts. When a match is found,
4910 * the new broadcast (and receivers associated with it) will replace the
4911 * existing one in the pending broadcast list, remaining at the same
4912 * position in the list.
Tom Taylord4a47292009-12-21 13:59:18 -08004913 *
Dianne Hackborn1c633fc2009-12-08 19:45:14 -08004914 * <p>This flag is most typically used with sticky broadcasts, which
4915 * only care about delivering the most recent values of the broadcast
4916 * to their receivers.
4917 */
4918 public static final int FLAG_RECEIVER_REPLACE_PENDING = 0x20000000;
4919 /**
Christopher Tatef46723b2012-01-26 14:19:24 -08004920 * If set, when sending a broadcast the recipient is allowed to run at
4921 * foreground priority, with a shorter timeout interval. During normal
4922 * broadcasts the receivers are not automatically hoisted out of the
4923 * background priority class.
4924 */
4925 public static final int FLAG_RECEIVER_FOREGROUND = 0x10000000;
4926 /**
Dianne Hackborn6285a322013-09-18 12:09:47 -07004927 * If this is an ordered broadcast, don't allow receivers to abort the broadcast.
4928 * They can still propagate results through to later receivers, but they can not prevent
4929 * later receivers from seeing the broadcast.
4930 */
4931 public static final int FLAG_RECEIVER_NO_ABORT = 0x08000000;
4932 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004933 * If set, when sending a broadcast <i>before boot has completed</i> only
4934 * registered receivers will be called -- no BroadcastReceiver components
4935 * will be launched. Sticky intent state will be recorded properly even
4936 * if no receivers wind up being called. If {@link #FLAG_RECEIVER_REGISTERED_ONLY}
4937 * is specified in the broadcast intent, this flag is unnecessary.
The Android Open Source Project10592532009-03-18 17:39:46 -07004938 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004939 * <p>This flag is only for use by system sevices as a convenience to
4940 * avoid having to implement a more complex mechanism around detection
4941 * of boot completion.
The Android Open Source Project10592532009-03-18 17:39:46 -07004942 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004943 * @hide
4944 */
Dianne Hackborn6285a322013-09-18 12:09:47 -07004945 public static final int FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT = 0x04000000;
Dianne Hackborn9acc0302009-08-25 00:27:12 -07004946 /**
4947 * Set when this broadcast is for a boot upgrade, a special mode that
4948 * allows the broadcast to be sent before the system is ready and launches
4949 * the app process with no providers running in it.
4950 * @hide
4951 */
Dianne Hackborn6285a322013-09-18 12:09:47 -07004952 public static final int FLAG_RECEIVER_BOOT_UPGRADE = 0x02000000;
Dianne Hackborn6ac42ae2015-12-08 17:22:10 -08004953 /**
4954 * If set, the broadcast will always go to manifest receivers in background (cached
4955 * or not running) apps, regardless of whether that would be done by default. By
4956 * default they will only receive broadcasts if the broadcast has specified an
4957 * explicit component or package name.
Christopher Tatebdc39412017-01-23 12:21:13 -08004958 *
4959 * NOTE: dumpstate uses this flag numerically, so when its value is changed
4960 * the broadcast code there must also be changed to match.
4961 *
Dianne Hackborn6ac42ae2015-12-08 17:22:10 -08004962 * @hide
4963 */
4964 public static final int FLAG_RECEIVER_INCLUDE_BACKGROUND = 0x01000000;
4965 /**
4966 * If set, the broadcast will never go to manifest receivers in background (cached
4967 * or not running) apps, regardless of whether that would be done by default. By
4968 * default they will receive broadcasts if the broadcast has specified an
4969 * explicit component or package name.
4970 * @hide
4971 */
4972 public static final int FLAG_RECEIVER_EXCLUDE_BACKGROUND = 0x00800000;
Jeff Sharkey6a34e562016-12-21 09:56:00 -07004973 /**
4974 * If set, this broadcast is being sent from the shell.
4975 * @hide
4976 */
4977 public static final int FLAG_RECEIVER_FROM_SHELL = 0x00400000;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004978
Dianne Hackbornfa82f222009-09-17 15:14:12 -07004979 /**
4980 * @hide Flags that can't be changed with PendingIntent.
4981 */
Jeff Sharkey846318a2014-04-04 12:12:41 -07004982 public static final int IMMUTABLE_FLAGS = FLAG_GRANT_READ_URI_PERMISSION
4983 | FLAG_GRANT_WRITE_URI_PERMISSION | FLAG_GRANT_PERSISTABLE_URI_PERMISSION
4984 | FLAG_GRANT_PREFIX_URI_PERMISSION;
Tom Taylord4a47292009-12-21 13:59:18 -08004985
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004986 // ---------------------------------------------------------------------
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004987 // ---------------------------------------------------------------------
4988 // toUri() and parseUri() options.
4989
4990 /**
4991 * Flag for use with {@link #toUri} and {@link #parseUri}: the URI string
4992 * always has the "intent:" scheme. This syntax can be used when you want
4993 * to later disambiguate between URIs that are intended to describe an
4994 * Intent vs. all others that should be treated as raw URIs. When used
4995 * with {@link #parseUri}, any other scheme will result in a generic
4996 * VIEW action for that raw URI.
4997 */
4998 public static final int URI_INTENT_SCHEME = 1<<0;
Tom Taylord4a47292009-12-21 13:59:18 -08004999
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005000 /**
5001 * Flag for use with {@link #toUri} and {@link #parseUri}: the URI string
5002 * always has the "android-app:" scheme. This is a variation of
5003 * {@link #URI_INTENT_SCHEME} whose format is simpler for the case of an
5004 * http/https URI being delivered to a specific package name. The format
5005 * is:
5006 *
5007 * <pre class="prettyprint">
Dianne Hackborn0ee10f62015-01-14 16:16:13 -08005008 * android-app://{package_id}[/{scheme}[/{host}[/{path}]]][#Intent;{...}]</pre>
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005009 *
Dianne Hackborn0ee10f62015-01-14 16:16:13 -08005010 * <p>In this scheme, only the <code>package_id</code> is required. If you include a host,
5011 * you must also include a scheme; including a path also requires both a host and a scheme.
5012 * The final #Intent; fragment can be used without a scheme, host, or path.
5013 * Note that this can not be
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005014 * used with intents that have a {@link #setSelector}, since the base intent
5015 * will always have an explicit package name.</p>
5016 *
5017 * <p>Some examples of how this scheme maps to Intent objects:</p>
5018 * <table border="2" width="85%" align="center" frame="hsides" rules="rows">
5019 * <colgroup align="left" />
5020 * <colgroup align="left" />
5021 * <thead>
5022 * <tr><th>URI</th> <th>Intent</th></tr>
5023 * </thead>
5024 *
5025 * <tbody>
5026 * <tr><td><code>android-app://com.example.app</code></td>
5027 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
5028 * <tr><td>Action: </td><td>{@link #ACTION_MAIN}</td></tr>
5029 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
5030 * </table></td>
5031 * </tr>
5032 * <tr><td><code>android-app://com.example.app/http/example.com</code></td>
5033 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
5034 * <tr><td>Action: </td><td>{@link #ACTION_VIEW}</td></tr>
5035 * <tr><td>Data: </td><td><code>http://example.com/</code></td></tr>
5036 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
5037 * </table></td>
5038 * </tr>
5039 * <tr><td><code>android-app://com.example.app/http/example.com/foo?1234</code></td>
5040 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
5041 * <tr><td>Action: </td><td>{@link #ACTION_VIEW}</td></tr>
5042 * <tr><td>Data: </td><td><code>http://example.com/foo?1234</code></td></tr>
5043 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
5044 * </table></td>
5045 * </tr>
5046 * <tr><td><code>android-app://com.example.app/<br />#Intent;action=com.example.MY_ACTION;end</code></td>
5047 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
5048 * <tr><td>Action: </td><td><code>com.example.MY_ACTION</code></td></tr>
5049 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
5050 * </table></td>
5051 * </tr>
5052 * <tr><td><code>android-app://com.example.app/http/example.com/foo?1234<br />#Intent;action=com.example.MY_ACTION;end</code></td>
5053 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
5054 * <tr><td>Action: </td><td><code>com.example.MY_ACTION</code></td></tr>
5055 * <tr><td>Data: </td><td><code>http://example.com/foo?1234</code></td></tr>
5056 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
5057 * </table></td>
5058 * </tr>
5059 * <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>
5060 * <td><table border="" style="margin:0" >
5061 * <tr><td>Action: </td><td><code>com.example.MY_ACTION</code></td></tr>
5062 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
5063 * <tr><td>Extras: </td><td><code>some_int=(int)100<br />some_str=(String)hello</code></td></tr>
5064 * </table></td>
5065 * </tr>
5066 * </tbody>
5067 * </table>
5068 */
5069 public static final int URI_ANDROID_APP_SCHEME = 1<<1;
5070
Dianne Hackborn24b1c232014-11-20 17:17:39 -08005071 /**
5072 * Flag for use with {@link #toUri} and {@link #parseUri}: allow parsing
5073 * of unsafe information. In particular, the flags {@link #FLAG_GRANT_READ_URI_PERMISSION},
5074 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, {@link #FLAG_GRANT_PERSISTABLE_URI_PERMISSION},
5075 * and {@link #FLAG_GRANT_PREFIX_URI_PERMISSION} flags can not be set, so that the
5076 * generated Intent can not cause unexpected data access to happen.
5077 *
5078 * <p>If you do not trust the source of the URI being parsed, you should still do further
5079 * processing to protect yourself from it. In particular, when using it to start an
5080 * activity you should usually add in {@link #CATEGORY_BROWSABLE} to limit the activities
5081 * that can handle it.</p>
5082 */
5083 public static final int URI_ALLOW_UNSAFE = 1<<2;
5084
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005085 // ---------------------------------------------------------------------
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005086
5087 private String mAction;
5088 private Uri mData;
5089 private String mType;
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005090 private String mPackage;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005091 private ComponentName mComponent;
5092 private int mFlags;
Dianne Hackbornadd005c2013-07-17 18:43:12 -07005093 private ArraySet<String> mCategories;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005094 private Bundle mExtras;
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08005095 private Rect mSourceBounds;
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005096 private Intent mSelector;
Dianne Hackborn21c241e2012-03-08 13:57:23 -08005097 private ClipData mClipData;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01005098 private int mContentUserHint = UserHandle.USER_CURRENT;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005099
5100 // ---------------------------------------------------------------------
5101
5102 /**
5103 * Create an empty intent.
5104 */
5105 public Intent() {
5106 }
5107
5108 /**
5109 * Copy constructor.
5110 */
5111 public Intent(Intent o) {
5112 this.mAction = o.mAction;
5113 this.mData = o.mData;
5114 this.mType = o.mType;
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005115 this.mPackage = o.mPackage;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005116 this.mComponent = o.mComponent;
5117 this.mFlags = o.mFlags;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01005118 this.mContentUserHint = o.mContentUserHint;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005119 if (o.mCategories != null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07005120 this.mCategories = new ArraySet<String>(o.mCategories);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005121 }
5122 if (o.mExtras != null) {
5123 this.mExtras = new Bundle(o.mExtras);
5124 }
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08005125 if (o.mSourceBounds != null) {
5126 this.mSourceBounds = new Rect(o.mSourceBounds);
5127 }
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005128 if (o.mSelector != null) {
5129 this.mSelector = new Intent(o.mSelector);
5130 }
Dianne Hackborn21c241e2012-03-08 13:57:23 -08005131 if (o.mClipData != null) {
5132 this.mClipData = new ClipData(o.mClipData);
5133 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005134 }
5135
5136 @Override
5137 public Object clone() {
5138 return new Intent(this);
5139 }
5140
5141 private Intent(Intent o, boolean all) {
5142 this.mAction = o.mAction;
5143 this.mData = o.mData;
5144 this.mType = o.mType;
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005145 this.mPackage = o.mPackage;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005146 this.mComponent = o.mComponent;
5147 if (o.mCategories != null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07005148 this.mCategories = new ArraySet<String>(o.mCategories);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005149 }
5150 }
5151
5152 /**
5153 * Make a clone of only the parts of the Intent that are relevant for
5154 * filter matching: the action, data, type, component, and categories.
5155 */
5156 public Intent cloneFilter() {
5157 return new Intent(this, false);
5158 }
5159
5160 /**
5161 * Create an intent with a given action. All other fields (data, type,
5162 * class) are null. Note that the action <em>must</em> be in a
5163 * namespace because Intents are used globally in the system -- for
5164 * example the system VIEW action is android.intent.action.VIEW; an
5165 * application's custom action would be something like
5166 * com.google.app.myapp.CUSTOM_ACTION.
5167 *
5168 * @param action The Intent action, such as ACTION_VIEW.
5169 */
5170 public Intent(String action) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08005171 setAction(action);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005172 }
5173
5174 /**
5175 * Create an intent with a given action and for a given data url. Note
5176 * that the action <em>must</em> be in a namespace because Intents are
5177 * used globally in the system -- for example the system VIEW action is
5178 * android.intent.action.VIEW; an application's custom action would be
5179 * something like com.google.app.myapp.CUSTOM_ACTION.
5180 *
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07005181 * <p><em>Note: scheme and host name matching in the Android framework is
5182 * case-sensitive, unlike the formal RFC. As a result,
5183 * you should always ensure that you write your Uri with these elements
5184 * using lower case letters, and normalize any Uris you receive from
5185 * outside of Android to ensure the scheme and host is lower case.</em></p>
5186 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005187 * @param action The Intent action, such as ACTION_VIEW.
5188 * @param uri The Intent data URI.
5189 */
5190 public Intent(String action, Uri uri) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08005191 setAction(action);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005192 mData = uri;
5193 }
5194
5195 /**
5196 * Create an intent for a specific component. All other fields (action, data,
5197 * type, class) are null, though they can be modified later with explicit
5198 * calls. This provides a convenient way to create an intent that is
5199 * intended to execute a hard-coded class name, rather than relying on the
5200 * system to find an appropriate class for you; see {@link #setComponent}
5201 * for more information on the repercussions of this.
5202 *
5203 * @param packageContext A Context of the application package implementing
5204 * this class.
5205 * @param cls The component class that is to be used for the intent.
5206 *
5207 * @see #setClass
5208 * @see #setComponent
5209 * @see #Intent(String, android.net.Uri , Context, Class)
5210 */
5211 public Intent(Context packageContext, Class<?> cls) {
5212 mComponent = new ComponentName(packageContext, cls);
5213 }
5214
5215 /**
5216 * Create an intent for a specific component with a specified action and data.
Craig Mautner2dac0562014-05-06 09:06:44 -07005217 * This is equivalent to using {@link #Intent(String, android.net.Uri)} to
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005218 * construct the Intent and then calling {@link #setClass} to set its
5219 * class.
5220 *
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07005221 * <p><em>Note: scheme and host name matching in the Android framework is
5222 * case-sensitive, unlike the formal RFC. As a result,
5223 * you should always ensure that you write your Uri with these elements
5224 * using lower case letters, and normalize any Uris you receive from
5225 * outside of Android to ensure the scheme and host is lower case.</em></p>
5226 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005227 * @param action The Intent action, such as ACTION_VIEW.
5228 * @param uri The Intent data URI.
5229 * @param packageContext A Context of the application package implementing
5230 * this class.
5231 * @param cls The component class that is to be used for the intent.
5232 *
5233 * @see #Intent(String, android.net.Uri)
5234 * @see #Intent(Context, Class)
5235 * @see #setClass
5236 * @see #setComponent
5237 */
5238 public Intent(String action, Uri uri,
5239 Context packageContext, Class<?> cls) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08005240 setAction(action);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005241 mData = uri;
5242 mComponent = new ComponentName(packageContext, cls);
5243 }
5244
5245 /**
Dianne Hackborn30d71892010-12-11 10:37:55 -08005246 * Create an intent to launch the main (root) activity of a task. This
5247 * is the Intent that is started when the application's is launched from
5248 * Home. For anything else that wants to launch an application in the
5249 * same way, it is important that they use an Intent structured the same
5250 * way, and can use this function to ensure this is the case.
5251 *
5252 * <p>The returned Intent has the given Activity component as its explicit
5253 * component, {@link #ACTION_MAIN} as its action, and includes the
5254 * category {@link #CATEGORY_LAUNCHER}. This does <em>not</em> have
5255 * {@link #FLAG_ACTIVITY_NEW_TASK} set, though typically you will want
5256 * to do that through {@link #addFlags(int)} on the returned Intent.
5257 *
5258 * @param mainActivity The main activity component that this Intent will
5259 * launch.
5260 * @return Returns a newly created Intent that can be used to launch the
5261 * activity as a main application entry.
5262 *
5263 * @see #setClass
5264 * @see #setComponent
5265 */
5266 public static Intent makeMainActivity(ComponentName mainActivity) {
5267 Intent intent = new Intent(ACTION_MAIN);
5268 intent.setComponent(mainActivity);
5269 intent.addCategory(CATEGORY_LAUNCHER);
5270 return intent;
5271 }
5272
5273 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005274 * Make an Intent for the main activity of an application, without
5275 * specifying a specific activity to run but giving a selector to find
5276 * the activity. This results in a final Intent that is structured
5277 * the same as when the application is launched from
5278 * Home. For anything else that wants to launch an application in the
5279 * same way, it is important that they use an Intent structured the same
5280 * way, and can use this function to ensure this is the case.
5281 *
5282 * <p>The returned Intent has {@link #ACTION_MAIN} as its action, and includes the
5283 * category {@link #CATEGORY_LAUNCHER}. This does <em>not</em> have
5284 * {@link #FLAG_ACTIVITY_NEW_TASK} set, though typically you will want
5285 * to do that through {@link #addFlags(int)} on the returned Intent.
5286 *
5287 * @param selectorAction The action name of the Intent's selector.
5288 * @param selectorCategory The name of a category to add to the Intent's
5289 * selector.
5290 * @return Returns a newly created Intent that can be used to launch the
5291 * activity as a main application entry.
5292 *
5293 * @see #setSelector(Intent)
5294 */
5295 public static Intent makeMainSelectorActivity(String selectorAction,
5296 String selectorCategory) {
5297 Intent intent = new Intent(ACTION_MAIN);
5298 intent.addCategory(CATEGORY_LAUNCHER);
5299 Intent selector = new Intent();
5300 selector.setAction(selectorAction);
5301 selector.addCategory(selectorCategory);
5302 intent.setSelector(selector);
5303 return intent;
5304 }
5305
5306 /**
Dianne Hackborn30d71892010-12-11 10:37:55 -08005307 * Make an Intent that can be used to re-launch an application's task
5308 * in its base state. This is like {@link #makeMainActivity(ComponentName)},
5309 * but also sets the flags {@link #FLAG_ACTIVITY_NEW_TASK} and
5310 * {@link #FLAG_ACTIVITY_CLEAR_TASK}.
5311 *
5312 * @param mainActivity The activity component that is the root of the
5313 * task; this is the activity that has been published in the application's
5314 * manifest as the main launcher icon.
5315 *
5316 * @return Returns a newly created Intent that can be used to relaunch the
5317 * activity's task in its root state.
5318 */
5319 public static Intent makeRestartActivityTask(ComponentName mainActivity) {
5320 Intent intent = makeMainActivity(mainActivity);
5321 intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK
5322 | Intent.FLAG_ACTIVITY_CLEAR_TASK);
5323 return intent;
5324 }
5325
5326 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005327 * Call {@link #parseUri} with 0 flags.
5328 * @deprecated Use {@link #parseUri} instead.
5329 */
5330 @Deprecated
5331 public static Intent getIntent(String uri) throws URISyntaxException {
5332 return parseUri(uri, 0);
5333 }
Tom Taylord4a47292009-12-21 13:59:18 -08005334
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005335 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005336 * Create an intent from a URI. This URI may encode the action,
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005337 * category, and other intent fields, if it was returned by
Dianne Hackborn7f205432009-07-28 00:13:47 -07005338 * {@link #toUri}. If the Intent was not generate by toUri(), its data
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005339 * will be the entire URI and its action will be ACTION_VIEW.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005340 *
5341 * <p>The URI given here must not be relative -- that is, it must include
5342 * the scheme and full path.
5343 *
5344 * @param uri The URI to turn into an Intent.
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005345 * @param flags Additional processing flags. Either 0,
5346 * {@link #URI_INTENT_SCHEME}, or {@link #URI_ANDROID_APP_SCHEME}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005347 *
5348 * @return Intent The newly created Intent object.
5349 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005350 * @throws URISyntaxException Throws URISyntaxError if the basic URI syntax
5351 * it bad (as parsed by the Uri class) or the Intent data within the
5352 * URI is invalid.
Tom Taylord4a47292009-12-21 13:59:18 -08005353 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005354 * @see #toUri
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005355 */
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005356 public static Intent parseUri(String uri, int flags) throws URISyntaxException {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005357 int i = 0;
5358 try {
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005359 final boolean androidApp = uri.startsWith("android-app:");
5360
5361 // Validate intent scheme if requested.
5362 if ((flags&(URI_INTENT_SCHEME|URI_ANDROID_APP_SCHEME)) != 0) {
5363 if (!uri.startsWith("intent:") && !androidApp) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005364 Intent intent = new Intent(ACTION_VIEW);
5365 try {
5366 intent.setData(Uri.parse(uri));
5367 } catch (IllegalArgumentException e) {
5368 throw new URISyntaxException(uri, e.getMessage());
5369 }
5370 return intent;
5371 }
5372 }
Tom Taylord4a47292009-12-21 13:59:18 -08005373
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005374 i = uri.lastIndexOf("#");
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005375 // simple case
5376 if (i == -1) {
5377 if (!androidApp) {
5378 return new Intent(ACTION_VIEW, Uri.parse(uri));
5379 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005380
5381 // old format Intent URI
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005382 } else if (!uri.startsWith("#Intent;", i)) {
5383 if (!androidApp) {
Dianne Hackborn24b1c232014-11-20 17:17:39 -08005384 return getIntentOld(uri, flags);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005385 } else {
5386 i = -1;
5387 }
5388 }
The Android Open Source Project10592532009-03-18 17:39:46 -07005389
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005390 // new format
5391 Intent intent = new Intent(ACTION_VIEW);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005392 Intent baseIntent = intent;
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005393 boolean explicitAction = false;
5394 boolean inSelector = false;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005395
5396 // fetch data part, if present
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005397 String scheme = null;
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005398 String data;
5399 if (i >= 0) {
5400 data = uri.substring(0, i);
5401 i += 8; // length of "#Intent;"
5402 } else {
5403 data = uri;
5404 }
The Android Open Source Project10592532009-03-18 17:39:46 -07005405
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005406 // loop over contents of Intent, all name=value;
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005407 while (i >= 0 && !uri.startsWith("end", i)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005408 int eq = uri.indexOf('=', i);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005409 if (eq < 0) eq = i-1;
5410 int semi = uri.indexOf(';', i);
5411 String value = eq < semi ? Uri.decode(uri.substring(eq + 1, semi)) : "";
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005412
5413 // action
5414 if (uri.startsWith("action=", i)) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08005415 intent.setAction(value);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005416 if (!inSelector) {
5417 explicitAction = true;
5418 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005419 }
5420
5421 // categories
5422 else if (uri.startsWith("category=", i)) {
5423 intent.addCategory(value);
5424 }
5425
5426 // type
5427 else if (uri.startsWith("type=", i)) {
5428 intent.mType = value;
5429 }
5430
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08005431 // launch flags
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005432 else if (uri.startsWith("launchFlags=", i)) {
5433 intent.mFlags = Integer.decode(value).intValue();
Dianne Hackborn24b1c232014-11-20 17:17:39 -08005434 if ((flags& URI_ALLOW_UNSAFE) == 0) {
5435 intent.mFlags &= ~IMMUTABLE_FLAGS;
5436 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005437 }
5438
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005439 // package
5440 else if (uri.startsWith("package=", i)) {
5441 intent.mPackage = value;
5442 }
5443
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005444 // component
5445 else if (uri.startsWith("component=", i)) {
5446 intent.mComponent = ComponentName.unflattenFromString(value);
5447 }
The Android Open Source Project10592532009-03-18 17:39:46 -07005448
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005449 // scheme
5450 else if (uri.startsWith("scheme=", i)) {
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005451 if (inSelector) {
Dianne Hackborn80b1c562014-12-09 20:22:08 -08005452 intent.mData = Uri.parse(value + ":");
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005453 } else {
5454 scheme = value;
5455 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005456 }
5457
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08005458 // source bounds
5459 else if (uri.startsWith("sourceBounds=", i)) {
5460 intent.mSourceBounds = Rect.unflattenFromString(value);
5461 }
5462
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005463 // selector
5464 else if (semi == (i+3) && uri.startsWith("SEL", i)) {
5465 intent = new Intent();
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005466 inSelector = true;
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005467 }
5468
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005469 // extra
5470 else {
5471 String key = Uri.decode(uri.substring(i + 2, eq));
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005472 // create Bundle if it doesn't already exist
5473 if (intent.mExtras == null) intent.mExtras = new Bundle();
5474 Bundle b = intent.mExtras;
5475 // add EXTRA
5476 if (uri.startsWith("S.", i)) b.putString(key, value);
5477 else if (uri.startsWith("B.", i)) b.putBoolean(key, Boolean.parseBoolean(value));
5478 else if (uri.startsWith("b.", i)) b.putByte(key, Byte.parseByte(value));
5479 else if (uri.startsWith("c.", i)) b.putChar(key, value.charAt(0));
5480 else if (uri.startsWith("d.", i)) b.putDouble(key, Double.parseDouble(value));
5481 else if (uri.startsWith("f.", i)) b.putFloat(key, Float.parseFloat(value));
5482 else if (uri.startsWith("i.", i)) b.putInt(key, Integer.parseInt(value));
5483 else if (uri.startsWith("l.", i)) b.putLong(key, Long.parseLong(value));
5484 else if (uri.startsWith("s.", i)) b.putShort(key, Short.parseShort(value));
5485 else throw new URISyntaxException(uri, "unknown EXTRA type", i);
5486 }
The Android Open Source Project10592532009-03-18 17:39:46 -07005487
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005488 // move to the next item
5489 i = semi + 1;
5490 }
5491
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005492 if (inSelector) {
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005493 // The Intent had a selector; fix it up.
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005494 if (baseIntent.mPackage == null) {
5495 baseIntent.setSelector(intent);
5496 }
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005497 intent = baseIntent;
5498 }
5499
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005500 if (data != null) {
5501 if (data.startsWith("intent:")) {
5502 data = data.substring(7);
5503 if (scheme != null) {
5504 data = scheme + ':' + data;
5505 }
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005506 } else if (data.startsWith("android-app:")) {
5507 if (data.charAt(12) == '/' && data.charAt(13) == '/') {
5508 // Correctly formed android-app, first part is package name.
5509 int end = data.indexOf('/', 14);
5510 if (end < 0) {
5511 // All we have is a package name.
5512 intent.mPackage = data.substring(14);
5513 if (!explicitAction) {
5514 intent.setAction(ACTION_MAIN);
5515 }
5516 data = "";
5517 } else {
5518 // Target the Intent at the given package name always.
5519 String authority = null;
5520 intent.mPackage = data.substring(14, end);
5521 int newEnd;
Dianne Hackborn80b1c562014-12-09 20:22:08 -08005522 if ((end+1) < data.length()) {
5523 if ((newEnd=data.indexOf('/', end+1)) >= 0) {
5524 // Found a scheme, remember it.
5525 scheme = data.substring(end+1, newEnd);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005526 end = newEnd;
Dianne Hackborn80b1c562014-12-09 20:22:08 -08005527 if (end < data.length() && (newEnd=data.indexOf('/', end+1)) >= 0) {
5528 // Found a authority, remember it.
5529 authority = data.substring(end+1, newEnd);
5530 end = newEnd;
5531 }
5532 } else {
5533 // All we have is a scheme.
5534 scheme = data.substring(end+1);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005535 }
5536 }
5537 if (scheme == null) {
5538 // If there was no scheme, then this just targets the package.
5539 if (!explicitAction) {
5540 intent.setAction(ACTION_MAIN);
5541 }
5542 data = "";
5543 } else if (authority == null) {
5544 data = scheme + ":";
5545 } else {
5546 data = scheme + "://" + authority + data.substring(end);
5547 }
5548 }
5549 } else {
5550 data = "";
5551 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005552 }
Tom Taylord4a47292009-12-21 13:59:18 -08005553
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005554 if (data.length() > 0) {
5555 try {
5556 intent.mData = Uri.parse(data);
5557 } catch (IllegalArgumentException e) {
5558 throw new URISyntaxException(uri, e.getMessage());
5559 }
5560 }
5561 }
Tom Taylord4a47292009-12-21 13:59:18 -08005562
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005563 return intent;
The Android Open Source Project10592532009-03-18 17:39:46 -07005564
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005565 } catch (IndexOutOfBoundsException e) {
5566 throw new URISyntaxException(uri, "illegal Intent URI format", i);
5567 }
5568 }
The Android Open Source Project10592532009-03-18 17:39:46 -07005569
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005570 public static Intent getIntentOld(String uri) throws URISyntaxException {
Dianne Hackborn24b1c232014-11-20 17:17:39 -08005571 return getIntentOld(uri, 0);
5572 }
5573
5574 private static Intent getIntentOld(String uri, int flags) throws URISyntaxException {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005575 Intent intent;
5576
5577 int i = uri.lastIndexOf('#');
5578 if (i >= 0) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005579 String action = null;
Dianne Hackborn6cca1592009-09-20 12:40:03 -07005580 final int intentFragmentStart = i;
5581 boolean isIntentFragment = false;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005582
5583 i++;
5584
5585 if (uri.regionMatches(i, "action(", 0, 7)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07005586 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005587 i += 7;
5588 int j = uri.indexOf(')', i);
5589 action = uri.substring(i, j);
5590 i = j + 1;
5591 }
5592
Dianne Hackborn6cca1592009-09-20 12:40:03 -07005593 intent = new Intent(action);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005594
5595 if (uri.regionMatches(i, "categories(", 0, 11)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07005596 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005597 i += 11;
5598 int j = uri.indexOf(')', i);
5599 while (i < j) {
5600 int sep = uri.indexOf('!', i);
Alan Viverette0adf32b2014-09-18 12:53:16 -07005601 if (sep < 0 || sep > j) sep = j;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005602 if (i < sep) {
5603 intent.addCategory(uri.substring(i, sep));
5604 }
5605 i = sep + 1;
5606 }
5607 i = j + 1;
5608 }
5609
5610 if (uri.regionMatches(i, "type(", 0, 5)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07005611 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005612 i += 5;
5613 int j = uri.indexOf(')', i);
5614 intent.mType = uri.substring(i, j);
5615 i = j + 1;
5616 }
5617
5618 if (uri.regionMatches(i, "launchFlags(", 0, 12)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07005619 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005620 i += 12;
5621 int j = uri.indexOf(')', i);
5622 intent.mFlags = Integer.decode(uri.substring(i, j)).intValue();
Dianne Hackborn24b1c232014-11-20 17:17:39 -08005623 if ((flags& URI_ALLOW_UNSAFE) == 0) {
5624 intent.mFlags &= ~IMMUTABLE_FLAGS;
5625 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005626 i = j + 1;
5627 }
5628
5629 if (uri.regionMatches(i, "component(", 0, 10)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07005630 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005631 i += 10;
5632 int j = uri.indexOf(')', i);
5633 int sep = uri.indexOf('!', i);
5634 if (sep >= 0 && sep < j) {
5635 String pkg = uri.substring(i, sep);
5636 String cls = uri.substring(sep + 1, j);
5637 intent.mComponent = new ComponentName(pkg, cls);
5638 }
5639 i = j + 1;
5640 }
5641
5642 if (uri.regionMatches(i, "extras(", 0, 7)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07005643 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005644 i += 7;
The Android Open Source Project10592532009-03-18 17:39:46 -07005645
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005646 final int closeParen = uri.indexOf(')', i);
5647 if (closeParen == -1) throw new URISyntaxException(uri,
5648 "EXTRA missing trailing ')'", i);
5649
5650 while (i < closeParen) {
5651 // fetch the key value
5652 int j = uri.indexOf('=', i);
5653 if (j <= i + 1 || i >= closeParen) {
5654 throw new URISyntaxException(uri, "EXTRA missing '='", i);
5655 }
5656 char type = uri.charAt(i);
5657 i++;
5658 String key = uri.substring(i, j);
5659 i = j + 1;
The Android Open Source Project10592532009-03-18 17:39:46 -07005660
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005661 // get type-value
5662 j = uri.indexOf('!', i);
5663 if (j == -1 || j >= closeParen) j = closeParen;
5664 if (i >= j) throw new URISyntaxException(uri, "EXTRA missing '!'", i);
5665 String value = uri.substring(i, j);
5666 i = j;
5667
5668 // create Bundle if it doesn't already exist
5669 if (intent.mExtras == null) intent.mExtras = new Bundle();
The Android Open Source Project10592532009-03-18 17:39:46 -07005670
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005671 // add item to bundle
5672 try {
5673 switch (type) {
5674 case 'S':
5675 intent.mExtras.putString(key, Uri.decode(value));
5676 break;
5677 case 'B':
5678 intent.mExtras.putBoolean(key, Boolean.parseBoolean(value));
5679 break;
5680 case 'b':
5681 intent.mExtras.putByte(key, Byte.parseByte(value));
5682 break;
5683 case 'c':
5684 intent.mExtras.putChar(key, Uri.decode(value).charAt(0));
5685 break;
5686 case 'd':
5687 intent.mExtras.putDouble(key, Double.parseDouble(value));
5688 break;
5689 case 'f':
5690 intent.mExtras.putFloat(key, Float.parseFloat(value));
5691 break;
5692 case 'i':
5693 intent.mExtras.putInt(key, Integer.parseInt(value));
5694 break;
5695 case 'l':
5696 intent.mExtras.putLong(key, Long.parseLong(value));
5697 break;
5698 case 's':
5699 intent.mExtras.putShort(key, Short.parseShort(value));
5700 break;
5701 default:
5702 throw new URISyntaxException(uri, "EXTRA has unknown type", i);
5703 }
5704 } catch (NumberFormatException e) {
5705 throw new URISyntaxException(uri, "EXTRA value can't be parsed", i);
5706 }
The Android Open Source Project10592532009-03-18 17:39:46 -07005707
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005708 char ch = uri.charAt(i);
5709 if (ch == ')') break;
5710 if (ch != '!') throw new URISyntaxException(uri, "EXTRA missing '!'", i);
5711 i++;
5712 }
5713 }
5714
Dianne Hackborn6cca1592009-09-20 12:40:03 -07005715 if (isIntentFragment) {
5716 intent.mData = Uri.parse(uri.substring(0, intentFragmentStart));
5717 } else {
5718 intent.mData = Uri.parse(uri);
5719 }
Tom Taylord4a47292009-12-21 13:59:18 -08005720
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005721 if (intent.mAction == null) {
5722 // By default, if no action is specified, then use VIEW.
5723 intent.mAction = ACTION_VIEW;
5724 }
5725
5726 } else {
5727 intent = new Intent(ACTION_VIEW, Uri.parse(uri));
5728 }
5729
5730 return intent;
5731 }
5732
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08005733 /** @hide */
5734 public interface CommandOptionHandler {
5735 boolean handleOption(String opt, ShellCommand cmd);
5736 }
5737
5738 /** @hide */
5739 public static Intent parseCommandArgs(ShellCommand cmd, CommandOptionHandler optionHandler)
5740 throws URISyntaxException {
5741 Intent intent = new Intent();
5742 Intent baseIntent = intent;
5743 boolean hasIntentInfo = false;
5744
5745 Uri data = null;
5746 String type = null;
5747
5748 String opt;
5749 while ((opt=cmd.getNextOption()) != null) {
5750 switch (opt) {
5751 case "-a":
5752 intent.setAction(cmd.getNextArgRequired());
5753 if (intent == baseIntent) {
5754 hasIntentInfo = true;
5755 }
5756 break;
5757 case "-d":
5758 data = Uri.parse(cmd.getNextArgRequired());
5759 if (intent == baseIntent) {
5760 hasIntentInfo = true;
5761 }
5762 break;
5763 case "-t":
5764 type = cmd.getNextArgRequired();
5765 if (intent == baseIntent) {
5766 hasIntentInfo = true;
5767 }
5768 break;
5769 case "-c":
5770 intent.addCategory(cmd.getNextArgRequired());
5771 if (intent == baseIntent) {
5772 hasIntentInfo = true;
5773 }
5774 break;
5775 case "-e":
5776 case "--es": {
5777 String key = cmd.getNextArgRequired();
5778 String value = cmd.getNextArgRequired();
5779 intent.putExtra(key, value);
5780 }
5781 break;
5782 case "--esn": {
5783 String key = cmd.getNextArgRequired();
5784 intent.putExtra(key, (String) null);
5785 }
5786 break;
5787 case "--ei": {
5788 String key = cmd.getNextArgRequired();
5789 String value = cmd.getNextArgRequired();
5790 intent.putExtra(key, Integer.decode(value));
5791 }
5792 break;
5793 case "--eu": {
5794 String key = cmd.getNextArgRequired();
5795 String value = cmd.getNextArgRequired();
5796 intent.putExtra(key, Uri.parse(value));
5797 }
5798 break;
5799 case "--ecn": {
5800 String key = cmd.getNextArgRequired();
5801 String value = cmd.getNextArgRequired();
5802 ComponentName cn = ComponentName.unflattenFromString(value);
5803 if (cn == null)
5804 throw new IllegalArgumentException("Bad component name: " + value);
5805 intent.putExtra(key, cn);
5806 }
5807 break;
5808 case "--eia": {
5809 String key = cmd.getNextArgRequired();
5810 String value = cmd.getNextArgRequired();
5811 String[] strings = value.split(",");
5812 int[] list = new int[strings.length];
5813 for (int i = 0; i < strings.length; i++) {
5814 list[i] = Integer.decode(strings[i]);
5815 }
5816 intent.putExtra(key, list);
5817 }
5818 break;
5819 case "--eial": {
5820 String key = cmd.getNextArgRequired();
5821 String value = cmd.getNextArgRequired();
5822 String[] strings = value.split(",");
5823 ArrayList<Integer> list = new ArrayList<>(strings.length);
5824 for (int i = 0; i < strings.length; i++) {
5825 list.add(Integer.decode(strings[i]));
5826 }
5827 intent.putExtra(key, list);
5828 }
5829 break;
5830 case "--el": {
5831 String key = cmd.getNextArgRequired();
5832 String value = cmd.getNextArgRequired();
5833 intent.putExtra(key, Long.valueOf(value));
5834 }
5835 break;
5836 case "--ela": {
5837 String key = cmd.getNextArgRequired();
5838 String value = cmd.getNextArgRequired();
5839 String[] strings = value.split(",");
5840 long[] list = new long[strings.length];
5841 for (int i = 0; i < strings.length; i++) {
5842 list[i] = Long.valueOf(strings[i]);
5843 }
5844 intent.putExtra(key, list);
5845 hasIntentInfo = true;
5846 }
5847 break;
5848 case "--elal": {
5849 String key = cmd.getNextArgRequired();
5850 String value = cmd.getNextArgRequired();
5851 String[] strings = value.split(",");
5852 ArrayList<Long> list = new ArrayList<>(strings.length);
5853 for (int i = 0; i < strings.length; i++) {
5854 list.add(Long.valueOf(strings[i]));
5855 }
5856 intent.putExtra(key, list);
5857 hasIntentInfo = true;
5858 }
5859 break;
5860 case "--ef": {
5861 String key = cmd.getNextArgRequired();
5862 String value = cmd.getNextArgRequired();
5863 intent.putExtra(key, Float.valueOf(value));
5864 hasIntentInfo = true;
5865 }
5866 break;
5867 case "--efa": {
5868 String key = cmd.getNextArgRequired();
5869 String value = cmd.getNextArgRequired();
5870 String[] strings = value.split(",");
5871 float[] list = new float[strings.length];
5872 for (int i = 0; i < strings.length; i++) {
5873 list[i] = Float.valueOf(strings[i]);
5874 }
5875 intent.putExtra(key, list);
5876 hasIntentInfo = true;
5877 }
5878 break;
5879 case "--efal": {
5880 String key = cmd.getNextArgRequired();
5881 String value = cmd.getNextArgRequired();
5882 String[] strings = value.split(",");
5883 ArrayList<Float> list = new ArrayList<>(strings.length);
5884 for (int i = 0; i < strings.length; i++) {
5885 list.add(Float.valueOf(strings[i]));
5886 }
5887 intent.putExtra(key, list);
5888 hasIntentInfo = true;
5889 }
5890 break;
5891 case "--esa": {
5892 String key = cmd.getNextArgRequired();
5893 String value = cmd.getNextArgRequired();
5894 // Split on commas unless they are preceeded by an escape.
5895 // The escape character must be escaped for the string and
5896 // again for the regex, thus four escape characters become one.
5897 String[] strings = value.split("(?<!\\\\),");
5898 intent.putExtra(key, strings);
5899 hasIntentInfo = true;
5900 }
5901 break;
5902 case "--esal": {
5903 String key = cmd.getNextArgRequired();
5904 String value = cmd.getNextArgRequired();
5905 // Split on commas unless they are preceeded by an escape.
5906 // The escape character must be escaped for the string and
5907 // again for the regex, thus four escape characters become one.
5908 String[] strings = value.split("(?<!\\\\),");
5909 ArrayList<String> list = new ArrayList<>(strings.length);
5910 for (int i = 0; i < strings.length; i++) {
5911 list.add(strings[i]);
5912 }
5913 intent.putExtra(key, list);
5914 hasIntentInfo = true;
5915 }
5916 break;
5917 case "--ez": {
5918 String key = cmd.getNextArgRequired();
5919 String value = cmd.getNextArgRequired().toLowerCase();
5920 // Boolean.valueOf() results in false for anything that is not "true", which is
5921 // error-prone in shell commands
5922 boolean arg;
5923 if ("true".equals(value) || "t".equals(value)) {
5924 arg = true;
5925 } else if ("false".equals(value) || "f".equals(value)) {
5926 arg = false;
5927 } else {
5928 try {
5929 arg = Integer.decode(value) != 0;
5930 } catch (NumberFormatException ex) {
5931 throw new IllegalArgumentException("Invalid boolean value: " + value);
5932 }
5933 }
5934
5935 intent.putExtra(key, arg);
5936 }
5937 break;
5938 case "-n": {
5939 String str = cmd.getNextArgRequired();
5940 ComponentName cn = ComponentName.unflattenFromString(str);
5941 if (cn == null)
5942 throw new IllegalArgumentException("Bad component name: " + str);
5943 intent.setComponent(cn);
5944 if (intent == baseIntent) {
5945 hasIntentInfo = true;
5946 }
5947 }
5948 break;
5949 case "-p": {
5950 String str = cmd.getNextArgRequired();
5951 intent.setPackage(str);
5952 if (intent == baseIntent) {
5953 hasIntentInfo = true;
5954 }
5955 }
5956 break;
5957 case "-f":
5958 String str = cmd.getNextArgRequired();
5959 intent.setFlags(Integer.decode(str).intValue());
5960 break;
5961 case "--grant-read-uri-permission":
5962 intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
5963 break;
5964 case "--grant-write-uri-permission":
5965 intent.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
5966 break;
5967 case "--grant-persistable-uri-permission":
5968 intent.addFlags(Intent.FLAG_GRANT_PERSISTABLE_URI_PERMISSION);
5969 break;
5970 case "--grant-prefix-uri-permission":
5971 intent.addFlags(Intent.FLAG_GRANT_PREFIX_URI_PERMISSION);
5972 break;
5973 case "--exclude-stopped-packages":
5974 intent.addFlags(Intent.FLAG_EXCLUDE_STOPPED_PACKAGES);
5975 break;
5976 case "--include-stopped-packages":
5977 intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
5978 break;
5979 case "--debug-log-resolution":
5980 intent.addFlags(Intent.FLAG_DEBUG_LOG_RESOLUTION);
5981 break;
5982 case "--activity-brought-to-front":
5983 intent.addFlags(Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT);
5984 break;
5985 case "--activity-clear-top":
5986 intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
5987 break;
5988 case "--activity-clear-when-task-reset":
5989 intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
5990 break;
5991 case "--activity-exclude-from-recents":
5992 intent.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
5993 break;
5994 case "--activity-launched-from-history":
5995 intent.addFlags(Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY);
5996 break;
5997 case "--activity-multiple-task":
5998 intent.addFlags(Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
5999 break;
6000 case "--activity-no-animation":
6001 intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
6002 break;
6003 case "--activity-no-history":
6004 intent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
6005 break;
6006 case "--activity-no-user-action":
6007 intent.addFlags(Intent.FLAG_ACTIVITY_NO_USER_ACTION);
6008 break;
6009 case "--activity-previous-is-top":
6010 intent.addFlags(Intent.FLAG_ACTIVITY_PREVIOUS_IS_TOP);
6011 break;
6012 case "--activity-reorder-to-front":
6013 intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
6014 break;
6015 case "--activity-reset-task-if-needed":
6016 intent.addFlags(Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
6017 break;
6018 case "--activity-single-top":
6019 intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
6020 break;
6021 case "--activity-clear-task":
6022 intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
6023 break;
6024 case "--activity-task-on-home":
6025 intent.addFlags(Intent.FLAG_ACTIVITY_TASK_ON_HOME);
6026 break;
6027 case "--receiver-registered-only":
6028 intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY);
6029 break;
6030 case "--receiver-replace-pending":
6031 intent.addFlags(Intent.FLAG_RECEIVER_REPLACE_PENDING);
6032 break;
Felipe Leme3cb48cd2016-01-27 08:39:09 -08006033 case "--receiver-foreground":
6034 intent.addFlags(Intent.FLAG_RECEIVER_FOREGROUND);
6035 break;
Dianne Hackborn797772b12017-02-08 16:33:43 -08006036 case "--receiver-no-abort":
6037 intent.addFlags(Intent.FLAG_RECEIVER_NO_ABORT);
6038 break;
6039 case "--receiver-include-background":
6040 intent.addFlags(Intent.FLAG_RECEIVER_INCLUDE_BACKGROUND);
6041 break;
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08006042 case "--selector":
6043 intent.setDataAndType(data, type);
6044 intent = new Intent();
6045 break;
6046 default:
6047 if (optionHandler != null && optionHandler.handleOption(opt, cmd)) {
6048 // Okay, caller handled this option.
6049 } else {
6050 throw new IllegalArgumentException("Unknown option: " + opt);
6051 }
6052 break;
6053 }
6054 }
6055 intent.setDataAndType(data, type);
6056
6057 final boolean hasSelector = intent != baseIntent;
6058 if (hasSelector) {
6059 // A selector was specified; fix up.
6060 baseIntent.setSelector(intent);
6061 intent = baseIntent;
6062 }
6063
6064 String arg = cmd.getNextArg();
6065 baseIntent = null;
6066 if (arg == null) {
6067 if (hasSelector) {
6068 // If a selector has been specified, and no arguments
6069 // have been supplied for the main Intent, then we can
6070 // assume it is ACTION_MAIN CATEGORY_LAUNCHER; we don't
6071 // need to have a component name specified yet, the
6072 // selector will take care of that.
6073 baseIntent = new Intent(Intent.ACTION_MAIN);
6074 baseIntent.addCategory(Intent.CATEGORY_LAUNCHER);
6075 }
6076 } else if (arg.indexOf(':') >= 0) {
6077 // The argument is a URI. Fully parse it, and use that result
6078 // to fill in any data not specified so far.
6079 baseIntent = Intent.parseUri(arg, Intent.URI_INTENT_SCHEME
6080 | Intent.URI_ANDROID_APP_SCHEME | Intent.URI_ALLOW_UNSAFE);
6081 } else if (arg.indexOf('/') >= 0) {
6082 // The argument is a component name. Build an Intent to launch
6083 // it.
6084 baseIntent = new Intent(Intent.ACTION_MAIN);
6085 baseIntent.addCategory(Intent.CATEGORY_LAUNCHER);
6086 baseIntent.setComponent(ComponentName.unflattenFromString(arg));
6087 } else {
6088 // Assume the argument is a package name.
6089 baseIntent = new Intent(Intent.ACTION_MAIN);
6090 baseIntent.addCategory(Intent.CATEGORY_LAUNCHER);
6091 baseIntent.setPackage(arg);
6092 }
6093 if (baseIntent != null) {
6094 Bundle extras = intent.getExtras();
6095 intent.replaceExtras((Bundle)null);
6096 Bundle uriExtras = baseIntent.getExtras();
6097 baseIntent.replaceExtras((Bundle)null);
6098 if (intent.getAction() != null && baseIntent.getCategories() != null) {
6099 HashSet<String> cats = new HashSet<String>(baseIntent.getCategories());
6100 for (String c : cats) {
6101 baseIntent.removeCategory(c);
6102 }
6103 }
6104 intent.fillIn(baseIntent, Intent.FILL_IN_COMPONENT | Intent.FILL_IN_SELECTOR);
6105 if (extras == null) {
6106 extras = uriExtras;
6107 } else if (uriExtras != null) {
6108 uriExtras.putAll(extras);
6109 extras = uriExtras;
6110 }
6111 intent.replaceExtras(extras);
6112 hasIntentInfo = true;
6113 }
6114
6115 if (!hasIntentInfo) throw new IllegalArgumentException("No intent supplied");
6116 return intent;
6117 }
6118
6119 /** @hide */
6120 public static void printIntentArgsHelp(PrintWriter pw, String prefix) {
6121 final String[] lines = new String[] {
6122 "<INTENT> specifications include these flags and arguments:",
6123 " [-a <ACTION>] [-d <DATA_URI>] [-t <MIME_TYPE>]",
6124 " [-c <CATEGORY> [-c <CATEGORY>] ...]",
6125 " [-e|--es <EXTRA_KEY> <EXTRA_STRING_VALUE> ...]",
6126 " [--esn <EXTRA_KEY> ...]",
6127 " [--ez <EXTRA_KEY> <EXTRA_BOOLEAN_VALUE> ...]",
6128 " [--ei <EXTRA_KEY> <EXTRA_INT_VALUE> ...]",
6129 " [--el <EXTRA_KEY> <EXTRA_LONG_VALUE> ...]",
6130 " [--ef <EXTRA_KEY> <EXTRA_FLOAT_VALUE> ...]",
6131 " [--eu <EXTRA_KEY> <EXTRA_URI_VALUE> ...]",
6132 " [--ecn <EXTRA_KEY> <EXTRA_COMPONENT_NAME_VALUE>]",
6133 " [--eia <EXTRA_KEY> <EXTRA_INT_VALUE>[,<EXTRA_INT_VALUE...]]",
6134 " (mutiple extras passed as Integer[])",
6135 " [--eial <EXTRA_KEY> <EXTRA_INT_VALUE>[,<EXTRA_INT_VALUE...]]",
6136 " (mutiple extras passed as List<Integer>)",
6137 " [--ela <EXTRA_KEY> <EXTRA_LONG_VALUE>[,<EXTRA_LONG_VALUE...]]",
6138 " (mutiple extras passed as Long[])",
6139 " [--elal <EXTRA_KEY> <EXTRA_LONG_VALUE>[,<EXTRA_LONG_VALUE...]]",
6140 " (mutiple extras passed as List<Long>)",
6141 " [--efa <EXTRA_KEY> <EXTRA_FLOAT_VALUE>[,<EXTRA_FLOAT_VALUE...]]",
6142 " (mutiple extras passed as Float[])",
6143 " [--efal <EXTRA_KEY> <EXTRA_FLOAT_VALUE>[,<EXTRA_FLOAT_VALUE...]]",
6144 " (mutiple extras passed as List<Float>)",
6145 " [--esa <EXTRA_KEY> <EXTRA_STRING_VALUE>[,<EXTRA_STRING_VALUE...]]",
6146 " (mutiple extras passed as String[]; to embed a comma into a string,",
6147 " escape it using \"\\,\")",
6148 " [--esal <EXTRA_KEY> <EXTRA_STRING_VALUE>[,<EXTRA_STRING_VALUE...]]",
6149 " (mutiple extras passed as List<String>; to embed a comma into a string,",
6150 " escape it using \"\\,\")",
Felipe Leme545569d2016-01-11 16:27:58 -08006151 " [-f <FLAG>]",
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08006152 " [--grant-read-uri-permission] [--grant-write-uri-permission]",
6153 " [--grant-persistable-uri-permission] [--grant-prefix-uri-permission]",
6154 " [--debug-log-resolution] [--exclude-stopped-packages]",
6155 " [--include-stopped-packages]",
6156 " [--activity-brought-to-front] [--activity-clear-top]",
6157 " [--activity-clear-when-task-reset] [--activity-exclude-from-recents]",
6158 " [--activity-launched-from-history] [--activity-multiple-task]",
6159 " [--activity-no-animation] [--activity-no-history]",
6160 " [--activity-no-user-action] [--activity-previous-is-top]",
6161 " [--activity-reorder-to-front] [--activity-reset-task-if-needed]",
6162 " [--activity-single-top] [--activity-clear-task]",
6163 " [--activity-task-on-home]",
6164 " [--receiver-registered-only] [--receiver-replace-pending]",
Dianne Hackborn797772b12017-02-08 16:33:43 -08006165 " [--receiver-foreground] [--receiver-no-abort]",
6166 " [--receiver-include-background]",
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08006167 " [--selector]",
6168 " [<URI> | <PACKAGE> | <COMPONENT>]"
6169 };
6170 for (String line : lines) {
6171 pw.print(prefix);
6172 pw.println(line);
6173 }
6174 }
6175
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006176 /**
6177 * Retrieve the general action to be performed, such as
6178 * {@link #ACTION_VIEW}. The action describes the general way the rest of
6179 * the information in the intent should be interpreted -- most importantly,
6180 * what to do with the data returned by {@link #getData}.
6181 *
6182 * @return The action of this intent or null if none is specified.
6183 *
6184 * @see #setAction
6185 */
6186 public String getAction() {
6187 return mAction;
6188 }
6189
6190 /**
6191 * Retrieve data this intent is operating on. This URI specifies the name
6192 * of the data; often it uses the content: scheme, specifying data in a
6193 * content provider. Other schemes may be handled by specific activities,
6194 * such as http: by the web browser.
6195 *
6196 * @return The URI of the data this intent is targeting or null.
6197 *
6198 * @see #getScheme
6199 * @see #setData
6200 */
6201 public Uri getData() {
6202 return mData;
6203 }
6204
6205 /**
6206 * The same as {@link #getData()}, but returns the URI as an encoded
6207 * String.
6208 */
6209 public String getDataString() {
6210 return mData != null ? mData.toString() : null;
6211 }
6212
6213 /**
6214 * Return the scheme portion of the intent's data. If the data is null or
6215 * does not include a scheme, null is returned. Otherwise, the scheme
6216 * prefix without the final ':' is returned, i.e. "http".
6217 *
6218 * <p>This is the same as calling getData().getScheme() (and checking for
6219 * null data).
6220 *
6221 * @return The scheme of this intent.
6222 *
6223 * @see #getData
6224 */
6225 public String getScheme() {
6226 return mData != null ? mData.getScheme() : null;
6227 }
6228
6229 /**
6230 * Retrieve any explicit MIME type included in the intent. This is usually
6231 * null, as the type is determined by the intent data.
6232 *
6233 * @return If a type was manually set, it is returned; else null is
6234 * returned.
6235 *
6236 * @see #resolveType(ContentResolver)
6237 * @see #setType
6238 */
6239 public String getType() {
6240 return mType;
6241 }
6242
6243 /**
6244 * Return the MIME data type of this intent. If the type field is
6245 * explicitly set, that is simply returned. Otherwise, if the data is set,
6246 * the type of that data is returned. If neither fields are set, a null is
6247 * returned.
6248 *
6249 * @return The MIME type of this intent.
6250 *
6251 * @see #getType
6252 * @see #resolveType(ContentResolver)
6253 */
6254 public String resolveType(Context context) {
6255 return resolveType(context.getContentResolver());
6256 }
6257
6258 /**
6259 * Return the MIME data type of this intent. If the type field is
6260 * explicitly set, that is simply returned. Otherwise, if the data is set,
6261 * the type of that data is returned. If neither fields are set, a null is
6262 * returned.
6263 *
6264 * @param resolver A ContentResolver that can be used to determine the MIME
6265 * type of the intent's data.
6266 *
6267 * @return The MIME type of this intent.
6268 *
6269 * @see #getType
6270 * @see #resolveType(Context)
6271 */
6272 public String resolveType(ContentResolver resolver) {
6273 if (mType != null) {
6274 return mType;
6275 }
6276 if (mData != null) {
6277 if ("content".equals(mData.getScheme())) {
6278 return resolver.getType(mData);
6279 }
6280 }
6281 return null;
6282 }
6283
6284 /**
6285 * Return the MIME data type of this intent, only if it will be needed for
6286 * intent resolution. This is not generally useful for application code;
6287 * it is used by the frameworks for communicating with back-end system
6288 * services.
6289 *
6290 * @param resolver A ContentResolver that can be used to determine the MIME
6291 * type of the intent's data.
6292 *
6293 * @return The MIME type of this intent, or null if it is unknown or not
6294 * needed.
6295 */
6296 public String resolveTypeIfNeeded(ContentResolver resolver) {
6297 if (mComponent != null) {
6298 return mType;
6299 }
6300 return resolveType(resolver);
6301 }
6302
6303 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09006304 * Check if a category exists in the intent.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006305 *
6306 * @param category The category to check.
6307 *
6308 * @return boolean True if the intent contains the category, else false.
6309 *
6310 * @see #getCategories
6311 * @see #addCategory
6312 */
6313 public boolean hasCategory(String category) {
6314 return mCategories != null && mCategories.contains(category);
6315 }
6316
6317 /**
6318 * Return the set of all categories in the intent. If there are no categories,
6319 * returns NULL.
6320 *
Dianne Hackbornf5b86712011-12-05 17:42:41 -08006321 * @return The set of categories you can examine. Do not modify!
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006322 *
6323 * @see #hasCategory
6324 * @see #addCategory
6325 */
6326 public Set<String> getCategories() {
6327 return mCategories;
6328 }
6329
6330 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08006331 * Return the specific selector associated with this Intent. If there is
6332 * none, returns null. See {@link #setSelector} for more information.
6333 *
6334 * @see #setSelector
6335 */
6336 public Intent getSelector() {
6337 return mSelector;
6338 }
6339
6340 /**
Dianne Hackborn21c241e2012-03-08 13:57:23 -08006341 * Return the {@link ClipData} associated with this Intent. If there is
6342 * none, returns null. See {@link #setClipData} for more information.
6343 *
John Spurlock125d1332013-11-25 11:58:37 -05006344 * @see #setClipData
Dianne Hackborn21c241e2012-03-08 13:57:23 -08006345 */
6346 public ClipData getClipData() {
6347 return mClipData;
6348 }
6349
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01006350 /** @hide */
6351 public int getContentUserHint() {
6352 return mContentUserHint;
6353 }
6354
Dianne Hackborn21c241e2012-03-08 13:57:23 -08006355 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006356 * Sets the ClassLoader that will be used when unmarshalling
6357 * any Parcelable values from the extras of this Intent.
6358 *
6359 * @param loader a ClassLoader, or null to use the default loader
6360 * at the time of unmarshalling.
6361 */
6362 public void setExtrasClassLoader(ClassLoader loader) {
6363 if (mExtras != null) {
6364 mExtras.setClassLoader(loader);
6365 }
6366 }
6367
6368 /**
6369 * Returns true if an extra value is associated with the given name.
6370 * @param name the extra's name
6371 * @return true if the given extra is present.
6372 */
6373 public boolean hasExtra(String name) {
6374 return mExtras != null && mExtras.containsKey(name);
6375 }
6376
6377 /**
6378 * Returns true if the Intent's extras contain a parcelled file descriptor.
6379 * @return true if the Intent contains a parcelled file descriptor.
6380 */
6381 public boolean hasFileDescriptors() {
6382 return mExtras != null && mExtras.hasFileDescriptors();
6383 }
The Android Open Source Project10592532009-03-18 17:39:46 -07006384
Jeff Sharkeyd136e512016-03-09 22:30:56 -07006385 /** {@hide} */
Dianne Hackborn9ecebbf2011-09-28 23:19:47 -04006386 public void setAllowFds(boolean allowFds) {
6387 if (mExtras != null) {
6388 mExtras.setAllowFds(allowFds);
6389 }
6390 }
6391
Jeff Sharkeyd136e512016-03-09 22:30:56 -07006392 /** {@hide} */
6393 public void setDefusable(boolean defusable) {
6394 if (mExtras != null) {
6395 mExtras.setDefusable(defusable);
6396 }
6397 }
6398
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006399 /**
6400 * Retrieve extended data from the intent.
6401 *
6402 * @param name The name of the desired item.
6403 *
6404 * @return the value of an item that previously added with putExtra()
6405 * or null if none was found.
6406 *
6407 * @deprecated
6408 * @hide
6409 */
6410 @Deprecated
6411 public Object getExtra(String name) {
6412 return getExtra(name, null);
6413 }
6414
6415 /**
6416 * Retrieve extended data from the intent.
6417 *
6418 * @param name The name of the desired item.
6419 * @param defaultValue the value to be returned if no value of the desired
6420 * type is stored with the given name.
6421 *
6422 * @return the value of an item that previously added with putExtra()
6423 * or the default value if none was found.
6424 *
6425 * @see #putExtra(String, boolean)
6426 */
6427 public boolean getBooleanExtra(String name, boolean defaultValue) {
6428 return mExtras == null ? defaultValue :
6429 mExtras.getBoolean(name, defaultValue);
6430 }
6431
6432 /**
6433 * Retrieve extended data from the intent.
6434 *
6435 * @param name The name of the desired item.
6436 * @param defaultValue the value to be returned if no value of the desired
6437 * type is stored with the given name.
6438 *
6439 * @return the value of an item that previously added with putExtra()
6440 * or the default value if none was found.
6441 *
6442 * @see #putExtra(String, byte)
6443 */
6444 public byte getByteExtra(String name, byte defaultValue) {
6445 return mExtras == null ? defaultValue :
6446 mExtras.getByte(name, defaultValue);
6447 }
6448
6449 /**
6450 * Retrieve extended data from the intent.
6451 *
6452 * @param name The name of the desired item.
6453 * @param defaultValue the value to be returned if no value of the desired
6454 * type is stored with the given name.
6455 *
6456 * @return the value of an item that previously added with putExtra()
6457 * or the default value if none was found.
6458 *
6459 * @see #putExtra(String, short)
6460 */
6461 public short getShortExtra(String name, short defaultValue) {
6462 return mExtras == null ? defaultValue :
6463 mExtras.getShort(name, defaultValue);
6464 }
6465
6466 /**
6467 * Retrieve extended data from the intent.
6468 *
6469 * @param name The name of the desired item.
6470 * @param defaultValue the value to be returned if no value of the desired
6471 * type is stored with the given name.
6472 *
6473 * @return the value of an item that previously added with putExtra()
6474 * or the default value if none was found.
6475 *
6476 * @see #putExtra(String, char)
6477 */
6478 public char getCharExtra(String name, char defaultValue) {
6479 return mExtras == null ? defaultValue :
6480 mExtras.getChar(name, defaultValue);
6481 }
6482
6483 /**
6484 * Retrieve extended data from the intent.
6485 *
6486 * @param name The name of the desired item.
6487 * @param defaultValue the value to be returned if no value of the desired
6488 * type is stored with the given name.
6489 *
6490 * @return the value of an item that previously added with putExtra()
6491 * or the default value if none was found.
6492 *
6493 * @see #putExtra(String, int)
6494 */
6495 public int getIntExtra(String name, int defaultValue) {
6496 return mExtras == null ? defaultValue :
6497 mExtras.getInt(name, defaultValue);
6498 }
6499
6500 /**
6501 * Retrieve extended data from the intent.
6502 *
6503 * @param name The name of the desired item.
6504 * @param defaultValue the value to be returned if no value of the desired
6505 * type is stored with the given name.
6506 *
6507 * @return the value of an item that previously added with putExtra()
6508 * or the default value if none was found.
6509 *
6510 * @see #putExtra(String, long)
6511 */
6512 public long getLongExtra(String name, long defaultValue) {
6513 return mExtras == null ? defaultValue :
6514 mExtras.getLong(name, defaultValue);
6515 }
6516
6517 /**
6518 * Retrieve extended data from the intent.
6519 *
6520 * @param name The name of the desired item.
6521 * @param defaultValue the value to be returned if no value of the desired
6522 * type is stored with the given name.
6523 *
6524 * @return the value of an item that previously added with putExtra(),
6525 * or the default value if no such item is present
6526 *
6527 * @see #putExtra(String, float)
6528 */
6529 public float getFloatExtra(String name, float defaultValue) {
6530 return mExtras == null ? defaultValue :
6531 mExtras.getFloat(name, defaultValue);
6532 }
6533
6534 /**
6535 * Retrieve extended data from the intent.
6536 *
6537 * @param name The name of the desired item.
6538 * @param defaultValue the value to be returned if no value of the desired
6539 * type is stored with the given name.
6540 *
6541 * @return the value of an item that previously added with putExtra()
6542 * or the default value if none was found.
6543 *
6544 * @see #putExtra(String, double)
6545 */
6546 public double getDoubleExtra(String name, double defaultValue) {
6547 return mExtras == null ? defaultValue :
6548 mExtras.getDouble(name, defaultValue);
6549 }
6550
6551 /**
6552 * Retrieve extended data from the intent.
6553 *
6554 * @param name The name of the desired item.
6555 *
6556 * @return the value of an item that previously added with putExtra()
6557 * or null if no String value was found.
6558 *
6559 * @see #putExtra(String, String)
6560 */
6561 public String getStringExtra(String name) {
6562 return mExtras == null ? null : mExtras.getString(name);
6563 }
6564
6565 /**
6566 * Retrieve extended data from the intent.
6567 *
6568 * @param name The name of the desired item.
6569 *
6570 * @return the value of an item that previously added with putExtra()
6571 * or null if no CharSequence value was found.
6572 *
6573 * @see #putExtra(String, CharSequence)
6574 */
6575 public CharSequence getCharSequenceExtra(String name) {
6576 return mExtras == null ? null : mExtras.getCharSequence(name);
6577 }
6578
6579 /**
6580 * Retrieve extended data from the intent.
6581 *
6582 * @param name The name of the desired item.
6583 *
6584 * @return the value of an item that previously added with putExtra()
6585 * or null if no Parcelable value was found.
6586 *
6587 * @see #putExtra(String, Parcelable)
6588 */
6589 public <T extends Parcelable> T getParcelableExtra(String name) {
6590 return mExtras == null ? null : mExtras.<T>getParcelable(name);
6591 }
6592
6593 /**
6594 * Retrieve extended data from the intent.
6595 *
6596 * @param name The name of the desired item.
6597 *
6598 * @return the value of an item that previously added with putExtra()
6599 * or null if no Parcelable[] value was found.
6600 *
6601 * @see #putExtra(String, Parcelable[])
6602 */
6603 public Parcelable[] getParcelableArrayExtra(String name) {
6604 return mExtras == null ? null : mExtras.getParcelableArray(name);
6605 }
6606
6607 /**
6608 * Retrieve extended data from the intent.
6609 *
6610 * @param name The name of the desired item.
6611 *
6612 * @return the value of an item that previously added with putExtra()
6613 * or null if no ArrayList<Parcelable> value was found.
6614 *
6615 * @see #putParcelableArrayListExtra(String, ArrayList)
6616 */
6617 public <T extends Parcelable> ArrayList<T> getParcelableArrayListExtra(String name) {
6618 return mExtras == null ? null : mExtras.<T>getParcelableArrayList(name);
6619 }
6620
6621 /**
6622 * Retrieve extended data from the intent.
6623 *
6624 * @param name The name of the desired item.
6625 *
6626 * @return the value of an item that previously added with putExtra()
6627 * or null if no Serializable value was found.
6628 *
6629 * @see #putExtra(String, Serializable)
6630 */
6631 public Serializable getSerializableExtra(String name) {
6632 return mExtras == null ? null : mExtras.getSerializable(name);
6633 }
6634
6635 /**
6636 * Retrieve extended data from the intent.
6637 *
6638 * @param name The name of the desired item.
6639 *
6640 * @return the value of an item that previously added with putExtra()
6641 * or null if no ArrayList<Integer> value was found.
6642 *
6643 * @see #putIntegerArrayListExtra(String, ArrayList)
6644 */
6645 public ArrayList<Integer> getIntegerArrayListExtra(String name) {
6646 return mExtras == null ? null : mExtras.getIntegerArrayList(name);
6647 }
6648
6649 /**
6650 * Retrieve extended data from the intent.
6651 *
6652 * @param name The name of the desired item.
6653 *
6654 * @return the value of an item that previously added with putExtra()
6655 * or null if no ArrayList<String> value was found.
6656 *
6657 * @see #putStringArrayListExtra(String, ArrayList)
6658 */
6659 public ArrayList<String> getStringArrayListExtra(String name) {
6660 return mExtras == null ? null : mExtras.getStringArrayList(name);
6661 }
6662
6663 /**
6664 * Retrieve extended data from the intent.
6665 *
6666 * @param name The name of the desired item.
6667 *
6668 * @return the value of an item that previously added with putExtra()
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00006669 * or null if no ArrayList<CharSequence> value was found.
6670 *
6671 * @see #putCharSequenceArrayListExtra(String, ArrayList)
6672 */
6673 public ArrayList<CharSequence> getCharSequenceArrayListExtra(String name) {
6674 return mExtras == null ? null : mExtras.getCharSequenceArrayList(name);
6675 }
6676
6677 /**
6678 * Retrieve extended data from the intent.
6679 *
6680 * @param name The name of the desired item.
6681 *
6682 * @return the value of an item that previously added with putExtra()
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006683 * or null if no boolean array value was found.
6684 *
6685 * @see #putExtra(String, boolean[])
6686 */
6687 public boolean[] getBooleanArrayExtra(String name) {
6688 return mExtras == null ? null : mExtras.getBooleanArray(name);
6689 }
6690
6691 /**
6692 * Retrieve extended data from the intent.
6693 *
6694 * @param name The name of the desired item.
6695 *
6696 * @return the value of an item that previously added with putExtra()
6697 * or null if no byte array value was found.
6698 *
6699 * @see #putExtra(String, byte[])
6700 */
6701 public byte[] getByteArrayExtra(String name) {
6702 return mExtras == null ? null : mExtras.getByteArray(name);
6703 }
6704
6705 /**
6706 * Retrieve extended data from the intent.
6707 *
6708 * @param name The name of the desired item.
6709 *
6710 * @return the value of an item that previously added with putExtra()
6711 * or null if no short array value was found.
6712 *
6713 * @see #putExtra(String, short[])
6714 */
6715 public short[] getShortArrayExtra(String name) {
6716 return mExtras == null ? null : mExtras.getShortArray(name);
6717 }
6718
6719 /**
6720 * Retrieve extended data from the intent.
6721 *
6722 * @param name The name of the desired item.
6723 *
6724 * @return the value of an item that previously added with putExtra()
6725 * or null if no char array value was found.
6726 *
6727 * @see #putExtra(String, char[])
6728 */
6729 public char[] getCharArrayExtra(String name) {
6730 return mExtras == null ? null : mExtras.getCharArray(name);
6731 }
6732
6733 /**
6734 * Retrieve extended data from the intent.
6735 *
6736 * @param name The name of the desired item.
6737 *
6738 * @return the value of an item that previously added with putExtra()
6739 * or null if no int array value was found.
6740 *
6741 * @see #putExtra(String, int[])
6742 */
6743 public int[] getIntArrayExtra(String name) {
6744 return mExtras == null ? null : mExtras.getIntArray(name);
6745 }
6746
6747 /**
6748 * Retrieve extended data from the intent.
6749 *
6750 * @param name The name of the desired item.
6751 *
6752 * @return the value of an item that previously added with putExtra()
6753 * or null if no long array value was found.
6754 *
6755 * @see #putExtra(String, long[])
6756 */
6757 public long[] getLongArrayExtra(String name) {
6758 return mExtras == null ? null : mExtras.getLongArray(name);
6759 }
6760
6761 /**
6762 * Retrieve extended data from the intent.
6763 *
6764 * @param name The name of the desired item.
6765 *
6766 * @return the value of an item that previously added with putExtra()
6767 * or null if no float array value was found.
6768 *
6769 * @see #putExtra(String, float[])
6770 */
6771 public float[] getFloatArrayExtra(String name) {
6772 return mExtras == null ? null : mExtras.getFloatArray(name);
6773 }
6774
6775 /**
6776 * Retrieve extended data from the intent.
6777 *
6778 * @param name The name of the desired item.
6779 *
6780 * @return the value of an item that previously added with putExtra()
6781 * or null if no double array value was found.
6782 *
6783 * @see #putExtra(String, double[])
6784 */
6785 public double[] getDoubleArrayExtra(String name) {
6786 return mExtras == null ? null : mExtras.getDoubleArray(name);
6787 }
6788
6789 /**
6790 * Retrieve extended data from the intent.
6791 *
6792 * @param name The name of the desired item.
6793 *
6794 * @return the value of an item that previously added with putExtra()
6795 * or null if no String array value was found.
6796 *
6797 * @see #putExtra(String, String[])
6798 */
6799 public String[] getStringArrayExtra(String name) {
6800 return mExtras == null ? null : mExtras.getStringArray(name);
6801 }
6802
6803 /**
6804 * Retrieve extended data from the intent.
6805 *
6806 * @param name The name of the desired item.
6807 *
6808 * @return the value of an item that previously added with putExtra()
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00006809 * or null if no CharSequence array value was found.
6810 *
6811 * @see #putExtra(String, CharSequence[])
6812 */
6813 public CharSequence[] getCharSequenceArrayExtra(String name) {
6814 return mExtras == null ? null : mExtras.getCharSequenceArray(name);
6815 }
6816
6817 /**
6818 * Retrieve extended data from the intent.
6819 *
6820 * @param name The name of the desired item.
6821 *
6822 * @return the value of an item that previously added with putExtra()
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006823 * or null if no Bundle value was found.
6824 *
6825 * @see #putExtra(String, Bundle)
6826 */
6827 public Bundle getBundleExtra(String name) {
6828 return mExtras == null ? null : mExtras.getBundle(name);
6829 }
6830
6831 /**
6832 * Retrieve extended data from the intent.
6833 *
6834 * @param name The name of the desired item.
6835 *
6836 * @return the value of an item that previously added with putExtra()
6837 * or null if no IBinder value was found.
6838 *
6839 * @see #putExtra(String, IBinder)
6840 *
6841 * @deprecated
6842 * @hide
6843 */
6844 @Deprecated
6845 public IBinder getIBinderExtra(String name) {
6846 return mExtras == null ? null : mExtras.getIBinder(name);
6847 }
6848
6849 /**
6850 * Retrieve extended data from the intent.
6851 *
6852 * @param name The name of the desired item.
6853 * @param defaultValue The default value to return in case no item is
6854 * associated with the key 'name'
6855 *
6856 * @return the value of an item that previously added with putExtra()
6857 * or defaultValue if none was found.
6858 *
6859 * @see #putExtra
6860 *
6861 * @deprecated
6862 * @hide
6863 */
6864 @Deprecated
6865 public Object getExtra(String name, Object defaultValue) {
6866 Object result = defaultValue;
6867 if (mExtras != null) {
6868 Object result2 = mExtras.get(name);
6869 if (result2 != null) {
6870 result = result2;
6871 }
6872 }
6873
6874 return result;
6875 }
6876
6877 /**
6878 * Retrieves a map of extended data from the intent.
6879 *
6880 * @return the map of all extras previously added with putExtra(),
6881 * or null if none have been added.
6882 */
6883 public Bundle getExtras() {
6884 return (mExtras != null)
6885 ? new Bundle(mExtras)
6886 : null;
6887 }
6888
6889 /**
Dianne Hackborna83ce1d2015-03-11 15:16:13 -07006890 * Filter extras to only basic types.
6891 * @hide
6892 */
6893 public void removeUnsafeExtras() {
6894 if (mExtras != null) {
Dianne Hackborn851ec492016-10-12 17:20:07 -07006895 mExtras = mExtras.filterValues();
Dianne Hackborna83ce1d2015-03-11 15:16:13 -07006896 }
6897 }
6898
6899 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006900 * Retrieve any special flags associated with this intent. You will
6901 * normally just set them with {@link #setFlags} and let the system
6902 * take the appropriate action with them.
6903 *
6904 * @return int The currently set flags.
6905 *
6906 * @see #setFlags
6907 */
6908 public int getFlags() {
6909 return mFlags;
6910 }
6911
Dianne Hackborne7f97212011-02-24 14:40:20 -08006912 /** @hide */
6913 public boolean isExcludingStopped() {
6914 return (mFlags&(FLAG_EXCLUDE_STOPPED_PACKAGES|FLAG_INCLUDE_STOPPED_PACKAGES))
6915 == FLAG_EXCLUDE_STOPPED_PACKAGES;
6916 }
6917
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006918 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006919 * Retrieve the application package name this Intent is limited to. When
6920 * resolving an Intent, if non-null this limits the resolution to only
6921 * components in the given application package.
6922 *
6923 * @return The name of the application package for the Intent.
6924 *
6925 * @see #resolveActivity
6926 * @see #setPackage
6927 */
6928 public String getPackage() {
6929 return mPackage;
6930 }
6931
6932 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006933 * Retrieve the concrete component associated with the intent. When receiving
6934 * an intent, this is the component that was found to best handle it (that is,
6935 * yourself) and will always be non-null; in all other cases it will be
6936 * null unless explicitly set.
6937 *
6938 * @return The name of the application component to handle the intent.
6939 *
6940 * @see #resolveActivity
6941 * @see #setComponent
6942 */
6943 public ComponentName getComponent() {
6944 return mComponent;
6945 }
6946
6947 /**
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08006948 * Get the bounds of the sender of this intent, in screen coordinates. This can be
6949 * used as a hint to the receiver for animations and the like. Null means that there
6950 * is no source bounds.
6951 */
6952 public Rect getSourceBounds() {
6953 return mSourceBounds;
6954 }
6955
6956 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006957 * Return the Activity component that should be used to handle this intent.
6958 * The appropriate component is determined based on the information in the
6959 * intent, evaluated as follows:
6960 *
6961 * <p>If {@link #getComponent} returns an explicit class, that is returned
6962 * without any further consideration.
6963 *
6964 * <p>The activity must handle the {@link Intent#CATEGORY_DEFAULT} Intent
6965 * category to be considered.
6966 *
6967 * <p>If {@link #getAction} is non-NULL, the activity must handle this
6968 * action.
6969 *
6970 * <p>If {@link #resolveType} returns non-NULL, the activity must handle
6971 * this type.
6972 *
6973 * <p>If {@link #addCategory} has added any categories, the activity must
6974 * handle ALL of the categories specified.
6975 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006976 * <p>If {@link #getPackage} is non-NULL, only activity components in
6977 * that application package will be considered.
6978 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006979 * <p>If there are no activities that satisfy all of these conditions, a
6980 * null string is returned.
6981 *
6982 * <p>If multiple activities are found to satisfy the intent, the one with
6983 * the highest priority will be used. If there are multiple activities
6984 * with the same priority, the system will either pick the best activity
6985 * based on user preference, or resolve to a system class that will allow
6986 * the user to pick an activity and forward from there.
6987 *
6988 * <p>This method is implemented simply by calling
6989 * {@link PackageManager#resolveActivity} with the "defaultOnly" parameter
6990 * true.</p>
6991 * <p> This API is called for you as part of starting an activity from an
6992 * intent. You do not normally need to call it yourself.</p>
6993 *
6994 * @param pm The package manager with which to resolve the Intent.
6995 *
6996 * @return Name of the component implementing an activity that can
6997 * display the intent.
6998 *
6999 * @see #setComponent
7000 * @see #getComponent
7001 * @see #resolveActivityInfo
7002 */
7003 public ComponentName resolveActivity(PackageManager pm) {
7004 if (mComponent != null) {
7005 return mComponent;
7006 }
7007
7008 ResolveInfo info = pm.resolveActivity(
7009 this, PackageManager.MATCH_DEFAULT_ONLY);
7010 if (info != null) {
7011 return new ComponentName(
7012 info.activityInfo.applicationInfo.packageName,
7013 info.activityInfo.name);
7014 }
7015
7016 return null;
7017 }
7018
7019 /**
7020 * Resolve the Intent into an {@link ActivityInfo}
7021 * describing the activity that should execute the intent. Resolution
7022 * follows the same rules as described for {@link #resolveActivity}, but
7023 * you get back the completely information about the resolved activity
7024 * instead of just its class name.
7025 *
7026 * @param pm The package manager with which to resolve the Intent.
7027 * @param flags Addition information to retrieve as per
7028 * {@link PackageManager#getActivityInfo(ComponentName, int)
7029 * PackageManager.getActivityInfo()}.
7030 *
7031 * @return PackageManager.ActivityInfo
7032 *
7033 * @see #resolveActivity
7034 */
7035 public ActivityInfo resolveActivityInfo(PackageManager pm, int flags) {
7036 ActivityInfo ai = null;
7037 if (mComponent != null) {
7038 try {
7039 ai = pm.getActivityInfo(mComponent, flags);
7040 } catch (PackageManager.NameNotFoundException e) {
7041 // ignore
7042 }
7043 } else {
7044 ResolveInfo info = pm.resolveActivity(
Dianne Hackborn9bfb7072009-09-22 11:37:40 -07007045 this, PackageManager.MATCH_DEFAULT_ONLY | flags);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007046 if (info != null) {
7047 ai = info.activityInfo;
7048 }
7049 }
7050
7051 return ai;
7052 }
7053
7054 /**
Dianne Hackborn221ea892013-08-04 16:50:16 -07007055 * Special function for use by the system to resolve service
7056 * intents to system apps. Throws an exception if there are
7057 * multiple potential matches to the Intent. Returns null if
7058 * there are no matches.
7059 * @hide
7060 */
7061 public ComponentName resolveSystemService(PackageManager pm, int flags) {
7062 if (mComponent != null) {
7063 return mComponent;
7064 }
7065
7066 List<ResolveInfo> results = pm.queryIntentServices(this, flags);
7067 if (results == null) {
7068 return null;
7069 }
7070 ComponentName comp = null;
7071 for (int i=0; i<results.size(); i++) {
7072 ResolveInfo ri = results.get(i);
7073 if ((ri.serviceInfo.applicationInfo.flags&ApplicationInfo.FLAG_SYSTEM) == 0) {
7074 continue;
7075 }
7076 ComponentName foundComp = new ComponentName(ri.serviceInfo.applicationInfo.packageName,
7077 ri.serviceInfo.name);
7078 if (comp != null) {
7079 throw new IllegalStateException("Multiple system services handle " + this
7080 + ": " + comp + ", " + foundComp);
7081 }
7082 comp = foundComp;
7083 }
7084 return comp;
7085 }
7086
7087 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007088 * Set the general action to be performed.
7089 *
7090 * @param action An action name, such as ACTION_VIEW. Application-specific
7091 * actions should be prefixed with the vendor's package name.
7092 *
7093 * @return Returns the same Intent object, for chaining multiple calls
7094 * into a single statement.
7095 *
7096 * @see #getAction
7097 */
7098 public Intent setAction(String action) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08007099 mAction = action != null ? action.intern() : null;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007100 return this;
7101 }
7102
7103 /**
7104 * Set the data this intent is operating on. This method automatically
Nick Pellyccae4122012-01-09 14:12:58 -08007105 * clears any type that was previously set by {@link #setType} or
7106 * {@link #setTypeAndNormalize}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007107 *
Nick Pellyccae4122012-01-09 14:12:58 -08007108 * <p><em>Note: scheme matching in the Android framework is
7109 * case-sensitive, unlike the formal RFC. As a result,
7110 * you should always write your Uri with a lower case scheme,
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04007111 * or use {@link Uri#normalizeScheme} or
Nick Pellyccae4122012-01-09 14:12:58 -08007112 * {@link #setDataAndNormalize}
7113 * to ensure that the scheme is converted to lower case.</em>
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07007114 *
Nick Pellyccae4122012-01-09 14:12:58 -08007115 * @param data The Uri of the data this intent is now targeting.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007116 *
7117 * @return Returns the same Intent object, for chaining multiple calls
7118 * into a single statement.
7119 *
7120 * @see #getData
Nick Pellyccae4122012-01-09 14:12:58 -08007121 * @see #setDataAndNormalize
Dianne Hackborn221ea892013-08-04 16:50:16 -07007122 * @see android.net.Uri#normalizeScheme()
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007123 */
7124 public Intent setData(Uri data) {
7125 mData = data;
7126 mType = null;
7127 return this;
7128 }
7129
7130 /**
Nick Pellyccae4122012-01-09 14:12:58 -08007131 * Normalize and set the data this intent is operating on.
7132 *
7133 * <p>This method automatically clears any type that was
7134 * previously set (for example, by {@link #setType}).
7135 *
7136 * <p>The data Uri is normalized using
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04007137 * {@link android.net.Uri#normalizeScheme} before it is set,
Nick Pellyccae4122012-01-09 14:12:58 -08007138 * so really this is just a convenience method for
7139 * <pre>
7140 * setData(data.normalize())
7141 * </pre>
7142 *
7143 * @param data The Uri of the data this intent is now targeting.
7144 *
7145 * @return Returns the same Intent object, for chaining multiple calls
7146 * into a single statement.
7147 *
7148 * @see #getData
7149 * @see #setType
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04007150 * @see android.net.Uri#normalizeScheme
Nick Pellyccae4122012-01-09 14:12:58 -08007151 */
7152 public Intent setDataAndNormalize(Uri data) {
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04007153 return setData(data.normalizeScheme());
Nick Pellyccae4122012-01-09 14:12:58 -08007154 }
7155
7156 /**
7157 * Set an explicit MIME data type.
7158 *
7159 * <p>This is used to create intents that only specify a type and not data,
7160 * for example to indicate the type of data to return.
7161 *
7162 * <p>This method automatically clears any data that was
7163 * previously set (for example by {@link #setData}).
Romain Guy4969af72009-06-17 10:53:19 -07007164 *
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07007165 * <p><em>Note: MIME type matching in the Android framework is
7166 * case-sensitive, unlike formal RFC MIME types. As a result,
7167 * you should always write your MIME types with lower case letters,
Nick Pellyccae4122012-01-09 14:12:58 -08007168 * or use {@link #normalizeMimeType} or {@link #setTypeAndNormalize}
7169 * to ensure that it is converted to lower case.</em>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007170 *
7171 * @param type The MIME type of the data being handled by this intent.
7172 *
7173 * @return Returns the same Intent object, for chaining multiple calls
7174 * into a single statement.
7175 *
7176 * @see #getType
Nick Pellyccae4122012-01-09 14:12:58 -08007177 * @see #setTypeAndNormalize
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007178 * @see #setDataAndType
Nick Pellyccae4122012-01-09 14:12:58 -08007179 * @see #normalizeMimeType
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007180 */
7181 public Intent setType(String type) {
7182 mData = null;
7183 mType = type;
7184 return this;
7185 }
7186
7187 /**
Nick Pellyccae4122012-01-09 14:12:58 -08007188 * Normalize and set an explicit MIME data type.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007189 *
Nick Pellyccae4122012-01-09 14:12:58 -08007190 * <p>This is used to create intents that only specify a type and not data,
7191 * for example to indicate the type of data to return.
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07007192 *
Nick Pellyccae4122012-01-09 14:12:58 -08007193 * <p>This method automatically clears any data that was
7194 * previously set (for example by {@link #setData}).
7195 *
7196 * <p>The MIME type is normalized using
7197 * {@link #normalizeMimeType} before it is set,
7198 * so really this is just a convenience method for
7199 * <pre>
7200 * setType(Intent.normalizeMimeType(type))
7201 * </pre>
7202 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007203 * @param type The MIME type of the data being handled by this intent.
7204 *
7205 * @return Returns the same Intent object, for chaining multiple calls
7206 * into a single statement.
7207 *
Nick Pellyccae4122012-01-09 14:12:58 -08007208 * @see #getType
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007209 * @see #setData
Nick Pellyccae4122012-01-09 14:12:58 -08007210 * @see #normalizeMimeType
7211 */
7212 public Intent setTypeAndNormalize(String type) {
7213 return setType(normalizeMimeType(type));
7214 }
7215
7216 /**
7217 * (Usually optional) Set the data for the intent along with an explicit
7218 * MIME data type. This method should very rarely be used -- it allows you
7219 * to override the MIME type that would ordinarily be inferred from the
7220 * data with your own type given here.
7221 *
7222 * <p><em>Note: MIME type and Uri scheme matching in the
7223 * Android framework is case-sensitive, unlike the formal RFC definitions.
7224 * As a result, you should always write these elements with lower case letters,
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04007225 * or use {@link #normalizeMimeType} or {@link android.net.Uri#normalizeScheme} or
Nick Pellyccae4122012-01-09 14:12:58 -08007226 * {@link #setDataAndTypeAndNormalize}
7227 * to ensure that they are converted to lower case.</em>
7228 *
7229 * @param data The Uri of the data this intent is now targeting.
7230 * @param type The MIME type of the data being handled by this intent.
7231 *
7232 * @return Returns the same Intent object, for chaining multiple calls
7233 * into a single statement.
7234 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007235 * @see #setType
Nick Pellyccae4122012-01-09 14:12:58 -08007236 * @see #setData
7237 * @see #normalizeMimeType
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04007238 * @see android.net.Uri#normalizeScheme
Nick Pellyccae4122012-01-09 14:12:58 -08007239 * @see #setDataAndTypeAndNormalize
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007240 */
7241 public Intent setDataAndType(Uri data, String type) {
7242 mData = data;
7243 mType = type;
7244 return this;
7245 }
7246
7247 /**
Nick Pellyccae4122012-01-09 14:12:58 -08007248 * (Usually optional) Normalize and set both the data Uri and an explicit
7249 * MIME data type. This method should very rarely be used -- it allows you
7250 * to override the MIME type that would ordinarily be inferred from the
7251 * data with your own type given here.
7252 *
7253 * <p>The data Uri and the MIME type are normalize using
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04007254 * {@link android.net.Uri#normalizeScheme} and {@link #normalizeMimeType}
Nick Pellyccae4122012-01-09 14:12:58 -08007255 * before they are set, so really this is just a convenience method for
7256 * <pre>
7257 * setDataAndType(data.normalize(), Intent.normalizeMimeType(type))
7258 * </pre>
7259 *
7260 * @param data The Uri of the data this intent is now targeting.
7261 * @param type The MIME type of the data being handled by this intent.
7262 *
7263 * @return Returns the same Intent object, for chaining multiple calls
7264 * into a single statement.
7265 *
7266 * @see #setType
7267 * @see #setData
7268 * @see #setDataAndType
7269 * @see #normalizeMimeType
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04007270 * @see android.net.Uri#normalizeScheme
Nick Pellyccae4122012-01-09 14:12:58 -08007271 */
7272 public Intent setDataAndTypeAndNormalize(Uri data, String type) {
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04007273 return setDataAndType(data.normalizeScheme(), normalizeMimeType(type));
Nick Pellyccae4122012-01-09 14:12:58 -08007274 }
7275
7276 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007277 * Add a new category to the intent. Categories provide additional detail
Ken Wakasaf76a50c2012-03-09 19:56:35 +09007278 * about the action the intent performs. When resolving an intent, only
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007279 * activities that provide <em>all</em> of the requested categories will be
7280 * used.
7281 *
7282 * @param category The desired category. This can be either one of the
7283 * predefined Intent categories, or a custom category in your own
7284 * namespace.
7285 *
7286 * @return Returns the same Intent object, for chaining multiple calls
7287 * into a single statement.
7288 *
7289 * @see #hasCategory
7290 * @see #removeCategory
7291 */
7292 public Intent addCategory(String category) {
7293 if (mCategories == null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07007294 mCategories = new ArraySet<String>();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007295 }
Jeff Brown2c376fc2011-01-28 17:34:01 -08007296 mCategories.add(category.intern());
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007297 return this;
7298 }
7299
7300 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09007301 * Remove a category from an intent.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007302 *
7303 * @param category The category to remove.
7304 *
7305 * @see #addCategory
7306 */
7307 public void removeCategory(String category) {
7308 if (mCategories != null) {
7309 mCategories.remove(category);
7310 if (mCategories.size() == 0) {
7311 mCategories = null;
7312 }
7313 }
7314 }
7315
7316 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08007317 * Set a selector for this Intent. This is a modification to the kinds of
7318 * things the Intent will match. If the selector is set, it will be used
7319 * when trying to find entities that can handle the Intent, instead of the
7320 * main contents of the Intent. This allows you build an Intent containing
7321 * a generic protocol while targeting it more specifically.
7322 *
7323 * <p>An example of where this may be used is with things like
7324 * {@link #CATEGORY_APP_BROWSER}. This category allows you to build an
7325 * Intent that will launch the Browser application. However, the correct
7326 * main entry point of an application is actually {@link #ACTION_MAIN}
7327 * {@link #CATEGORY_LAUNCHER} with {@link #setComponent(ComponentName)}
7328 * used to specify the actual Activity to launch. If you launch the browser
7329 * with something different, undesired behavior may happen if the user has
7330 * previously or later launches it the normal way, since they do not match.
7331 * Instead, you can build an Intent with the MAIN action (but no ComponentName
7332 * yet specified) and set a selector with {@link #ACTION_MAIN} and
7333 * {@link #CATEGORY_APP_BROWSER} to point it specifically to the browser activity.
7334 *
7335 * <p>Setting a selector does not impact the behavior of
7336 * {@link #filterEquals(Intent)} and {@link #filterHashCode()}. This is part of the
7337 * desired behavior of a selector -- it does not impact the base meaning
7338 * of the Intent, just what kinds of things will be matched against it
7339 * when determining who can handle it.</p>
7340 *
7341 * <p>You can not use both a selector and {@link #setPackage(String)} on
7342 * the same base Intent.</p>
7343 *
7344 * @param selector The desired selector Intent; set to null to not use
7345 * a special selector.
7346 */
7347 public void setSelector(Intent selector) {
7348 if (selector == this) {
7349 throw new IllegalArgumentException(
7350 "Intent being set as a selector of itself");
7351 }
7352 if (selector != null && mPackage != null) {
7353 throw new IllegalArgumentException(
7354 "Can't set selector when package name is already set");
7355 }
7356 mSelector = selector;
7357 }
7358
7359 /**
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007360 * Set a {@link ClipData} associated with this Intent. This replaces any
7361 * previously set ClipData.
7362 *
7363 * <p>The ClipData in an intent is not used for Intent matching or other
7364 * such operations. Semantically it is like extras, used to transmit
7365 * additional data with the Intent. The main feature of using this over
7366 * the extras for data is that {@link #FLAG_GRANT_READ_URI_PERMISSION}
7367 * and {@link #FLAG_GRANT_WRITE_URI_PERMISSION} will operate on any URI
7368 * items included in the clip data. This is useful, in particular, if
7369 * you want to transmit an Intent containing multiple <code>content:</code>
7370 * URIs for which the recipient may not have global permission to access the
7371 * content provider.
7372 *
7373 * <p>If the ClipData contains items that are themselves Intents, any
7374 * grant flags in those Intents will be ignored. Only the top-level flags
7375 * of the main Intent are respected, and will be applied to all Uri or
7376 * Intent items in the clip (or sub-items of the clip).
7377 *
7378 * <p>The MIME type, label, and icon in the ClipData object are not
7379 * directly used by Intent. Applications should generally rely on the
7380 * MIME type of the Intent itself, not what it may find in the ClipData.
7381 * A common practice is to construct a ClipData for use with an Intent
John Spurlock33900182014-01-02 11:04:18 -05007382 * with a MIME type of "*&#47;*".
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007383 *
7384 * @param clip The new clip to set. May be null to clear the current clip.
7385 */
7386 public void setClipData(ClipData clip) {
7387 mClipData = clip;
7388 }
7389
7390 /**
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01007391 * This is NOT a secure mechanism to identify the user who sent the intent.
7392 * When the intent is sent to a different user, it is used to fix uris by adding the userId
7393 * who sent the intent.
7394 * @hide
7395 */
Nicolas Prevot107f7b72015-07-01 16:31:48 +01007396 public void prepareToLeaveUser(int userId) {
7397 // If mContentUserHint is not UserHandle.USER_CURRENT, the intent has already left a user.
7398 // We want mContentUserHint to refer to the original user, so don't do anything.
7399 if (mContentUserHint == UserHandle.USER_CURRENT) {
7400 mContentUserHint = userId;
7401 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01007402 }
7403
7404 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007405 * Add extended data to the intent. The name must include a package
7406 * prefix, for example the app com.android.contacts would use names
7407 * like "com.android.contacts.ShowAll".
7408 *
7409 * @param name The name of the extra data, with package prefix.
7410 * @param value The boolean data value.
7411 *
7412 * @return Returns the same Intent object, for chaining multiple calls
7413 * into a single statement.
7414 *
7415 * @see #putExtras
7416 * @see #removeExtra
7417 * @see #getBooleanExtra(String, boolean)
7418 */
7419 public Intent putExtra(String name, boolean value) {
7420 if (mExtras == null) {
7421 mExtras = new Bundle();
7422 }
7423 mExtras.putBoolean(name, value);
7424 return this;
7425 }
7426
7427 /**
7428 * Add extended data to the intent. The name must include a package
7429 * prefix, for example the app com.android.contacts would use names
7430 * like "com.android.contacts.ShowAll".
7431 *
7432 * @param name The name of the extra data, with package prefix.
7433 * @param value The byte data value.
7434 *
7435 * @return Returns the same Intent object, for chaining multiple calls
7436 * into a single statement.
7437 *
7438 * @see #putExtras
7439 * @see #removeExtra
7440 * @see #getByteExtra(String, byte)
7441 */
7442 public Intent putExtra(String name, byte value) {
7443 if (mExtras == null) {
7444 mExtras = new Bundle();
7445 }
7446 mExtras.putByte(name, value);
7447 return this;
7448 }
7449
7450 /**
7451 * Add extended data to the intent. The name must include a package
7452 * prefix, for example the app com.android.contacts would use names
7453 * like "com.android.contacts.ShowAll".
7454 *
7455 * @param name The name of the extra data, with package prefix.
7456 * @param value The char data value.
7457 *
7458 * @return Returns the same Intent object, for chaining multiple calls
7459 * into a single statement.
7460 *
7461 * @see #putExtras
7462 * @see #removeExtra
7463 * @see #getCharExtra(String, char)
7464 */
7465 public Intent putExtra(String name, char value) {
7466 if (mExtras == null) {
7467 mExtras = new Bundle();
7468 }
7469 mExtras.putChar(name, value);
7470 return this;
7471 }
7472
7473 /**
7474 * Add extended data to the intent. The name must include a package
7475 * prefix, for example the app com.android.contacts would use names
7476 * like "com.android.contacts.ShowAll".
7477 *
7478 * @param name The name of the extra data, with package prefix.
7479 * @param value The short data value.
7480 *
7481 * @return Returns the same Intent object, for chaining multiple calls
7482 * into a single statement.
7483 *
7484 * @see #putExtras
7485 * @see #removeExtra
7486 * @see #getShortExtra(String, short)
7487 */
7488 public Intent putExtra(String name, short value) {
7489 if (mExtras == null) {
7490 mExtras = new Bundle();
7491 }
7492 mExtras.putShort(name, value);
7493 return this;
7494 }
7495
7496 /**
7497 * Add extended data to the intent. The name must include a package
7498 * prefix, for example the app com.android.contacts would use names
7499 * like "com.android.contacts.ShowAll".
7500 *
7501 * @param name The name of the extra data, with package prefix.
7502 * @param value The integer data value.
7503 *
7504 * @return Returns the same Intent object, for chaining multiple calls
7505 * into a single statement.
7506 *
7507 * @see #putExtras
7508 * @see #removeExtra
7509 * @see #getIntExtra(String, int)
7510 */
7511 public Intent putExtra(String name, int value) {
7512 if (mExtras == null) {
7513 mExtras = new Bundle();
7514 }
7515 mExtras.putInt(name, value);
7516 return this;
7517 }
7518
7519 /**
7520 * Add extended data to the intent. The name must include a package
7521 * prefix, for example the app com.android.contacts would use names
7522 * like "com.android.contacts.ShowAll".
7523 *
7524 * @param name The name of the extra data, with package prefix.
7525 * @param value The long data value.
7526 *
7527 * @return Returns the same Intent object, for chaining multiple calls
7528 * into a single statement.
7529 *
7530 * @see #putExtras
7531 * @see #removeExtra
7532 * @see #getLongExtra(String, long)
7533 */
7534 public Intent putExtra(String name, long value) {
7535 if (mExtras == null) {
7536 mExtras = new Bundle();
7537 }
7538 mExtras.putLong(name, value);
7539 return this;
7540 }
7541
7542 /**
7543 * Add extended data to the intent. The name must include a package
7544 * prefix, for example the app com.android.contacts would use names
7545 * like "com.android.contacts.ShowAll".
7546 *
7547 * @param name The name of the extra data, with package prefix.
7548 * @param value The float data value.
7549 *
7550 * @return Returns the same Intent object, for chaining multiple calls
7551 * into a single statement.
7552 *
7553 * @see #putExtras
7554 * @see #removeExtra
7555 * @see #getFloatExtra(String, float)
7556 */
7557 public Intent putExtra(String name, float value) {
7558 if (mExtras == null) {
7559 mExtras = new Bundle();
7560 }
7561 mExtras.putFloat(name, value);
7562 return this;
7563 }
7564
7565 /**
7566 * Add extended data to the intent. The name must include a package
7567 * prefix, for example the app com.android.contacts would use names
7568 * like "com.android.contacts.ShowAll".
7569 *
7570 * @param name The name of the extra data, with package prefix.
7571 * @param value The double data value.
7572 *
7573 * @return Returns the same Intent object, for chaining multiple calls
7574 * into a single statement.
7575 *
7576 * @see #putExtras
7577 * @see #removeExtra
7578 * @see #getDoubleExtra(String, double)
7579 */
7580 public Intent putExtra(String name, double value) {
7581 if (mExtras == null) {
7582 mExtras = new Bundle();
7583 }
7584 mExtras.putDouble(name, value);
7585 return this;
7586 }
7587
7588 /**
7589 * Add extended data to the intent. The name must include a package
7590 * prefix, for example the app com.android.contacts would use names
7591 * like "com.android.contacts.ShowAll".
7592 *
7593 * @param name The name of the extra data, with package prefix.
7594 * @param value The String data value.
7595 *
7596 * @return Returns the same Intent object, for chaining multiple calls
7597 * into a single statement.
7598 *
7599 * @see #putExtras
7600 * @see #removeExtra
7601 * @see #getStringExtra(String)
7602 */
7603 public Intent putExtra(String name, String value) {
7604 if (mExtras == null) {
7605 mExtras = new Bundle();
7606 }
7607 mExtras.putString(name, value);
7608 return this;
7609 }
7610
7611 /**
7612 * Add extended data to the intent. The name must include a package
7613 * prefix, for example the app com.android.contacts would use names
7614 * like "com.android.contacts.ShowAll".
7615 *
7616 * @param name The name of the extra data, with package prefix.
7617 * @param value The CharSequence data value.
7618 *
7619 * @return Returns the same Intent object, for chaining multiple calls
7620 * into a single statement.
7621 *
7622 * @see #putExtras
7623 * @see #removeExtra
7624 * @see #getCharSequenceExtra(String)
7625 */
7626 public Intent putExtra(String name, CharSequence value) {
7627 if (mExtras == null) {
7628 mExtras = new Bundle();
7629 }
7630 mExtras.putCharSequence(name, value);
7631 return this;
7632 }
7633
7634 /**
7635 * Add extended data to the intent. The name must include a package
7636 * prefix, for example the app com.android.contacts would use names
7637 * like "com.android.contacts.ShowAll".
7638 *
7639 * @param name The name of the extra data, with package prefix.
7640 * @param value The Parcelable data value.
7641 *
7642 * @return Returns the same Intent object, for chaining multiple calls
7643 * into a single statement.
7644 *
7645 * @see #putExtras
7646 * @see #removeExtra
7647 * @see #getParcelableExtra(String)
7648 */
7649 public Intent putExtra(String name, Parcelable value) {
7650 if (mExtras == null) {
7651 mExtras = new Bundle();
7652 }
7653 mExtras.putParcelable(name, value);
7654 return this;
7655 }
7656
7657 /**
7658 * Add extended data to the intent. The name must include a package
7659 * prefix, for example the app com.android.contacts would use names
7660 * like "com.android.contacts.ShowAll".
7661 *
7662 * @param name The name of the extra data, with package prefix.
7663 * @param value The Parcelable[] data value.
7664 *
7665 * @return Returns the same Intent object, for chaining multiple calls
7666 * into a single statement.
7667 *
7668 * @see #putExtras
7669 * @see #removeExtra
7670 * @see #getParcelableArrayExtra(String)
7671 */
7672 public Intent putExtra(String name, Parcelable[] value) {
7673 if (mExtras == null) {
7674 mExtras = new Bundle();
7675 }
7676 mExtras.putParcelableArray(name, value);
7677 return this;
7678 }
7679
7680 /**
7681 * Add extended data to the intent. The name must include a package
7682 * prefix, for example the app com.android.contacts would use names
7683 * like "com.android.contacts.ShowAll".
7684 *
7685 * @param name The name of the extra data, with package prefix.
7686 * @param value The ArrayList<Parcelable> data value.
7687 *
7688 * @return Returns the same Intent object, for chaining multiple calls
7689 * into a single statement.
7690 *
7691 * @see #putExtras
7692 * @see #removeExtra
7693 * @see #getParcelableArrayListExtra(String)
7694 */
7695 public Intent putParcelableArrayListExtra(String name, ArrayList<? extends Parcelable> value) {
7696 if (mExtras == null) {
7697 mExtras = new Bundle();
7698 }
7699 mExtras.putParcelableArrayList(name, value);
7700 return this;
7701 }
7702
7703 /**
7704 * Add extended data to the intent. The name must include a package
7705 * prefix, for example the app com.android.contacts would use names
7706 * like "com.android.contacts.ShowAll".
7707 *
7708 * @param name The name of the extra data, with package prefix.
7709 * @param value The ArrayList<Integer> data value.
7710 *
7711 * @return Returns the same Intent object, for chaining multiple calls
7712 * into a single statement.
7713 *
7714 * @see #putExtras
7715 * @see #removeExtra
7716 * @see #getIntegerArrayListExtra(String)
7717 */
7718 public Intent putIntegerArrayListExtra(String name, ArrayList<Integer> value) {
7719 if (mExtras == null) {
7720 mExtras = new Bundle();
7721 }
7722 mExtras.putIntegerArrayList(name, value);
7723 return this;
7724 }
7725
7726 /**
7727 * Add extended data to the intent. The name must include a package
7728 * prefix, for example the app com.android.contacts would use names
7729 * like "com.android.contacts.ShowAll".
7730 *
7731 * @param name The name of the extra data, with package prefix.
7732 * @param value The ArrayList<String> data value.
7733 *
7734 * @return Returns the same Intent object, for chaining multiple calls
7735 * into a single statement.
7736 *
7737 * @see #putExtras
7738 * @see #removeExtra
7739 * @see #getStringArrayListExtra(String)
7740 */
7741 public Intent putStringArrayListExtra(String name, ArrayList<String> value) {
7742 if (mExtras == null) {
7743 mExtras = new Bundle();
7744 }
7745 mExtras.putStringArrayList(name, value);
7746 return this;
7747 }
7748
7749 /**
7750 * Add extended data to the intent. The name must include a package
7751 * prefix, for example the app com.android.contacts would use names
7752 * like "com.android.contacts.ShowAll".
7753 *
7754 * @param name The name of the extra data, with package prefix.
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00007755 * @param value The ArrayList<CharSequence> data value.
7756 *
7757 * @return Returns the same Intent object, for chaining multiple calls
7758 * into a single statement.
7759 *
7760 * @see #putExtras
7761 * @see #removeExtra
7762 * @see #getCharSequenceArrayListExtra(String)
7763 */
7764 public Intent putCharSequenceArrayListExtra(String name, ArrayList<CharSequence> value) {
7765 if (mExtras == null) {
7766 mExtras = new Bundle();
7767 }
7768 mExtras.putCharSequenceArrayList(name, value);
7769 return this;
7770 }
7771
7772 /**
7773 * Add extended data to the intent. The name must include a package
7774 * prefix, for example the app com.android.contacts would use names
7775 * like "com.android.contacts.ShowAll".
7776 *
7777 * @param name The name of the extra data, with package prefix.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007778 * @param value The Serializable data value.
7779 *
7780 * @return Returns the same Intent object, for chaining multiple calls
7781 * into a single statement.
7782 *
7783 * @see #putExtras
7784 * @see #removeExtra
7785 * @see #getSerializableExtra(String)
7786 */
7787 public Intent putExtra(String name, Serializable value) {
7788 if (mExtras == null) {
7789 mExtras = new Bundle();
7790 }
7791 mExtras.putSerializable(name, value);
7792 return this;
7793 }
7794
7795 /**
7796 * Add extended data to the intent. The name must include a package
7797 * prefix, for example the app com.android.contacts would use names
7798 * like "com.android.contacts.ShowAll".
7799 *
7800 * @param name The name of the extra data, with package prefix.
7801 * @param value The boolean array data value.
7802 *
7803 * @return Returns the same Intent object, for chaining multiple calls
7804 * into a single statement.
7805 *
7806 * @see #putExtras
7807 * @see #removeExtra
7808 * @see #getBooleanArrayExtra(String)
7809 */
7810 public Intent putExtra(String name, boolean[] value) {
7811 if (mExtras == null) {
7812 mExtras = new Bundle();
7813 }
7814 mExtras.putBooleanArray(name, value);
7815 return this;
7816 }
7817
7818 /**
7819 * Add extended data to the intent. The name must include a package
7820 * prefix, for example the app com.android.contacts would use names
7821 * like "com.android.contacts.ShowAll".
7822 *
7823 * @param name The name of the extra data, with package prefix.
7824 * @param value The byte array data value.
7825 *
7826 * @return Returns the same Intent object, for chaining multiple calls
7827 * into a single statement.
7828 *
7829 * @see #putExtras
7830 * @see #removeExtra
7831 * @see #getByteArrayExtra(String)
7832 */
7833 public Intent putExtra(String name, byte[] value) {
7834 if (mExtras == null) {
7835 mExtras = new Bundle();
7836 }
7837 mExtras.putByteArray(name, value);
7838 return this;
7839 }
7840
7841 /**
7842 * Add extended data to the intent. The name must include a package
7843 * prefix, for example the app com.android.contacts would use names
7844 * like "com.android.contacts.ShowAll".
7845 *
7846 * @param name The name of the extra data, with package prefix.
7847 * @param value The short array data value.
7848 *
7849 * @return Returns the same Intent object, for chaining multiple calls
7850 * into a single statement.
7851 *
7852 * @see #putExtras
7853 * @see #removeExtra
7854 * @see #getShortArrayExtra(String)
7855 */
7856 public Intent putExtra(String name, short[] value) {
7857 if (mExtras == null) {
7858 mExtras = new Bundle();
7859 }
7860 mExtras.putShortArray(name, value);
7861 return this;
7862 }
7863
7864 /**
7865 * Add extended data to the intent. The name must include a package
7866 * prefix, for example the app com.android.contacts would use names
7867 * like "com.android.contacts.ShowAll".
7868 *
7869 * @param name The name of the extra data, with package prefix.
7870 * @param value The char array data value.
7871 *
7872 * @return Returns the same Intent object, for chaining multiple calls
7873 * into a single statement.
7874 *
7875 * @see #putExtras
7876 * @see #removeExtra
7877 * @see #getCharArrayExtra(String)
7878 */
7879 public Intent putExtra(String name, char[] value) {
7880 if (mExtras == null) {
7881 mExtras = new Bundle();
7882 }
7883 mExtras.putCharArray(name, value);
7884 return this;
7885 }
7886
7887 /**
7888 * Add extended data to the intent. The name must include a package
7889 * prefix, for example the app com.android.contacts would use names
7890 * like "com.android.contacts.ShowAll".
7891 *
7892 * @param name The name of the extra data, with package prefix.
7893 * @param value The int array data value.
7894 *
7895 * @return Returns the same Intent object, for chaining multiple calls
7896 * into a single statement.
7897 *
7898 * @see #putExtras
7899 * @see #removeExtra
7900 * @see #getIntArrayExtra(String)
7901 */
7902 public Intent putExtra(String name, int[] value) {
7903 if (mExtras == null) {
7904 mExtras = new Bundle();
7905 }
7906 mExtras.putIntArray(name, value);
7907 return this;
7908 }
7909
7910 /**
7911 * Add extended data to the intent. The name must include a package
7912 * prefix, for example the app com.android.contacts would use names
7913 * like "com.android.contacts.ShowAll".
7914 *
7915 * @param name The name of the extra data, with package prefix.
7916 * @param value The byte array data value.
7917 *
7918 * @return Returns the same Intent object, for chaining multiple calls
7919 * into a single statement.
7920 *
7921 * @see #putExtras
7922 * @see #removeExtra
7923 * @see #getLongArrayExtra(String)
7924 */
7925 public Intent putExtra(String name, long[] value) {
7926 if (mExtras == null) {
7927 mExtras = new Bundle();
7928 }
7929 mExtras.putLongArray(name, value);
7930 return this;
7931 }
7932
7933 /**
7934 * Add extended data to the intent. The name must include a package
7935 * prefix, for example the app com.android.contacts would use names
7936 * like "com.android.contacts.ShowAll".
7937 *
7938 * @param name The name of the extra data, with package prefix.
7939 * @param value The float array data value.
7940 *
7941 * @return Returns the same Intent object, for chaining multiple calls
7942 * into a single statement.
7943 *
7944 * @see #putExtras
7945 * @see #removeExtra
7946 * @see #getFloatArrayExtra(String)
7947 */
7948 public Intent putExtra(String name, float[] value) {
7949 if (mExtras == null) {
7950 mExtras = new Bundle();
7951 }
7952 mExtras.putFloatArray(name, value);
7953 return this;
7954 }
7955
7956 /**
7957 * Add extended data to the intent. The name must include a package
7958 * prefix, for example the app com.android.contacts would use names
7959 * like "com.android.contacts.ShowAll".
7960 *
7961 * @param name The name of the extra data, with package prefix.
7962 * @param value The double array data value.
7963 *
7964 * @return Returns the same Intent object, for chaining multiple calls
7965 * into a single statement.
7966 *
7967 * @see #putExtras
7968 * @see #removeExtra
7969 * @see #getDoubleArrayExtra(String)
7970 */
7971 public Intent putExtra(String name, double[] value) {
7972 if (mExtras == null) {
7973 mExtras = new Bundle();
7974 }
7975 mExtras.putDoubleArray(name, value);
7976 return this;
7977 }
7978
7979 /**
7980 * Add extended data to the intent. The name must include a package
7981 * prefix, for example the app com.android.contacts would use names
7982 * like "com.android.contacts.ShowAll".
7983 *
7984 * @param name The name of the extra data, with package prefix.
7985 * @param value The String array data value.
7986 *
7987 * @return Returns the same Intent object, for chaining multiple calls
7988 * into a single statement.
7989 *
7990 * @see #putExtras
7991 * @see #removeExtra
7992 * @see #getStringArrayExtra(String)
7993 */
7994 public Intent putExtra(String name, String[] value) {
7995 if (mExtras == null) {
7996 mExtras = new Bundle();
7997 }
7998 mExtras.putStringArray(name, value);
7999 return this;
8000 }
8001
8002 /**
8003 * Add extended data to the intent. The name must include a package
8004 * prefix, for example the app com.android.contacts would use names
8005 * like "com.android.contacts.ShowAll".
8006 *
8007 * @param name The name of the extra data, with package prefix.
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00008008 * @param value The CharSequence array data value.
8009 *
8010 * @return Returns the same Intent object, for chaining multiple calls
8011 * into a single statement.
8012 *
8013 * @see #putExtras
8014 * @see #removeExtra
8015 * @see #getCharSequenceArrayExtra(String)
8016 */
8017 public Intent putExtra(String name, CharSequence[] value) {
8018 if (mExtras == null) {
8019 mExtras = new Bundle();
8020 }
8021 mExtras.putCharSequenceArray(name, value);
8022 return this;
8023 }
8024
8025 /**
8026 * Add extended data to the intent. The name must include a package
8027 * prefix, for example the app com.android.contacts would use names
8028 * like "com.android.contacts.ShowAll".
8029 *
8030 * @param name The name of the extra data, with package prefix.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008031 * @param value The Bundle data value.
8032 *
8033 * @return Returns the same Intent object, for chaining multiple calls
8034 * into a single statement.
8035 *
8036 * @see #putExtras
8037 * @see #removeExtra
8038 * @see #getBundleExtra(String)
8039 */
8040 public Intent putExtra(String name, Bundle value) {
8041 if (mExtras == null) {
8042 mExtras = new Bundle();
8043 }
8044 mExtras.putBundle(name, value);
8045 return this;
8046 }
8047
8048 /**
8049 * Add extended data to the intent. The name must include a package
8050 * prefix, for example the app com.android.contacts would use names
8051 * like "com.android.contacts.ShowAll".
8052 *
8053 * @param name The name of the extra data, with package prefix.
8054 * @param value The IBinder data value.
8055 *
8056 * @return Returns the same Intent object, for chaining multiple calls
8057 * into a single statement.
8058 *
8059 * @see #putExtras
8060 * @see #removeExtra
8061 * @see #getIBinderExtra(String)
8062 *
8063 * @deprecated
8064 * @hide
8065 */
8066 @Deprecated
8067 public Intent putExtra(String name, IBinder value) {
8068 if (mExtras == null) {
8069 mExtras = new Bundle();
8070 }
8071 mExtras.putIBinder(name, value);
8072 return this;
8073 }
8074
8075 /**
8076 * Copy all extras in 'src' in to this intent.
8077 *
8078 * @param src Contains the extras to copy.
8079 *
8080 * @see #putExtra
8081 */
8082 public Intent putExtras(Intent src) {
8083 if (src.mExtras != null) {
8084 if (mExtras == null) {
8085 mExtras = new Bundle(src.mExtras);
8086 } else {
8087 mExtras.putAll(src.mExtras);
8088 }
8089 }
8090 return this;
8091 }
8092
8093 /**
8094 * Add a set of extended data to the intent. The keys must include a package
8095 * prefix, for example the app com.android.contacts would use names
8096 * like "com.android.contacts.ShowAll".
8097 *
8098 * @param extras The Bundle of extras to add to this intent.
8099 *
8100 * @see #putExtra
8101 * @see #removeExtra
8102 */
8103 public Intent putExtras(Bundle extras) {
8104 if (mExtras == null) {
8105 mExtras = new Bundle();
8106 }
8107 mExtras.putAll(extras);
8108 return this;
8109 }
8110
8111 /**
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08008112 * Completely replace the extras in the Intent with the extras in the
8113 * given Intent.
The Android Open Source Project10592532009-03-18 17:39:46 -07008114 *
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08008115 * @param src The exact extras contained in this Intent are copied
8116 * into the target intent, replacing any that were previously there.
8117 */
8118 public Intent replaceExtras(Intent src) {
8119 mExtras = src.mExtras != null ? new Bundle(src.mExtras) : null;
8120 return this;
8121 }
The Android Open Source Project10592532009-03-18 17:39:46 -07008122
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08008123 /**
8124 * Completely replace the extras in the Intent with the given Bundle of
8125 * extras.
The Android Open Source Project10592532009-03-18 17:39:46 -07008126 *
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08008127 * @param extras The new set of extras in the Intent, or null to erase
8128 * all extras.
8129 */
8130 public Intent replaceExtras(Bundle extras) {
8131 mExtras = extras != null ? new Bundle(extras) : null;
8132 return this;
8133 }
The Android Open Source Project10592532009-03-18 17:39:46 -07008134
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08008135 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008136 * Remove extended data from the intent.
8137 *
8138 * @see #putExtra
8139 */
8140 public void removeExtra(String name) {
8141 if (mExtras != null) {
8142 mExtras.remove(name);
8143 if (mExtras.size() == 0) {
8144 mExtras = null;
8145 }
8146 }
8147 }
8148
8149 /**
8150 * Set special flags controlling how this intent is handled. Most values
8151 * here depend on the type of component being executed by the Intent,
8152 * specifically the FLAG_ACTIVITY_* flags are all for use with
8153 * {@link Context#startActivity Context.startActivity()} and the
8154 * FLAG_RECEIVER_* flags are all for use with
8155 * {@link Context#sendBroadcast(Intent) Context.sendBroadcast()}.
8156 *
Scott Main7aee61f2011-02-08 11:25:01 -08008157 * <p>See the
8158 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
8159 * Stack</a> documentation for important information on how some of these options impact
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008160 * the behavior of your application.
8161 *
8162 * @param flags The desired flags.
8163 *
8164 * @return Returns the same Intent object, for chaining multiple calls
8165 * into a single statement.
8166 *
8167 * @see #getFlags
8168 * @see #addFlags
Jeff Sharkey6a34e562016-12-21 09:56:00 -07008169 * @see #removeFlags
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008170 *
8171 * @see #FLAG_GRANT_READ_URI_PERMISSION
8172 * @see #FLAG_GRANT_WRITE_URI_PERMISSION
Jeff Sharkey846318a2014-04-04 12:12:41 -07008173 * @see #FLAG_GRANT_PERSISTABLE_URI_PERMISSION
8174 * @see #FLAG_GRANT_PREFIX_URI_PERMISSION
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008175 * @see #FLAG_DEBUG_LOG_RESOLUTION
8176 * @see #FLAG_FROM_BACKGROUND
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008177 * @see #FLAG_ACTIVITY_BROUGHT_TO_FRONT
Dianne Hackborn621e17d2010-11-22 15:59:56 -08008178 * @see #FLAG_ACTIVITY_CLEAR_TASK
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008179 * @see #FLAG_ACTIVITY_CLEAR_TOP
Dianne Hackborn621e17d2010-11-22 15:59:56 -08008180 * @see #FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008181 * @see #FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS
8182 * @see #FLAG_ACTIVITY_FORWARD_RESULT
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08008183 * @see #FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008184 * @see #FLAG_ACTIVITY_MULTIPLE_TASK
Craig Mautnerd00f4742014-03-12 14:17:26 -07008185 * @see #FLAG_ACTIVITY_NEW_DOCUMENT
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008186 * @see #FLAG_ACTIVITY_NEW_TASK
Dianne Hackborn621e17d2010-11-22 15:59:56 -08008187 * @see #FLAG_ACTIVITY_NO_ANIMATION
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008188 * @see #FLAG_ACTIVITY_NO_HISTORY
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08008189 * @see #FLAG_ACTIVITY_NO_USER_ACTION
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08008190 * @see #FLAG_ACTIVITY_PREVIOUS_IS_TOP
8191 * @see #FLAG_ACTIVITY_RESET_TASK_IF_NEEDED
Dianne Hackborn621e17d2010-11-22 15:59:56 -08008192 * @see #FLAG_ACTIVITY_REORDER_TO_FRONT
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008193 * @see #FLAG_ACTIVITY_SINGLE_TOP
Dianne Hackborn621e17d2010-11-22 15:59:56 -08008194 * @see #FLAG_ACTIVITY_TASK_ON_HOME
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008195 * @see #FLAG_RECEIVER_REGISTERED_ONLY
8196 */
8197 public Intent setFlags(int flags) {
8198 mFlags = flags;
8199 return this;
8200 }
8201
8202 /**
Jeff Sharkey6a34e562016-12-21 09:56:00 -07008203 * Add additional flags to the intent (or with existing flags value).
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008204 *
8205 * @param flags The new flags to set.
Jeff Sharkey6a34e562016-12-21 09:56:00 -07008206 * @return Returns the same Intent object, for chaining multiple calls into
8207 * a single statement.
8208 * @see #setFlags(int)
8209 * @see #removeFlags(int)
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008210 */
8211 public Intent addFlags(int flags) {
8212 mFlags |= flags;
8213 return this;
8214 }
8215
8216 /**
Jeff Sharkey6a34e562016-12-21 09:56:00 -07008217 * Remove these flags from the intent.
8218 *
8219 * @param flags The flags to remove.
8220 * @see #setFlags(int)
8221 * @see #addFlags(int)
8222 */
8223 public void removeFlags(int flags) {
8224 mFlags &= ~flags;
8225 }
8226
8227 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008228 * (Usually optional) Set an explicit application package name that limits
8229 * the components this Intent will resolve to. If left to the default
8230 * value of null, all components in all applications will considered.
8231 * If non-null, the Intent can only match the components in the given
8232 * application package.
8233 *
8234 * @param packageName The name of the application package to handle the
8235 * intent, or null to allow any application package.
8236 *
8237 * @return Returns the same Intent object, for chaining multiple calls
8238 * into a single statement.
8239 *
8240 * @see #getPackage
8241 * @see #resolveActivity
8242 */
8243 public Intent setPackage(String packageName) {
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008244 if (packageName != null && mSelector != null) {
8245 throw new IllegalArgumentException(
8246 "Can't set package name when selector is already set");
8247 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008248 mPackage = packageName;
8249 return this;
8250 }
8251
8252 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008253 * (Usually optional) Explicitly set the component to handle the intent.
8254 * If left with the default value of null, the system will determine the
8255 * appropriate class to use based on the other fields (action, data,
8256 * type, categories) in the Intent. If this class is defined, the
8257 * specified class will always be used regardless of the other fields. You
8258 * should only set this value when you know you absolutely want a specific
8259 * class to be used; otherwise it is better to let the system find the
8260 * appropriate class so that you will respect the installed applications
8261 * and user preferences.
8262 *
8263 * @param component The name of the application component to handle the
8264 * intent, or null to let the system find one for you.
8265 *
8266 * @return Returns the same Intent object, for chaining multiple calls
8267 * into a single statement.
8268 *
8269 * @see #setClass
8270 * @see #setClassName(Context, String)
8271 * @see #setClassName(String, String)
8272 * @see #getComponent
8273 * @see #resolveActivity
8274 */
8275 public Intent setComponent(ComponentName component) {
8276 mComponent = component;
8277 return this;
8278 }
8279
8280 /**
8281 * Convenience for calling {@link #setComponent} with an
8282 * explicit class name.
8283 *
8284 * @param packageContext A Context of the application package implementing
8285 * this class.
8286 * @param className The name of a class inside of the application package
8287 * that will be used as the component for this Intent.
8288 *
8289 * @return Returns the same Intent object, for chaining multiple calls
8290 * into a single statement.
8291 *
8292 * @see #setComponent
8293 * @see #setClass
8294 */
8295 public Intent setClassName(Context packageContext, String className) {
8296 mComponent = new ComponentName(packageContext, className);
8297 return this;
8298 }
8299
8300 /**
8301 * Convenience for calling {@link #setComponent} with an
8302 * explicit application package name and class name.
8303 *
8304 * @param packageName The name of the package implementing the desired
8305 * component.
8306 * @param className The name of a class inside of the application package
8307 * that will be used as the component for this Intent.
8308 *
8309 * @return Returns the same Intent object, for chaining multiple calls
8310 * into a single statement.
8311 *
8312 * @see #setComponent
8313 * @see #setClass
8314 */
8315 public Intent setClassName(String packageName, String className) {
8316 mComponent = new ComponentName(packageName, className);
8317 return this;
8318 }
8319
8320 /**
8321 * Convenience for calling {@link #setComponent(ComponentName)} with the
8322 * name returned by a {@link Class} object.
8323 *
8324 * @param packageContext A Context of the application package implementing
8325 * this class.
8326 * @param cls The class name to set, equivalent to
8327 * <code>setClassName(context, cls.getName())</code>.
8328 *
8329 * @return Returns the same Intent object, for chaining multiple calls
8330 * into a single statement.
8331 *
8332 * @see #setComponent
8333 */
8334 public Intent setClass(Context packageContext, Class<?> cls) {
8335 mComponent = new ComponentName(packageContext, cls);
8336 return this;
8337 }
8338
8339 /**
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08008340 * Set the bounds of the sender of this intent, in screen coordinates. This can be
8341 * used as a hint to the receiver for animations and the like. Null means that there
8342 * is no source bounds.
8343 */
8344 public void setSourceBounds(Rect r) {
8345 if (r != null) {
8346 mSourceBounds = new Rect(r);
8347 } else {
Daniel Lehmanna5b58df2011-10-12 16:24:22 -07008348 mSourceBounds = null;
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08008349 }
8350 }
8351
Tor Norbyed9273d62013-05-30 15:59:53 -07008352 /** @hide */
8353 @IntDef(flag = true,
8354 value = {
8355 FILL_IN_ACTION,
8356 FILL_IN_DATA,
8357 FILL_IN_CATEGORIES,
8358 FILL_IN_COMPONENT,
8359 FILL_IN_PACKAGE,
8360 FILL_IN_SOURCE_BOUNDS,
8361 FILL_IN_SELECTOR,
8362 FILL_IN_CLIP_DATA
8363 })
8364 @Retention(RetentionPolicy.SOURCE)
8365 public @interface FillInFlags {}
8366
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08008367 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008368 * Use with {@link #fillIn} to allow the current action value to be
8369 * overwritten, even if it is already set.
8370 */
8371 public static final int FILL_IN_ACTION = 1<<0;
8372
8373 /**
8374 * Use with {@link #fillIn} to allow the current data or type value
8375 * overwritten, even if it is already set.
8376 */
8377 public static final int FILL_IN_DATA = 1<<1;
8378
8379 /**
8380 * Use with {@link #fillIn} to allow the current categories to be
8381 * overwritten, even if they are already set.
8382 */
8383 public static final int FILL_IN_CATEGORIES = 1<<2;
8384
8385 /**
8386 * Use with {@link #fillIn} to allow the current component value to be
8387 * overwritten, even if it is already set.
8388 */
8389 public static final int FILL_IN_COMPONENT = 1<<3;
8390
8391 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008392 * Use with {@link #fillIn} to allow the current package value to be
8393 * overwritten, even if it is already set.
8394 */
8395 public static final int FILL_IN_PACKAGE = 1<<4;
8396
8397 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008398 * Use with {@link #fillIn} to allow the current bounds rectangle to be
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08008399 * overwritten, even if it is already set.
8400 */
8401 public static final int FILL_IN_SOURCE_BOUNDS = 1<<5;
8402
8403 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008404 * Use with {@link #fillIn} to allow the current selector to be
8405 * overwritten, even if it is already set.
8406 */
8407 public static final int FILL_IN_SELECTOR = 1<<6;
8408
8409 /**
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008410 * Use with {@link #fillIn} to allow the current ClipData to be
8411 * overwritten, even if it is already set.
8412 */
8413 public static final int FILL_IN_CLIP_DATA = 1<<7;
8414
8415 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008416 * Copy the contents of <var>other</var> in to this object, but only
8417 * where fields are not defined by this object. For purposes of a field
8418 * being defined, the following pieces of data in the Intent are
8419 * considered to be separate fields:
8420 *
8421 * <ul>
8422 * <li> action, as set by {@link #setAction}.
Nick Pellyccae4122012-01-09 14:12:58 -08008423 * <li> data Uri and MIME type, as set by {@link #setData(Uri)},
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008424 * {@link #setType(String)}, or {@link #setDataAndType(Uri, String)}.
8425 * <li> categories, as set by {@link #addCategory}.
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008426 * <li> package, as set by {@link #setPackage}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008427 * <li> component, as set by {@link #setComponent(ComponentName)} or
8428 * related methods.
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008429 * <li> source bounds, as set by {@link #setSourceBounds}.
8430 * <li> selector, as set by {@link #setSelector(Intent)}.
8431 * <li> clip data, as set by {@link #setClipData(ClipData)}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008432 * <li> each top-level name in the associated extras.
8433 * </ul>
8434 *
8435 * <p>In addition, you can use the {@link #FILL_IN_ACTION},
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008436 * {@link #FILL_IN_DATA}, {@link #FILL_IN_CATEGORIES}, {@link #FILL_IN_PACKAGE},
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008437 * {@link #FILL_IN_COMPONENT}, {@link #FILL_IN_SOURCE_BOUNDS},
8438 * {@link #FILL_IN_SELECTOR}, and {@link #FILL_IN_CLIP_DATA} to override
8439 * the restriction where the corresponding field will not be replaced if
8440 * it is already set.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008441 *
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008442 * <p>Note: The component field will only be copied if {@link #FILL_IN_COMPONENT}
8443 * is explicitly specified. The selector will only be copied if
8444 * {@link #FILL_IN_SELECTOR} is explicitly specified.
Brett Chabot3e391752009-07-21 16:07:23 -07008445 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008446 * <p>For example, consider Intent A with {data="foo", categories="bar"}
8447 * and Intent B with {action="gotit", data-type="some/thing",
8448 * categories="one","two"}.
8449 *
8450 * <p>Calling A.fillIn(B, Intent.FILL_IN_DATA) will result in A now
8451 * containing: {action="gotit", data-type="some/thing",
8452 * categories="bar"}.
8453 *
8454 * @param other Another Intent whose values are to be used to fill in
8455 * the current one.
8456 * @param flags Options to control which fields can be filled in.
8457 *
8458 * @return Returns a bit mask of {@link #FILL_IN_ACTION},
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008459 * {@link #FILL_IN_DATA}, {@link #FILL_IN_CATEGORIES}, {@link #FILL_IN_PACKAGE},
Tor Norbyed9273d62013-05-30 15:59:53 -07008460 * {@link #FILL_IN_COMPONENT}, {@link #FILL_IN_SOURCE_BOUNDS},
Elliot Waite54de7742017-01-11 15:30:35 -08008461 * {@link #FILL_IN_SELECTOR} and {@link #FILL_IN_CLIP_DATA} indicating which fields were
Tor Norbyed9273d62013-05-30 15:59:53 -07008462 * changed.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008463 */
Tor Norbyed9273d62013-05-30 15:59:53 -07008464 @FillInFlags
8465 public int fillIn(Intent other, @FillInFlags int flags) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008466 int changes = 0;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008467 boolean mayHaveCopiedUris = false;
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008468 if (other.mAction != null
8469 && (mAction == null || (flags&FILL_IN_ACTION) != 0)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008470 mAction = other.mAction;
8471 changes |= FILL_IN_ACTION;
8472 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008473 if ((other.mData != null || other.mType != null)
8474 && ((mData == null && mType == null)
8475 || (flags&FILL_IN_DATA) != 0)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008476 mData = other.mData;
8477 mType = other.mType;
8478 changes |= FILL_IN_DATA;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008479 mayHaveCopiedUris = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008480 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008481 if (other.mCategories != null
8482 && (mCategories == null || (flags&FILL_IN_CATEGORIES) != 0)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008483 if (other.mCategories != null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07008484 mCategories = new ArraySet<String>(other.mCategories);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008485 }
8486 changes |= FILL_IN_CATEGORIES;
8487 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008488 if (other.mPackage != null
8489 && (mPackage == null || (flags&FILL_IN_PACKAGE) != 0)) {
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008490 // Only do this if mSelector is not set.
8491 if (mSelector == null) {
8492 mPackage = other.mPackage;
8493 changes |= FILL_IN_PACKAGE;
8494 }
8495 }
8496 // Selector is special: it can only be set if explicitly allowed,
8497 // for the same reason as the component name.
8498 if (other.mSelector != null && (flags&FILL_IN_SELECTOR) != 0) {
8499 if (mPackage == null) {
8500 mSelector = new Intent(other.mSelector);
8501 mPackage = null;
8502 changes |= FILL_IN_SELECTOR;
8503 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008504 }
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008505 if (other.mClipData != null
8506 && (mClipData == null || (flags&FILL_IN_CLIP_DATA) != 0)) {
8507 mClipData = other.mClipData;
8508 changes |= FILL_IN_CLIP_DATA;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008509 mayHaveCopiedUris = true;
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008510 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008511 // Component is special: it can -only- be set if explicitly allowed,
8512 // since otherwise the sender could force the intent somewhere the
8513 // originator didn't intend.
8514 if (other.mComponent != null && (flags&FILL_IN_COMPONENT) != 0) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008515 mComponent = other.mComponent;
8516 changes |= FILL_IN_COMPONENT;
8517 }
8518 mFlags |= other.mFlags;
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08008519 if (other.mSourceBounds != null
8520 && (mSourceBounds == null || (flags&FILL_IN_SOURCE_BOUNDS) != 0)) {
8521 mSourceBounds = new Rect(other.mSourceBounds);
8522 changes |= FILL_IN_SOURCE_BOUNDS;
8523 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008524 if (mExtras == null) {
8525 if (other.mExtras != null) {
8526 mExtras = new Bundle(other.mExtras);
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008527 mayHaveCopiedUris = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008528 }
8529 } else if (other.mExtras != null) {
8530 try {
8531 Bundle newb = new Bundle(other.mExtras);
8532 newb.putAll(mExtras);
8533 mExtras = newb;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008534 mayHaveCopiedUris = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008535 } catch (RuntimeException e) {
8536 // Modifying the extras can cause us to unparcel the contents
8537 // of the bundle, and if we do this in the system process that
8538 // may fail. We really should handle this (i.e., the Bundle
8539 // impl shouldn't be on top of a plain map), but for now just
8540 // ignore it and keep the original contents. :(
8541 Log.w("Intent", "Failure filling in extras", e);
8542 }
8543 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008544 if (mayHaveCopiedUris && mContentUserHint == UserHandle.USER_CURRENT
8545 && other.mContentUserHint != UserHandle.USER_CURRENT) {
8546 mContentUserHint = other.mContentUserHint;
8547 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008548 return changes;
8549 }
8550
8551 /**
8552 * Wrapper class holding an Intent and implementing comparisons on it for
8553 * the purpose of filtering. The class implements its
8554 * {@link #equals equals()} and {@link #hashCode hashCode()} methods as
8555 * simple calls to {@link Intent#filterEquals(Intent)} filterEquals()} and
8556 * {@link android.content.Intent#filterHashCode()} filterHashCode()}
8557 * on the wrapped Intent.
8558 */
8559 public static final class FilterComparison {
8560 private final Intent mIntent;
8561 private final int mHashCode;
8562
8563 public FilterComparison(Intent intent) {
8564 mIntent = intent;
8565 mHashCode = intent.filterHashCode();
8566 }
8567
8568 /**
8569 * Return the Intent that this FilterComparison represents.
8570 * @return Returns the Intent held by the FilterComparison. Do
8571 * not modify!
8572 */
8573 public Intent getIntent() {
8574 return mIntent;
8575 }
8576
8577 @Override
8578 public boolean equals(Object obj) {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08008579 if (obj instanceof FilterComparison) {
8580 Intent other = ((FilterComparison)obj).mIntent;
8581 return mIntent.filterEquals(other);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008582 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08008583 return false;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008584 }
8585
8586 @Override
8587 public int hashCode() {
8588 return mHashCode;
8589 }
8590 }
8591
8592 /**
8593 * Determine if two intents are the same for the purposes of intent
8594 * resolution (filtering). That is, if their action, data, type,
8595 * class, and categories are the same. This does <em>not</em> compare
8596 * any extra data included in the intents.
8597 *
8598 * @param other The other Intent to compare against.
8599 *
8600 * @return Returns true if action, data, type, class, and categories
8601 * are the same.
8602 */
8603 public boolean filterEquals(Intent other) {
8604 if (other == null) {
8605 return false;
8606 }
Christopher Tate63d9ae12014-06-19 19:07:26 -07008607 if (!Objects.equals(this.mAction, other.mAction)) return false;
8608 if (!Objects.equals(this.mData, other.mData)) return false;
8609 if (!Objects.equals(this.mType, other.mType)) return false;
8610 if (!Objects.equals(this.mPackage, other.mPackage)) return false;
8611 if (!Objects.equals(this.mComponent, other.mComponent)) return false;
8612 if (!Objects.equals(this.mCategories, other.mCategories)) return false;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008613
8614 return true;
8615 }
8616
8617 /**
8618 * Generate hash code that matches semantics of filterEquals().
8619 *
8620 * @return Returns the hash value of the action, data, type, class, and
8621 * categories.
8622 *
8623 * @see #filterEquals
8624 */
8625 public int filterHashCode() {
8626 int code = 0;
8627 if (mAction != null) {
8628 code += mAction.hashCode();
8629 }
8630 if (mData != null) {
8631 code += mData.hashCode();
8632 }
8633 if (mType != null) {
8634 code += mType.hashCode();
8635 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008636 if (mPackage != null) {
8637 code += mPackage.hashCode();
8638 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008639 if (mComponent != null) {
8640 code += mComponent.hashCode();
8641 }
8642 if (mCategories != null) {
8643 code += mCategories.hashCode();
8644 }
8645 return code;
8646 }
8647
8648 @Override
8649 public String toString() {
Dianne Hackborn90c52de2011-09-23 12:57:44 -07008650 StringBuilder b = new StringBuilder(128);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008651
Dianne Hackborn1d442e02009-04-20 18:14:05 -07008652 b.append("Intent { ");
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008653 toShortString(b, true, true, true, false);
Dianne Hackborn1d442e02009-04-20 18:14:05 -07008654 b.append(" }");
8655
8656 return b.toString();
8657 }
8658
8659 /** @hide */
Dianne Hackborn90c52de2011-09-23 12:57:44 -07008660 public String toInsecureString() {
8661 StringBuilder b = new StringBuilder(128);
8662
8663 b.append("Intent { ");
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008664 toShortString(b, false, true, true, false);
Dianne Hackborn90c52de2011-09-23 12:57:44 -07008665 b.append(" }");
8666
Dianne Hackborn1d442e02009-04-20 18:14:05 -07008667 return b.toString();
8668 }
Romain Guy4969af72009-06-17 10:53:19 -07008669
Dianne Hackborn1d442e02009-04-20 18:14:05 -07008670 /** @hide */
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008671 public String toInsecureStringWithClip() {
Dianne Hackborn90c52de2011-09-23 12:57:44 -07008672 StringBuilder b = new StringBuilder(128);
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008673
8674 b.append("Intent { ");
8675 toShortString(b, false, true, true, true);
8676 b.append(" }");
8677
Dianne Hackborn90c52de2011-09-23 12:57:44 -07008678 return b.toString();
8679 }
8680
8681 /** @hide */
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008682 public String toShortString(boolean secure, boolean comp, boolean extras, boolean clip) {
8683 StringBuilder b = new StringBuilder(128);
8684 toShortString(b, secure, comp, extras, clip);
8685 return b.toString();
8686 }
8687
8688 /** @hide */
8689 public void toShortString(StringBuilder b, boolean secure, boolean comp, boolean extras,
8690 boolean clip) {
Dianne Hackborn1d442e02009-04-20 18:14:05 -07008691 boolean first = true;
8692 if (mAction != null) {
8693 b.append("act=").append(mAction);
8694 first = false;
8695 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008696 if (mCategories != null) {
Dianne Hackborn1d442e02009-04-20 18:14:05 -07008697 if (!first) {
8698 b.append(' ');
8699 }
8700 first = false;
8701 b.append("cat=[");
Dianne Hackbornadd005c2013-07-17 18:43:12 -07008702 for (int i=0; i<mCategories.size(); i++) {
8703 if (i > 0) b.append(',');
8704 b.append(mCategories.valueAt(i));
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008705 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07008706 b.append("]");
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008707 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07008708 if (mData != null) {
8709 if (!first) {
8710 b.append(' ');
8711 }
8712 first = false;
Wink Savillea4288072010-10-12 12:36:38 -07008713 b.append("dat=");
Dianne Hackborn90c52de2011-09-23 12:57:44 -07008714 if (secure) {
8715 b.append(mData.toSafeString());
Wink Savillea4288072010-10-12 12:36:38 -07008716 } else {
8717 b.append(mData);
8718 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07008719 }
8720 if (mType != null) {
8721 if (!first) {
8722 b.append(' ');
8723 }
8724 first = false;
8725 b.append("typ=").append(mType);
8726 }
8727 if (mFlags != 0) {
8728 if (!first) {
8729 b.append(' ');
8730 }
8731 first = false;
8732 b.append("flg=0x").append(Integer.toHexString(mFlags));
8733 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008734 if (mPackage != null) {
8735 if (!first) {
8736 b.append(' ');
8737 }
8738 first = false;
8739 b.append("pkg=").append(mPackage);
8740 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07008741 if (comp && mComponent != null) {
8742 if (!first) {
8743 b.append(' ');
8744 }
8745 first = false;
8746 b.append("cmp=").append(mComponent.flattenToShortString());
8747 }
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08008748 if (mSourceBounds != null) {
8749 if (!first) {
8750 b.append(' ');
8751 }
8752 first = false;
8753 b.append("bnds=").append(mSourceBounds.toShortString());
8754 }
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008755 if (mClipData != null) {
8756 if (!first) {
8757 b.append(' ');
8758 }
Dianne Hackbornae498722015-08-14 13:29:47 -07008759 b.append("clip={");
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008760 if (clip) {
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008761 mClipData.toShortString(b);
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008762 } else {
Dianne Hackbornae498722015-08-14 13:29:47 -07008763 if (mClipData.getDescription() != null) {
8764 first = !mClipData.getDescription().toShortStringTypesOnly(b);
8765 } else {
8766 first = true;
8767 }
8768 mClipData.toShortStringShortItems(b, first);
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008769 }
Dianne Hackbornae498722015-08-14 13:29:47 -07008770 first = false;
8771 b.append('}');
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008772 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07008773 if (extras && mExtras != null) {
8774 if (!first) {
8775 b.append(' ');
8776 }
8777 first = false;
8778 b.append("(has extras)");
8779 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008780 if (mContentUserHint != UserHandle.USER_CURRENT) {
8781 if (!first) {
8782 b.append(' ');
8783 }
8784 first = false;
8785 b.append("u=").append(mContentUserHint);
8786 }
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008787 if (mSelector != null) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008788 b.append(" sel=");
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008789 mSelector.toShortString(b, secure, comp, extras, clip);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008790 b.append("}");
8791 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008792 }
8793
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008794 /**
8795 * Call {@link #toUri} with 0 flags.
8796 * @deprecated Use {@link #toUri} instead.
8797 */
8798 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008799 public String toURI() {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008800 return toUri(0);
8801 }
8802
8803 /**
8804 * Convert this Intent into a String holding a URI representation of it.
8805 * The returned URI string has been properly URI encoded, so it can be
8806 * used with {@link Uri#parse Uri.parse(String)}. The URI contains the
8807 * Intent's data as the base URI, with an additional fragment describing
8808 * the action, categories, type, flags, package, component, and extras.
Tom Taylord4a47292009-12-21 13:59:18 -08008809 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008810 * <p>You can convert the returned string back to an Intent with
8811 * {@link #getIntent}.
Tom Taylord4a47292009-12-21 13:59:18 -08008812 *
Dianne Hackborn85d558c2014-11-04 10:31:54 -08008813 * @param flags Additional operating flags. Either 0,
8814 * {@link #URI_INTENT_SCHEME}, or {@link #URI_ANDROID_APP_SCHEME}.
Tom Taylord4a47292009-12-21 13:59:18 -08008815 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008816 * @return Returns a URI encoding URI string describing the entire contents
8817 * of the Intent.
8818 */
8819 public String toUri(int flags) {
Dianne Hackborn1d442e02009-04-20 18:14:05 -07008820 StringBuilder uri = new StringBuilder(128);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08008821 if ((flags&URI_ANDROID_APP_SCHEME) != 0) {
8822 if (mPackage == null) {
8823 throw new IllegalArgumentException(
8824 "Intent must include an explicit package name to build an android-app: "
8825 + this);
8826 }
8827 uri.append("android-app://");
8828 uri.append(mPackage);
8829 String scheme = null;
8830 if (mData != null) {
8831 scheme = mData.getScheme();
8832 if (scheme != null) {
8833 uri.append('/');
8834 uri.append(scheme);
8835 String authority = mData.getEncodedAuthority();
8836 if (authority != null) {
8837 uri.append('/');
8838 uri.append(authority);
8839 String path = mData.getEncodedPath();
8840 if (path != null) {
8841 uri.append(path);
8842 }
8843 String queryParams = mData.getEncodedQuery();
8844 if (queryParams != null) {
8845 uri.append('?');
8846 uri.append(queryParams);
8847 }
8848 String fragment = mData.getEncodedFragment();
8849 if (fragment != null) {
8850 uri.append('#');
8851 uri.append(fragment);
8852 }
8853 }
8854 }
8855 }
8856 toUriFragment(uri, null, scheme == null ? Intent.ACTION_MAIN : Intent.ACTION_VIEW,
8857 mPackage, flags);
8858 return uri.toString();
8859 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008860 String scheme = null;
8861 if (mData != null) {
8862 String data = mData.toString();
8863 if ((flags&URI_INTENT_SCHEME) != 0) {
8864 final int N = data.length();
8865 for (int i=0; i<N; i++) {
8866 char c = data.charAt(i);
8867 if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')
8868 || c == '.' || c == '-') {
8869 continue;
8870 }
8871 if (c == ':' && i > 0) {
8872 // Valid scheme.
8873 scheme = data.substring(0, i);
8874 uri.append("intent:");
8875 data = data.substring(i+1);
8876 break;
8877 }
Tom Taylord4a47292009-12-21 13:59:18 -08008878
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008879 // No scheme.
8880 break;
8881 }
8882 }
8883 uri.append(data);
Tom Taylord4a47292009-12-21 13:59:18 -08008884
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008885 } else if ((flags&URI_INTENT_SCHEME) != 0) {
8886 uri.append("intent:");
8887 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008888
Dianne Hackborn85d558c2014-11-04 10:31:54 -08008889 toUriFragment(uri, scheme, Intent.ACTION_VIEW, null, flags);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008890
Dianne Hackborn85d558c2014-11-04 10:31:54 -08008891 return uri.toString();
8892 }
8893
8894 private void toUriFragment(StringBuilder uri, String scheme, String defAction,
8895 String defPackage, int flags) {
8896 StringBuilder frag = new StringBuilder(128);
8897
8898 toUriInner(frag, scheme, defAction, defPackage, flags);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008899 if (mSelector != null) {
Dianne Hackborn80b1c562014-12-09 20:22:08 -08008900 frag.append("SEL;");
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008901 // Note that for now we are not going to try to handle the
8902 // data part; not clear how to represent this as a URI, and
8903 // not much utility in it.
Dianne Hackborn85d558c2014-11-04 10:31:54 -08008904 mSelector.toUriInner(frag, mSelector.mData != null ? mSelector.mData.getScheme() : null,
8905 null, null, flags);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008906 }
8907
Dianne Hackborn85d558c2014-11-04 10:31:54 -08008908 if (frag.length() > 0) {
8909 uri.append("#Intent;");
8910 uri.append(frag);
8911 uri.append("end");
8912 }
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008913 }
8914
Dianne Hackborn85d558c2014-11-04 10:31:54 -08008915 private void toUriInner(StringBuilder uri, String scheme, String defAction,
8916 String defPackage, int flags) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008917 if (scheme != null) {
8918 uri.append("scheme=").append(scheme).append(';');
8919 }
Dianne Hackborn85d558c2014-11-04 10:31:54 -08008920 if (mAction != null && !mAction.equals(defAction)) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008921 uri.append("action=").append(Uri.encode(mAction)).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008922 }
8923 if (mCategories != null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07008924 for (int i=0; i<mCategories.size(); i++) {
8925 uri.append("category=").append(Uri.encode(mCategories.valueAt(i))).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008926 }
8927 }
8928 if (mType != null) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008929 uri.append("type=").append(Uri.encode(mType, "/")).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008930 }
8931 if (mFlags != 0) {
8932 uri.append("launchFlags=0x").append(Integer.toHexString(mFlags)).append(';');
8933 }
Dianne Hackborn85d558c2014-11-04 10:31:54 -08008934 if (mPackage != null && !mPackage.equals(defPackage)) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008935 uri.append("package=").append(Uri.encode(mPackage)).append(';');
8936 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008937 if (mComponent != null) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008938 uri.append("component=").append(Uri.encode(
8939 mComponent.flattenToShortString(), "/")).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008940 }
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08008941 if (mSourceBounds != null) {
8942 uri.append("sourceBounds=")
8943 .append(Uri.encode(mSourceBounds.flattenToString()))
8944 .append(';');
8945 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008946 if (mExtras != null) {
8947 for (String key : mExtras.keySet()) {
8948 final Object value = mExtras.get(key);
8949 char entryType =
8950 value instanceof String ? 'S' :
8951 value instanceof Boolean ? 'B' :
8952 value instanceof Byte ? 'b' :
8953 value instanceof Character ? 'c' :
8954 value instanceof Double ? 'd' :
8955 value instanceof Float ? 'f' :
8956 value instanceof Integer ? 'i' :
8957 value instanceof Long ? 'l' :
8958 value instanceof Short ? 's' :
8959 '\0';
8960
8961 if (entryType != '\0') {
8962 uri.append(entryType);
8963 uri.append('.');
8964 uri.append(Uri.encode(key));
8965 uri.append('=');
8966 uri.append(Uri.encode(value.toString()));
8967 uri.append(';');
8968 }
8969 }
8970 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008971 }
The Android Open Source Project10592532009-03-18 17:39:46 -07008972
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008973 public int describeContents() {
8974 return (mExtras != null) ? mExtras.describeContents() : 0;
8975 }
8976
8977 public void writeToParcel(Parcel out, int flags) {
8978 out.writeString(mAction);
8979 Uri.writeToParcel(out, mData);
8980 out.writeString(mType);
8981 out.writeInt(mFlags);
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008982 out.writeString(mPackage);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008983 ComponentName.writeToParcel(mComponent, out);
8984
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08008985 if (mSourceBounds != null) {
8986 out.writeInt(1);
8987 mSourceBounds.writeToParcel(out, flags);
8988 } else {
8989 out.writeInt(0);
8990 }
8991
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008992 if (mCategories != null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07008993 final int N = mCategories.size();
8994 out.writeInt(N);
8995 for (int i=0; i<N; i++) {
8996 out.writeString(mCategories.valueAt(i));
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008997 }
8998 } else {
8999 out.writeInt(0);
9000 }
9001
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009002 if (mSelector != null) {
9003 out.writeInt(1);
9004 mSelector.writeToParcel(out, flags);
9005 } else {
9006 out.writeInt(0);
9007 }
9008
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009009 if (mClipData != null) {
9010 out.writeInt(1);
9011 mClipData.writeToParcel(out, flags);
9012 } else {
9013 out.writeInt(0);
9014 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009015 out.writeInt(mContentUserHint);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009016 out.writeBundle(mExtras);
9017 }
9018
9019 public static final Parcelable.Creator<Intent> CREATOR
9020 = new Parcelable.Creator<Intent>() {
9021 public Intent createFromParcel(Parcel in) {
9022 return new Intent(in);
9023 }
9024 public Intent[] newArray(int size) {
9025 return new Intent[size];
9026 }
9027 };
9028
Dianne Hackborneb034652009-09-07 00:49:58 -07009029 /** @hide */
9030 protected Intent(Parcel in) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009031 readFromParcel(in);
9032 }
9033
9034 public void readFromParcel(Parcel in) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08009035 setAction(in.readString());
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009036 mData = Uri.CREATOR.createFromParcel(in);
9037 mType = in.readString();
9038 mFlags = in.readInt();
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009039 mPackage = in.readString();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009040 mComponent = ComponentName.readFromParcel(in);
9041
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08009042 if (in.readInt() != 0) {
9043 mSourceBounds = Rect.CREATOR.createFromParcel(in);
9044 }
9045
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009046 int N = in.readInt();
9047 if (N > 0) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07009048 mCategories = new ArraySet<String>();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009049 int i;
9050 for (i=0; i<N; i++) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08009051 mCategories.add(in.readString().intern());
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009052 }
9053 } else {
9054 mCategories = null;
9055 }
9056
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009057 if (in.readInt() != 0) {
9058 mSelector = new Intent(in);
9059 }
9060
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009061 if (in.readInt() != 0) {
9062 mClipData = new ClipData(in);
9063 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009064 mContentUserHint = in.readInt();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009065 mExtras = in.readBundle();
9066 }
9067
9068 /**
9069 * Parses the "intent" element (and its children) from XML and instantiates
9070 * an Intent object. The given XML parser should be located at the tag
9071 * where parsing should start (often named "intent"), from which the
9072 * basic action, data, type, and package and class name will be
9073 * retrieved. The function will then parse in to any child elements,
9074 * looking for <category android:name="xxx"> tags to add categories and
9075 * <extra android:name="xxx" android:value="yyy"> to attach extra data
9076 * to the intent.
9077 *
9078 * @param resources The Resources to use when inflating resources.
9079 * @param parser The XML parser pointing at an "intent" tag.
9080 * @param attrs The AttributeSet interface for retrieving extended
9081 * attribute data at the current <var>parser</var> location.
9082 * @return An Intent object matching the XML data.
9083 * @throws XmlPullParserException If there was an XML parsing error.
9084 * @throws IOException If there was an I/O error.
9085 */
9086 public static Intent parseIntent(Resources resources, XmlPullParser parser, AttributeSet attrs)
9087 throws XmlPullParserException, IOException {
9088 Intent intent = new Intent();
9089
9090 TypedArray sa = resources.obtainAttributes(attrs,
9091 com.android.internal.R.styleable.Intent);
9092
9093 intent.setAction(sa.getString(com.android.internal.R.styleable.Intent_action));
9094
9095 String data = sa.getString(com.android.internal.R.styleable.Intent_data);
9096 String mimeType = sa.getString(com.android.internal.R.styleable.Intent_mimeType);
9097 intent.setDataAndType(data != null ? Uri.parse(data) : null, mimeType);
9098
9099 String packageName = sa.getString(com.android.internal.R.styleable.Intent_targetPackage);
9100 String className = sa.getString(com.android.internal.R.styleable.Intent_targetClass);
9101 if (packageName != null && className != null) {
9102 intent.setComponent(new ComponentName(packageName, className));
9103 }
9104
9105 sa.recycle();
9106
9107 int outerDepth = parser.getDepth();
9108 int type;
9109 while ((type=parser.next()) != XmlPullParser.END_DOCUMENT
9110 && (type != XmlPullParser.END_TAG || parser.getDepth() > outerDepth)) {
9111 if (type == XmlPullParser.END_TAG || type == XmlPullParser.TEXT) {
9112 continue;
9113 }
9114
9115 String nodeName = parser.getName();
Craig Mautner21d24a22014-04-23 11:45:37 -07009116 if (nodeName.equals(TAG_CATEGORIES)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009117 sa = resources.obtainAttributes(attrs,
9118 com.android.internal.R.styleable.IntentCategory);
9119 String cat = sa.getString(com.android.internal.R.styleable.IntentCategory_name);
9120 sa.recycle();
9121
9122 if (cat != null) {
9123 intent.addCategory(cat);
9124 }
9125 XmlUtils.skipCurrentTag(parser);
9126
Craig Mautner21d24a22014-04-23 11:45:37 -07009127 } else if (nodeName.equals(TAG_EXTRA)) {
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08009128 if (intent.mExtras == null) {
9129 intent.mExtras = new Bundle();
9130 }
Craig Mautner21d24a22014-04-23 11:45:37 -07009131 resources.parseBundleExtra(TAG_EXTRA, attrs, intent.mExtras);
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08009132 XmlUtils.skipCurrentTag(parser);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009133
9134 } else {
9135 XmlUtils.skipCurrentTag(parser);
9136 }
9137 }
9138
9139 return intent;
9140 }
Nick Pellyccae4122012-01-09 14:12:58 -08009141
Craig Mautner21d24a22014-04-23 11:45:37 -07009142 /** @hide */
9143 public void saveToXml(XmlSerializer out) throws IOException {
9144 if (mAction != null) {
9145 out.attribute(null, ATTR_ACTION, mAction);
9146 }
9147 if (mData != null) {
9148 out.attribute(null, ATTR_DATA, mData.toString());
9149 }
9150 if (mType != null) {
9151 out.attribute(null, ATTR_TYPE, mType);
9152 }
9153 if (mComponent != null) {
9154 out.attribute(null, ATTR_COMPONENT, mComponent.flattenToShortString());
9155 }
9156 out.attribute(null, ATTR_FLAGS, Integer.toHexString(getFlags()));
9157
9158 if (mCategories != null) {
9159 out.startTag(null, TAG_CATEGORIES);
9160 for (int categoryNdx = mCategories.size() - 1; categoryNdx >= 0; --categoryNdx) {
9161 out.attribute(null, ATTR_CATEGORY, mCategories.valueAt(categoryNdx));
9162 }
Craig Mautner43e52ed2014-06-16 17:18:52 -07009163 out.endTag(null, TAG_CATEGORIES);
Craig Mautner21d24a22014-04-23 11:45:37 -07009164 }
9165 }
9166
9167 /** @hide */
9168 public static Intent restoreFromXml(XmlPullParser in) throws IOException,
9169 XmlPullParserException {
9170 Intent intent = new Intent();
9171 final int outerDepth = in.getDepth();
9172
9173 int attrCount = in.getAttributeCount();
9174 for (int attrNdx = attrCount - 1; attrNdx >= 0; --attrNdx) {
9175 final String attrName = in.getAttributeName(attrNdx);
9176 final String attrValue = in.getAttributeValue(attrNdx);
9177 if (ATTR_ACTION.equals(attrName)) {
9178 intent.setAction(attrValue);
9179 } else if (ATTR_DATA.equals(attrName)) {
9180 intent.setData(Uri.parse(attrValue));
9181 } else if (ATTR_TYPE.equals(attrName)) {
9182 intent.setType(attrValue);
9183 } else if (ATTR_COMPONENT.equals(attrName)) {
9184 intent.setComponent(ComponentName.unflattenFromString(attrValue));
9185 } else if (ATTR_FLAGS.equals(attrName)) {
Narayan Kamatha09b4d22016-04-15 18:32:45 +01009186 intent.setFlags(Integer.parseInt(attrValue, 16));
Craig Mautner21d24a22014-04-23 11:45:37 -07009187 } else {
9188 Log.e("Intent", "restoreFromXml: unknown attribute=" + attrName);
9189 }
9190 }
9191
9192 int event;
9193 String name;
9194 while (((event = in.next()) != XmlPullParser.END_DOCUMENT) &&
9195 (event != XmlPullParser.END_TAG || in.getDepth() < outerDepth)) {
9196 if (event == XmlPullParser.START_TAG) {
9197 name = in.getName();
9198 if (TAG_CATEGORIES.equals(name)) {
9199 attrCount = in.getAttributeCount();
9200 for (int attrNdx = attrCount - 1; attrNdx >= 0; --attrNdx) {
9201 intent.addCategory(in.getAttributeValue(attrNdx));
9202 }
9203 } else {
9204 Log.w("Intent", "restoreFromXml: unknown name=" + name);
9205 XmlUtils.skipCurrentTag(in);
9206 }
9207 }
9208 }
9209
9210 return intent;
9211 }
9212
Nick Pellyccae4122012-01-09 14:12:58 -08009213 /**
9214 * Normalize a MIME data type.
9215 *
9216 * <p>A normalized MIME type has white-space trimmed,
9217 * content-type parameters removed, and is lower-case.
9218 * This aligns the type with Android best practices for
9219 * intent filtering.
9220 *
9221 * <p>For example, "text/plain; charset=utf-8" becomes "text/plain".
9222 * "text/x-vCard" becomes "text/x-vcard".
9223 *
9224 * <p>All MIME types received from outside Android (such as user input,
9225 * or external sources like Bluetooth, NFC, or the Internet) should
9226 * be normalized before they are used to create an Intent.
9227 *
9228 * @param type MIME data type to normalize
9229 * @return normalized MIME data type, or null if the input was null
John Spurlock125d1332013-11-25 11:58:37 -05009230 * @see #setType
9231 * @see #setTypeAndNormalize
Nick Pellyccae4122012-01-09 14:12:58 -08009232 */
9233 public static String normalizeMimeType(String type) {
9234 if (type == null) {
9235 return null;
9236 }
9237
Elliott Hughescb64d432013-08-02 10:00:44 -07009238 type = type.trim().toLowerCase(Locale.ROOT);
Nick Pellyccae4122012-01-09 14:12:58 -08009239
9240 final int semicolonIndex = type.indexOf(';');
9241 if (semicolonIndex != -1) {
9242 type = type.substring(0, semicolonIndex);
9243 }
9244 return type;
9245 }
Jeff Sharkey678d04f2012-03-23 15:41:58 -07009246
9247 /**
Jeff Sharkeya14acd22013-04-02 18:27:45 -07009248 * Prepare this {@link Intent} to leave an app process.
9249 *
9250 * @hide
9251 */
Jeff Sharkey344744b2016-01-28 19:03:30 -07009252 public void prepareToLeaveProcess(Context context) {
9253 final boolean leavingPackage = (mComponent == null)
9254 || !Objects.equals(mComponent.getPackageName(), context.getPackageName());
9255 prepareToLeaveProcess(leavingPackage);
9256 }
9257
9258 /**
9259 * Prepare this {@link Intent} to leave an app process.
9260 *
9261 * @hide
9262 */
9263 public void prepareToLeaveProcess(boolean leavingPackage) {
Jeff Sharkeya14acd22013-04-02 18:27:45 -07009264 setAllowFds(false);
9265
9266 if (mSelector != null) {
Jeff Sharkey344744b2016-01-28 19:03:30 -07009267 mSelector.prepareToLeaveProcess(leavingPackage);
Jeff Sharkeya14acd22013-04-02 18:27:45 -07009268 }
9269 if (mClipData != null) {
Jeff Sharkeyfb833f32016-12-01 14:59:59 -07009270 mClipData.prepareToLeaveProcess(leavingPackage, getFlags());
Jeff Sharkeya14acd22013-04-02 18:27:45 -07009271 }
9272
Jeff Sharkeyc6fe23d2017-02-24 09:39:58 -07009273 if (mExtras != null && !mExtras.isParcelled()) {
9274 final Object intent = mExtras.get(Intent.EXTRA_INTENT);
9275 if (intent instanceof Intent) {
9276 ((Intent) intent).prepareToLeaveProcess(leavingPackage);
9277 }
9278 }
9279
Jeff Sharkeya8b42782016-01-30 17:58:09 -07009280 if (mAction != null && mData != null && StrictMode.vmFileUriExposureEnabled()
9281 && leavingPackage) {
Jeff Sharkey344744b2016-01-28 19:03:30 -07009282 switch (mAction) {
9283 case ACTION_MEDIA_REMOVED:
9284 case ACTION_MEDIA_UNMOUNTED:
9285 case ACTION_MEDIA_CHECKING:
9286 case ACTION_MEDIA_NOFS:
9287 case ACTION_MEDIA_MOUNTED:
9288 case ACTION_MEDIA_SHARED:
9289 case ACTION_MEDIA_UNSHARED:
9290 case ACTION_MEDIA_BAD_REMOVAL:
9291 case ACTION_MEDIA_UNMOUNTABLE:
9292 case ACTION_MEDIA_EJECT:
9293 case ACTION_MEDIA_SCANNER_STARTED:
9294 case ACTION_MEDIA_SCANNER_FINISHED:
9295 case ACTION_MEDIA_SCANNER_SCAN_FILE:
Jeff Sharkey37355a92016-02-05 16:19:10 -07009296 case ACTION_PACKAGE_NEEDS_VERIFICATION:
9297 case ACTION_PACKAGE_VERIFIED:
Jeff Sharkey344744b2016-01-28 19:03:30 -07009298 // Ignore legacy actions
9299 break;
9300 default:
9301 mData.checkFileUriExposed("Intent.getData()");
Jeff Sharkeya14acd22013-04-02 18:27:45 -07009302 }
9303 }
Jeff Sharkeyfb833f32016-12-01 14:59:59 -07009304
9305 if (mAction != null && mData != null && StrictMode.vmContentUriWithoutPermissionEnabled()
9306 && leavingPackage) {
9307 switch (mAction) {
9308 case ACTION_PROVIDER_CHANGED:
9309 // Ignore actions that don't need to grant
9310 break;
9311 default:
9312 mData.checkContentUriWithoutPermission("Intent.getData()", getFlags());
9313 }
9314 }
Jeff Sharkeya14acd22013-04-02 18:27:45 -07009315 }
9316
9317 /**
Nicolas Prevotd85fc722014-04-16 19:52:08 +01009318 * @hide
9319 */
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009320 public void prepareToEnterProcess() {
Jeff Sharkeyd136e512016-03-09 22:30:56 -07009321 // We just entered destination process, so we should be able to read all
9322 // parcelables inside.
9323 setDefusable(true);
9324
9325 if (mSelector != null) {
9326 mSelector.prepareToEnterProcess();
9327 }
9328 if (mClipData != null) {
9329 mClipData.prepareToEnterProcess();
9330 }
9331
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009332 if (mContentUserHint != UserHandle.USER_CURRENT) {
Nicolas Prevotc4fc00a2014-10-31 12:01:32 +00009333 if (UserHandle.getAppId(Process.myUid()) != Process.SYSTEM_UID) {
9334 fixUris(mContentUserHint);
9335 mContentUserHint = UserHandle.USER_CURRENT;
9336 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009337 }
9338 }
9339
9340 /**
9341 * @hide
9342 */
9343 public void fixUris(int contentUserHint) {
Nicolas Prevotd85fc722014-04-16 19:52:08 +01009344 Uri data = getData();
9345 if (data != null) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009346 mData = maybeAddUserId(data, contentUserHint);
Nicolas Prevotd85fc722014-04-16 19:52:08 +01009347 }
9348 if (mClipData != null) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009349 mClipData.fixUris(contentUserHint);
Nicolas Prevotd85fc722014-04-16 19:52:08 +01009350 }
9351 String action = getAction();
9352 if (ACTION_SEND.equals(action)) {
9353 final Uri stream = getParcelableExtra(EXTRA_STREAM);
9354 if (stream != null) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009355 putExtra(EXTRA_STREAM, maybeAddUserId(stream, contentUserHint));
Nicolas Prevotd85fc722014-04-16 19:52:08 +01009356 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009357 } else if (ACTION_SEND_MULTIPLE.equals(action)) {
Nicolas Prevotd85fc722014-04-16 19:52:08 +01009358 final ArrayList<Uri> streams = getParcelableArrayListExtra(EXTRA_STREAM);
9359 if (streams != null) {
9360 ArrayList<Uri> newStreams = new ArrayList<Uri>();
9361 for (int i = 0; i < streams.size(); i++) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009362 newStreams.add(maybeAddUserId(streams.get(i), contentUserHint));
Nicolas Prevotd85fc722014-04-16 19:52:08 +01009363 }
9364 putParcelableArrayListExtra(EXTRA_STREAM, newStreams);
9365 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009366 } else if (MediaStore.ACTION_IMAGE_CAPTURE.equals(action)
9367 || MediaStore.ACTION_IMAGE_CAPTURE_SECURE.equals(action)
9368 || MediaStore.ACTION_VIDEO_CAPTURE.equals(action)) {
9369 final Uri output = getParcelableExtra(MediaStore.EXTRA_OUTPUT);
9370 if (output != null) {
9371 putExtra(MediaStore.EXTRA_OUTPUT, maybeAddUserId(output, contentUserHint));
9372 }
Nicolas Prevotd85fc722014-04-16 19:52:08 +01009373 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009374 }
Nicolas Prevotd85fc722014-04-16 19:52:08 +01009375
9376 /**
Jeff Sharkey678d04f2012-03-23 15:41:58 -07009377 * Migrate any {@link #EXTRA_STREAM} in {@link #ACTION_SEND} and
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009378 * {@link #ACTION_SEND_MULTIPLE} to {@link ClipData}. Also inspects nested
9379 * intents in {@link #ACTION_CHOOSER}.
Jeff Sharkey678d04f2012-03-23 15:41:58 -07009380 *
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009381 * @return Whether any contents were migrated.
Jeff Sharkey678d04f2012-03-23 15:41:58 -07009382 * @hide
9383 */
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009384 public boolean migrateExtraStreamToClipData() {
Jeff Sharkey678d04f2012-03-23 15:41:58 -07009385 // Refuse to touch if extras already parcelled
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009386 if (mExtras != null && mExtras.isParcelled()) return false;
Jeff Sharkey678d04f2012-03-23 15:41:58 -07009387
9388 // Bail when someone already gave us ClipData
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009389 if (getClipData() != null) return false;
Jeff Sharkey678d04f2012-03-23 15:41:58 -07009390
9391 final String action = getAction();
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009392 if (ACTION_CHOOSER.equals(action)) {
Jeff Sharkeyc004eef2014-09-23 16:40:50 -07009393 // Inspect contained intents to see if we need to migrate extras. We
9394 // don't promote ClipData to the parent, since ChooserActivity will
9395 // already start the picked item as the caller, and we can't combine
9396 // the flags in a safe way.
9397
9398 boolean migrated = false;
Jeff Sharkey1c297002012-05-18 13:55:47 -07009399 try {
Jeff Sharkeyc004eef2014-09-23 16:40:50 -07009400 final Intent intent = getParcelableExtra(EXTRA_INTENT);
9401 if (intent != null) {
9402 migrated |= intent.migrateExtraStreamToClipData();
Jeff Sharkey1c297002012-05-18 13:55:47 -07009403 }
9404 } catch (ClassCastException e) {
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009405 }
Jeff Sharkeyc004eef2014-09-23 16:40:50 -07009406 try {
9407 final Parcelable[] intents = getParcelableArrayExtra(EXTRA_INITIAL_INTENTS);
9408 if (intents != null) {
9409 for (int i = 0; i < intents.length; i++) {
9410 final Intent intent = (Intent) intents[i];
9411 if (intent != null) {
9412 migrated |= intent.migrateExtraStreamToClipData();
9413 }
9414 }
9415 }
9416 } catch (ClassCastException e) {
9417 }
9418 return migrated;
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009419
9420 } else if (ACTION_SEND.equals(action)) {
Jeff Sharkeyf27ea662012-03-27 10:34:24 -07009421 try {
Jeff Sharkeydd471e62012-05-01 13:07:01 -07009422 final Uri stream = getParcelableExtra(EXTRA_STREAM);
9423 final CharSequence text = getCharSequenceExtra(EXTRA_TEXT);
9424 final String htmlText = getStringExtra(EXTRA_HTML_TEXT);
9425 if (stream != null || text != null || htmlText != null) {
9426 final ClipData clipData = new ClipData(
9427 null, new String[] { getType() },
9428 new ClipData.Item(text, htmlText, null, stream));
9429 setClipData(clipData);
9430 addFlags(FLAG_GRANT_READ_URI_PERMISSION);
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009431 return true;
Jeff Sharkeydd471e62012-05-01 13:07:01 -07009432 }
Jeff Sharkeyf27ea662012-03-27 10:34:24 -07009433 } catch (ClassCastException e) {
Jeff Sharkeyf27ea662012-03-27 10:34:24 -07009434 }
Jeff Sharkey678d04f2012-03-23 15:41:58 -07009435
9436 } else if (ACTION_SEND_MULTIPLE.equals(action)) {
Jeff Sharkeyf27ea662012-03-27 10:34:24 -07009437 try {
Jeff Sharkeydd471e62012-05-01 13:07:01 -07009438 final ArrayList<Uri> streams = getParcelableArrayListExtra(EXTRA_STREAM);
9439 final ArrayList<CharSequence> texts = getCharSequenceArrayListExtra(EXTRA_TEXT);
9440 final ArrayList<String> htmlTexts = getStringArrayListExtra(EXTRA_HTML_TEXT);
9441 int num = -1;
9442 if (streams != null) {
9443 num = streams.size();
9444 }
9445 if (texts != null) {
9446 if (num >= 0 && num != texts.size()) {
9447 // Wha...! F- you.
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009448 return false;
Jeff Sharkeydd471e62012-05-01 13:07:01 -07009449 }
9450 num = texts.size();
9451 }
9452 if (htmlTexts != null) {
9453 if (num >= 0 && num != htmlTexts.size()) {
9454 // Wha...! F- you.
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009455 return false;
Jeff Sharkeydd471e62012-05-01 13:07:01 -07009456 }
9457 num = htmlTexts.size();
9458 }
9459 if (num > 0) {
9460 final ClipData clipData = new ClipData(
9461 null, new String[] { getType() },
9462 makeClipItem(streams, texts, htmlTexts, 0));
9463
9464 for (int i = 1; i < num; i++) {
9465 clipData.addItem(makeClipItem(streams, texts, htmlTexts, i));
9466 }
9467
9468 setClipData(clipData);
9469 addFlags(FLAG_GRANT_READ_URI_PERMISSION);
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009470 return true;
Jeff Sharkeydd471e62012-05-01 13:07:01 -07009471 }
Jeff Sharkeyf27ea662012-03-27 10:34:24 -07009472 } catch (ClassCastException e) {
Jeff Sharkeyf27ea662012-03-27 10:34:24 -07009473 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009474 } else if (MediaStore.ACTION_IMAGE_CAPTURE.equals(action)
9475 || MediaStore.ACTION_IMAGE_CAPTURE_SECURE.equals(action)
9476 || MediaStore.ACTION_VIDEO_CAPTURE.equals(action)) {
9477 final Uri output;
9478 try {
9479 output = getParcelableExtra(MediaStore.EXTRA_OUTPUT);
9480 } catch (ClassCastException e) {
9481 return false;
9482 }
9483 if (output != null) {
9484 setClipData(ClipData.newRawUri("", output));
9485 addFlags(FLAG_GRANT_WRITE_URI_PERMISSION|FLAG_GRANT_READ_URI_PERMISSION);
9486 return true;
9487 }
Jeff Sharkey678d04f2012-03-23 15:41:58 -07009488 }
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009489
9490 return false;
Jeff Sharkey678d04f2012-03-23 15:41:58 -07009491 }
Dianne Hackbornac4243f2012-04-13 17:32:18 -07009492
9493 private static ClipData.Item makeClipItem(ArrayList<Uri> streams, ArrayList<CharSequence> texts,
9494 ArrayList<String> htmlTexts, int which) {
9495 Uri uri = streams != null ? streams.get(which) : null;
9496 CharSequence text = texts != null ? texts.get(which) : null;
9497 String htmlText = htmlTexts != null ? htmlTexts.get(which) : null;
9498 return new ClipData.Item(text, htmlText, null, uri);
9499 }
Craig Mautnerd00f4742014-03-12 14:17:26 -07009500
9501 /** @hide */
9502 public boolean isDocument() {
9503 return (mFlags & FLAG_ACTIVITY_NEW_DOCUMENT) == FLAG_ACTIVITY_NEW_DOCUMENT;
9504 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009505}