2 * Copyright (C) 2007 The Android Open Source Project
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 package android.content.pm;
19 import android.os.Parcel;
20 import android.os.Parcelable;
21 import android.util.Printer;
24 * Information you can retrieve about a particular application
25 * activity or receiver. This corresponds to information collected
26 * from the AndroidManifest.xml's <activity> and
27 * <receiver> tags.
29 public class ActivityInfo extends ComponentInfo
30 implements Parcelable {
32 * A style resource identifier (in the package's resources) of this
33 * activity's theme. From the "theme" attribute or, if not set, 0.
38 * Constant corresponding to <code>standard</code> in
39 * the {@link android.R.attr#launchMode} attribute.
41 public static final int LAUNCH_MULTIPLE = 0;
43 * Constant corresponding to <code>singleTop</code> in
44 * the {@link android.R.attr#launchMode} attribute.
46 public static final int LAUNCH_SINGLE_TOP = 1;
48 * Constant corresponding to <code>singleTask</code> in
49 * the {@link android.R.attr#launchMode} attribute.
51 public static final int LAUNCH_SINGLE_TASK = 2;
53 * Constant corresponding to <code>singleInstance</code> in
54 * the {@link android.R.attr#launchMode} attribute.
56 public static final int LAUNCH_SINGLE_INSTANCE = 3;
58 * The launch mode style requested by the activity. From the
59 * {@link android.R.attr#launchMode} attribute, one of
60 * {@link #LAUNCH_MULTIPLE},
61 * {@link #LAUNCH_SINGLE_TOP}, {@link #LAUNCH_SINGLE_TASK}, or
62 * {@link #LAUNCH_SINGLE_INSTANCE}.
64 public int launchMode;
67 * Optional name of a permission required to be able to access this
68 * Activity. From the "permission" attribute.
70 public String permission;
73 * The affinity this activity has for another task in the system. The
74 * string here is the name of the task, often the package name of the
75 * overall package. If null, the activity has no affinity. Set from the
76 * {@link android.R.attr#taskAffinity} attribute.
78 public String taskAffinity;
81 * If this is an activity alias, this is the real activity class to run
82 * for it. Otherwise, this is null.
84 public String targetActivity;
87 * Bit in {@link #flags} indicating whether this activity is able to
88 * run in multiple processes. If
89 * true, the system may instantiate it in the some process as the
90 * process starting it in order to conserve resources. If false, the
91 * default, it always runs in {@link #processName}. Set from the
92 * {@link android.R.attr#multiprocess} attribute.
94 public static final int FLAG_MULTIPROCESS = 0x0001;
96 * Bit in {@link #flags} indicating that, when the activity's task is
97 * relaunched from home, this activity should be finished.
99 * {@link android.R.attr#finishOnTaskLaunch} attribute.
101 public static final int FLAG_FINISH_ON_TASK_LAUNCH = 0x0002;
103 * Bit in {@link #flags} indicating that, when the activity is the root
104 * of a task, that task's stack should be cleared each time the user
105 * re-launches it from home. As a result, the user will always
106 * return to the original activity at the top of the task.
107 * This flag only applies to activities that
108 * are used to start the root of a new task. Set from the
109 * {@link android.R.attr#clearTaskOnLaunch} attribute.
111 public static final int FLAG_CLEAR_TASK_ON_LAUNCH = 0x0004;
113 * Bit in {@link #flags} indicating that, when the activity is the root
114 * of a task, that task's stack should never be cleared when it is
115 * relaunched from home. Set from the
116 * {@link android.R.attr#alwaysRetainTaskState} attribute.
118 public static final int FLAG_ALWAYS_RETAIN_TASK_STATE = 0x0008;
120 * Bit in {@link #flags} indicating that the activity's state
121 * is not required to be saved, so that if there is a failure the
122 * activity will not be removed from the activity stack. Set from the
123 * {@link android.R.attr#stateNotNeeded} attribute.
125 public static final int FLAG_STATE_NOT_NEEDED = 0x0010;
127 * Bit in {@link #flags} that indicates that the activity should not
128 * appear in the list of recently launched activities. Set from the
129 * {@link android.R.attr#excludeFromRecents} attribute.
131 public static final int FLAG_EXCLUDE_FROM_RECENTS = 0x0020;
133 * Bit in {@link #flags} that indicates that the activity can be moved
134 * between tasks based on its task affinity. Set from the
135 * {@link android.R.attr#allowTaskReparenting} attribute.
137 public static final int FLAG_ALLOW_TASK_REPARENTING = 0x0040;
139 * Bit in {@link #flags} indicating that, when the user navigates away
140 * from an activity, it should be finished.
142 * {@link android.R.attr#noHistory} attribute.
144 public static final int FLAG_NO_HISTORY = 0x0080;
146 * Bit in {@link #flags} indicating that, when a request to close system
147 * windows happens, this activity is finished.
149 * {@link android.R.attr#finishOnCloseSystemDialogs} attribute.
151 public static final int FLAG_FINISH_ON_CLOSE_SYSTEM_DIALOGS = 0x0100;
153 * Options that have been set in the activity declaration in the
156 * {@link #FLAG_MULTIPROCESS},
157 * {@link #FLAG_FINISH_ON_TASK_LAUNCH}, {@link #FLAG_CLEAR_TASK_ON_LAUNCH},
158 * {@link #FLAG_ALWAYS_RETAIN_TASK_STATE},
159 * {@link #FLAG_STATE_NOT_NEEDED}, {@link #FLAG_EXCLUDE_FROM_RECENTS},
160 * {@link #FLAG_ALLOW_TASK_REPARENTING}, {@link #FLAG_NO_HISTORY},
161 * {@link #FLAG_FINISH_ON_CLOSE_SYSTEM_DIALOGS},
166 * Constant corresponding to <code>unspecified</code> in
167 * the {@link android.R.attr#screenOrientation} attribute.
169 public static final int SCREEN_ORIENTATION_UNSPECIFIED = -1;
171 * Constant corresponding to <code>landscape</code> in
172 * the {@link android.R.attr#screenOrientation} attribute.
174 public static final int SCREEN_ORIENTATION_LANDSCAPE = 0;
176 * Constant corresponding to <code>portrait</code> in
177 * the {@link android.R.attr#screenOrientation} attribute.
179 public static final int SCREEN_ORIENTATION_PORTRAIT = 1;
181 * Constant corresponding to <code>user</code> in
182 * the {@link android.R.attr#screenOrientation} attribute.
184 public static final int SCREEN_ORIENTATION_USER = 2;
186 * Constant corresponding to <code>behind</code> in
187 * the {@link android.R.attr#screenOrientation} attribute.
189 public static final int SCREEN_ORIENTATION_BEHIND = 3;
191 * Constant corresponding to <code>sensor</code> in
192 * the {@link android.R.attr#screenOrientation} attribute.
194 public static final int SCREEN_ORIENTATION_SENSOR = 4;
197 * Constant corresponding to <code>nosensor</code> in
198 * the {@link android.R.attr#screenOrientation} attribute.
200 public static final int SCREEN_ORIENTATION_NOSENSOR = 5;
203 * Constant corresponding to <code>sensorLandscape</code> in
204 * the {@link android.R.attr#screenOrientation} attribute.
206 public static final int SCREEN_ORIENTATION_SENSOR_LANDSCAPE = 6;
209 * Constant corresponding to <code>sensorPortrait</code> in
210 * the {@link android.R.attr#screenOrientation} attribute.
212 public static final int SCREEN_ORIENTATION_SENSOR_PORTRAIT = 7;
215 * Constant corresponding to <code>reverseLandscape</code> in
216 * the {@link android.R.attr#screenOrientation} attribute.
218 public static final int SCREEN_ORIENTATION_REVERSE_LANDSCAPE = 8;
221 * Constant corresponding to <code>reversePortrait</code> in
222 * the {@link android.R.attr#screenOrientation} attribute.
224 public static final int SCREEN_ORIENTATION_REVERSE_PORTRAIT = 9;
227 * Constant corresponding to <code>fullSensor</code> in
228 * the {@link android.R.attr#screenOrientation} attribute.
230 public static final int SCREEN_ORIENTATION_FULL_SENSOR = 10;
233 * The preferred screen orientation this activity would like to run in.
234 * From the {@link android.R.attr#screenOrientation} attribute, one of
235 * {@link #SCREEN_ORIENTATION_UNSPECIFIED},
236 * {@link #SCREEN_ORIENTATION_LANDSCAPE},
237 * {@link #SCREEN_ORIENTATION_PORTRAIT},
238 * {@link #SCREEN_ORIENTATION_USER},
239 * {@link #SCREEN_ORIENTATION_BEHIND},
240 * {@link #SCREEN_ORIENTATION_SENSOR},
241 * {@link #SCREEN_ORIENTATION_NOSENSOR},
242 * {@link #SCREEN_ORIENTATION_SENSOR_LANDSCAPE},
243 * {@link #SCREEN_ORIENTATION_SENSOR_PORTRAIT},
244 * {@link #SCREEN_ORIENTATION_REVERSE_LANDSCAPE},
245 * {@link #SCREEN_ORIENTATION_REVERSE_PORTRAIT},
246 * {@link #SCREEN_ORIENTATION_FULL_SENSOR}.
248 public int screenOrientation = SCREEN_ORIENTATION_UNSPECIFIED;
251 * Bit in {@link #configChanges} that indicates that the activity
252 * can itself handle changes to the IMSI MCC. Set from the
253 * {@link android.R.attr#configChanges} attribute.
255 public static final int CONFIG_MCC = 0x0001;
257 * Bit in {@link #configChanges} that indicates that the activity
258 * can itself handle changes to the IMSI MNC. Set from the
259 * {@link android.R.attr#configChanges} attribute.
261 public static final int CONFIG_MNC = 0x0002;
263 * Bit in {@link #configChanges} that indicates that the activity
264 * can itself handle changes to the locale. Set from the
265 * {@link android.R.attr#configChanges} attribute.
267 public static final int CONFIG_LOCALE = 0x0004;
269 * Bit in {@link #configChanges} that indicates that the activity
270 * can itself handle changes to the touchscreen type. Set from the
271 * {@link android.R.attr#configChanges} attribute.
273 public static final int CONFIG_TOUCHSCREEN = 0x0008;
275 * Bit in {@link #configChanges} that indicates that the activity
276 * can itself handle changes to the keyboard type. Set from the
277 * {@link android.R.attr#configChanges} attribute.
279 public static final int CONFIG_KEYBOARD = 0x0010;
281 * Bit in {@link #configChanges} that indicates that the activity
282 * can itself handle changes to the keyboard or navigation being hidden/exposed.
283 * Note that inspite of the name, this applies to the changes to any
284 * hidden states: keyboard or navigation.
285 * Set from the {@link android.R.attr#configChanges} attribute.
287 public static final int CONFIG_KEYBOARD_HIDDEN = 0x0020;
289 * Bit in {@link #configChanges} that indicates that the activity
290 * can itself handle changes to the navigation type. Set from the
291 * {@link android.R.attr#configChanges} attribute.
293 public static final int CONFIG_NAVIGATION = 0x0040;
295 * Bit in {@link #configChanges} that indicates that the activity
296 * can itself handle changes to the screen orientation. Set from the
297 * {@link android.R.attr#configChanges} attribute.
299 public static final int CONFIG_ORIENTATION = 0x0080;
301 * Bit in {@link #configChanges} that indicates that the activity
302 * can itself handle changes to the screen layout. Set from the
303 * {@link android.R.attr#configChanges} attribute.
305 public static final int CONFIG_SCREEN_LAYOUT = 0x0100;
307 * Bit in {@link #configChanges} that indicates that the activity
308 * can itself handle the ui mode. Set from the
309 * {@link android.R.attr#configChanges} attribute.
311 public static final int CONFIG_UI_MODE = 0x0200;
313 * Bit in {@link #configChanges} that indicates that the activity
314 * can itself handle changes to the font scaling factor. Set from the
315 * {@link android.R.attr#configChanges} attribute. This is
316 * not a core resource configutation, but a higher-level value, so its
317 * constant starts at the high bits.
319 public static final int CONFIG_FONT_SCALE = 0x40000000;
322 * Bit mask of kinds of configuration changes that this activity
323 * can handle itself (without being restarted by the system).
324 * Contains any combination of {@link #CONFIG_FONT_SCALE},
325 * {@link #CONFIG_MCC}, {@link #CONFIG_MNC},
326 * {@link #CONFIG_LOCALE}, {@link #CONFIG_TOUCHSCREEN},
327 * {@link #CONFIG_KEYBOARD}, {@link #CONFIG_NAVIGATION},
328 * {@link #CONFIG_ORIENTATION}, and {@link #CONFIG_SCREEN_LAYOUT}. Set from the
329 * {@link android.R.attr#configChanges} attribute.
331 public int configChanges;
334 * The desired soft input mode for this activity's main window.
335 * Set from the {@link android.R.attr#windowSoftInputMode} attribute
336 * in the activity's manifest. May be any of the same values allowed
337 * for {@link android.view.WindowManager.LayoutParams#softInputMode
338 * WindowManager.LayoutParams.softInputMode}. If 0 (unspecified),
339 * the mode from the theme will be used.
341 public int softInputMode;
343 public ActivityInfo() {
346 public ActivityInfo(ActivityInfo orig) {
349 launchMode = orig.launchMode;
350 permission = orig.permission;
351 taskAffinity = orig.taskAffinity;
352 targetActivity = orig.targetActivity;
354 screenOrientation = orig.screenOrientation;
355 configChanges = orig.configChanges;
356 softInputMode = orig.softInputMode;
360 * Return the theme resource identifier to use for this activity. If
361 * the activity defines a theme, that is used; else, the application
364 * @return The theme associated with this activity.
366 public final int getThemeResource() {
367 return theme != 0 ? theme : applicationInfo.theme;
370 public void dump(Printer pw, String prefix) {
371 super.dumpFront(pw, prefix);
372 if (permission != null) {
373 pw.println(prefix + "permission=" + permission);
375 pw.println(prefix + "taskAffinity=" + taskAffinity
376 + " targetActivity=" + targetActivity);
377 if (launchMode != 0 || flags != 0 || theme != 0) {
378 pw.println(prefix + "launchMode=" + launchMode
379 + " flags=0x" + Integer.toHexString(flags)
380 + " theme=0x" + Integer.toHexString(theme));
382 if (screenOrientation != SCREEN_ORIENTATION_UNSPECIFIED
383 || configChanges != 0 || softInputMode != 0) {
384 pw.println(prefix + "screenOrientation=" + screenOrientation
385 + " configChanges=0x" + Integer.toHexString(configChanges)
386 + " softInputMode=0x" + Integer.toHexString(softInputMode));
388 super.dumpBack(pw, prefix);
391 public String toString() {
392 return "ActivityInfo{"
393 + Integer.toHexString(System.identityHashCode(this))
397 public int describeContents() {
401 public void writeToParcel(Parcel dest, int parcelableFlags) {
402 super.writeToParcel(dest, parcelableFlags);
403 dest.writeInt(theme);
404 dest.writeInt(launchMode);
405 dest.writeString(permission);
406 dest.writeString(taskAffinity);
407 dest.writeString(targetActivity);
408 dest.writeInt(flags);
409 dest.writeInt(screenOrientation);
410 dest.writeInt(configChanges);
411 dest.writeInt(softInputMode);
414 public static final Parcelable.Creator<ActivityInfo> CREATOR
415 = new Parcelable.Creator<ActivityInfo>() {
416 public ActivityInfo createFromParcel(Parcel source) {
417 return new ActivityInfo(source);
419 public ActivityInfo[] newArray(int size) {
420 return new ActivityInfo[size];
424 private ActivityInfo(Parcel source) {
426 theme = source.readInt();
427 launchMode = source.readInt();
428 permission = source.readString();
429 taskAffinity = source.readString();
430 targetActivity = source.readString();
431 flags = source.readInt();
432 screenOrientation = source.readInt();
433 configChanges = source.readInt();
434 softInputMode = source.readInt();