ActivityInfo.java revision ffa424800d0338b8b894aef2ea1e3e3344cbda7a
1package android.content.pm; 2 3import android.os.Parcel; 4import android.os.Parcelable; 5import android.util.Printer; 6 7/** 8 * Information you can retrieve about a particular application 9 * activity or receiver. This corresponds to information collected 10 * from the AndroidManifest.xml's <activity> and 11 * <receiver> tags. 12 */ 13public class ActivityInfo extends ComponentInfo 14 implements Parcelable { 15 /** 16 * A style resource identifier (in the package's resources) of this 17 * activity's theme. From the "theme" attribute or, if not set, 0. 18 */ 19 public int theme; 20 21 /** 22 * Constant corresponding to <code>standard</code> in 23 * the {@link android.R.attr#launchMode} attribute. 24 */ 25 public static final int LAUNCH_MULTIPLE = 0; 26 /** 27 * Constant corresponding to <code>singleTop</code> in 28 * the {@link android.R.attr#launchMode} attribute. 29 */ 30 public static final int LAUNCH_SINGLE_TOP = 1; 31 /** 32 * Constant corresponding to <code>singleTask</code> in 33 * the {@link android.R.attr#launchMode} attribute. 34 */ 35 public static final int LAUNCH_SINGLE_TASK = 2; 36 /** 37 * Constant corresponding to <code>singleInstance</code> in 38 * the {@link android.R.attr#launchMode} attribute. 39 */ 40 public static final int LAUNCH_SINGLE_INSTANCE = 3; 41 /** 42 * The launch mode style requested by the activity. From the 43 * {@link android.R.attr#launchMode} attribute, one of 44 * {@link #LAUNCH_MULTIPLE}, 45 * {@link #LAUNCH_SINGLE_TOP}, {@link #LAUNCH_SINGLE_TASK}, or 46 * {@link #LAUNCH_SINGLE_INSTANCE}. 47 */ 48 public int launchMode; 49 50 /** 51 * Optional name of a permission required to be able to access this 52 * Activity. From the "permission" attribute. 53 */ 54 public String permission; 55 56 /** 57 * The affinity this activity has for another task in the system. The 58 * string here is the name of the task, often the package name of the 59 * overall package. If null, the activity has no affinity. Set from the 60 * {@link android.R.attr#taskAffinity} attribute. 61 */ 62 public String taskAffinity; 63 64 /** 65 * If this is an activity alias, this is the real activity class to run 66 * for it. Otherwise, this is null. 67 */ 68 public String targetActivity; 69 70 /** 71 * Bit in {@link #flags} indicating whether this activity is able to 72 * run in multiple processes. If 73 * true, the system may instantiate it in the some process as the 74 * process starting it in order to conserve resources. If false, the 75 * default, it always runs in {@link #processName}. Set from the 76 * {@link android.R.attr#multiprocess} attribute. 77 */ 78 public static final int FLAG_MULTIPROCESS = 0x0001; 79 /** 80 * Bit in {@link #flags} indicating that, when the activity's task is 81 * relaunched from home, this activity should be finished. 82 * Set from the 83 * {@link android.R.attr#finishOnTaskLaunch} attribute. 84 */ 85 public static final int FLAG_FINISH_ON_TASK_LAUNCH = 0x0002; 86 /** 87 * Bit in {@link #flags} indicating that, when the activity is the root 88 * of a task, that task's stack should be cleared each time the user 89 * re-launches it from home. As a result, the user will always 90 * return to the original activity at the top of the task. 91 * This flag only applies to activities that 92 * are used to start the root of a new task. Set from the 93 * {@link android.R.attr#clearTaskOnLaunch} attribute. 94 */ 95 public static final int FLAG_CLEAR_TASK_ON_LAUNCH = 0x0004; 96 /** 97 * Bit in {@link #flags} indicating that, when the activity is the root 98 * of a task, that task's stack should never be cleared when it is 99 * relaunched from home. Set from the 100 * {@link android.R.attr#alwaysRetainTaskState} attribute. 101 */ 102 public static final int FLAG_ALWAYS_RETAIN_TASK_STATE = 0x0008; 103 /** 104 * Bit in {@link #flags} indicating that the activity's state 105 * is not required to be saved, so that if there is a failure the 106 * activity will not be removed from the activity stack. Set from the 107 * {@link android.R.attr#stateNotNeeded} attribute. 108 */ 109 public static final int FLAG_STATE_NOT_NEEDED = 0x0010; 110 /** 111 * Bit in {@link #flags} that indicates that the activity should not 112 * appear in the list of recently launched activities. Set from the 113 * {@link android.R.attr#excludeFromRecents} attribute. 114 */ 115 public static final int FLAG_EXCLUDE_FROM_RECENTS = 0x0020; 116 /** 117 * Bit in {@link #flags} that indicates that the activity can be moved 118 * between tasks based on its task affinity. Set from the 119 * {@link android.R.attr#allowTaskReparenting} attribute. 120 */ 121 public static final int FLAG_ALLOW_TASK_REPARENTING = 0x0040; 122 /** 123 * Bit in {@link #flags} indicating that, when the user navigates away 124 * from an activity, it should be finished. 125 * Set from the 126 * {@link android.R.attr#noHistory} attribute. 127 */ 128 public static final int FLAG_NO_HISTORY = 0x0080; 129 /** 130 * Bit in {@link #flags} indicating that, when a request to close system 131 * windows happens, this activity is finished. 132 * Set from the 133 * {@link android.R.attr#finishOnCloseSystemDialogs} attribute. 134 */ 135 public static final int FLAG_FINISH_ON_CLOSE_SYSTEM_DIALOGS = 0x0100; 136 /** 137 * Options that have been set in the activity declaration in the 138 * manifest: {@link #FLAG_MULTIPROCESS}, 139 * {@link #FLAG_FINISH_ON_TASK_LAUNCH}, {@link #FLAG_CLEAR_TASK_ON_LAUNCH}, 140 * {@link #FLAG_ALWAYS_RETAIN_TASK_STATE}, 141 * {@link #FLAG_STATE_NOT_NEEDED}, {@link #FLAG_EXCLUDE_FROM_RECENTS}, 142 * {@link #FLAG_ALLOW_TASK_REPARENTING}, {@link #FLAG_NO_HISTORY}, 143 * {@link #FLAG_FINISH_ON_CLOSE_SYSTEM_DIALOGS}. 144 */ 145 public int flags; 146 147 /** 148 * Constant corresponding to <code>unspecified</code> in 149 * the {@link android.R.attr#screenOrientation} attribute. 150 */ 151 public static final int SCREEN_ORIENTATION_UNSPECIFIED = -1; 152 /** 153 * Constant corresponding to <code>landscape</code> in 154 * the {@link android.R.attr#screenOrientation} attribute. 155 */ 156 public static final int SCREEN_ORIENTATION_LANDSCAPE = 0; 157 /** 158 * Constant corresponding to <code>portrait</code> in 159 * the {@link android.R.attr#screenOrientation} attribute. 160 */ 161 public static final int SCREEN_ORIENTATION_PORTRAIT = 1; 162 /** 163 * Constant corresponding to <code>user</code> in 164 * the {@link android.R.attr#screenOrientation} attribute. 165 */ 166 public static final int SCREEN_ORIENTATION_USER = 2; 167 /** 168 * Constant corresponding to <code>behind</code> in 169 * the {@link android.R.attr#screenOrientation} attribute. 170 */ 171 public static final int SCREEN_ORIENTATION_BEHIND = 3; 172 /** 173 * Constant corresponding to <code>sensor</code> in 174 * the {@link android.R.attr#screenOrientation} attribute. 175 */ 176 public static final int SCREEN_ORIENTATION_SENSOR = 4; 177 178 /** 179 * Constant corresponding to <code>sensor</code> in 180 * the {@link android.R.attr#screenOrientation} attribute. 181 */ 182 public static final int SCREEN_ORIENTATION_NOSENSOR = 5; 183 /** 184 * The preferred screen orientation this activity would like to run in. 185 * From the {@link android.R.attr#screenOrientation} attribute, one of 186 * {@link #SCREEN_ORIENTATION_UNSPECIFIED}, 187 * {@link #SCREEN_ORIENTATION_LANDSCAPE}, 188 * {@link #SCREEN_ORIENTATION_PORTRAIT}, 189 * {@link #SCREEN_ORIENTATION_USER}, 190 * {@link #SCREEN_ORIENTATION_BEHIND}, 191 * {@link #SCREEN_ORIENTATION_SENSOR}, 192 * {@link #SCREEN_ORIENTATION_NOSENSOR}. 193 */ 194 public int screenOrientation = SCREEN_ORIENTATION_UNSPECIFIED; 195 196 /** 197 * Bit in {@link #configChanges} that indicates that the activity 198 * can itself handle changes to the IMSI MCC. Set from the 199 * {@link android.R.attr#configChanges} attribute. 200 */ 201 public static final int CONFIG_MCC = 0x0001; 202 /** 203 * Bit in {@link #configChanges} that indicates that the activity 204 * can itself handle changes to the IMSI MNC. Set from the 205 * {@link android.R.attr#configChanges} attribute. 206 */ 207 public static final int CONFIG_MNC = 0x0002; 208 /** 209 * Bit in {@link #configChanges} that indicates that the activity 210 * can itself handle changes to the locale. Set from the 211 * {@link android.R.attr#configChanges} attribute. 212 */ 213 public static final int CONFIG_LOCALE = 0x0004; 214 /** 215 * Bit in {@link #configChanges} that indicates that the activity 216 * can itself handle changes to the touchscreen type. Set from the 217 * {@link android.R.attr#configChanges} attribute. 218 */ 219 public static final int CONFIG_TOUCHSCREEN = 0x0008; 220 /** 221 * Bit in {@link #configChanges} that indicates that the activity 222 * can itself handle changes to the keyboard type. Set from the 223 * {@link android.R.attr#configChanges} attribute. 224 */ 225 public static final int CONFIG_KEYBOARD = 0x0010; 226 /** 227 * Bit in {@link #configChanges} that indicates that the activity 228 * can itself handle changes to the keyboard or navigation being hidden/exposed. 229 * Note that inspite of the name, this applies to the changes to any 230 * hidden states: keyboard or navigation. 231 * Set from the {@link android.R.attr#configChanges} attribute. 232 */ 233 public static final int CONFIG_KEYBOARD_HIDDEN = 0x0020; 234 /** 235 * Bit in {@link #configChanges} that indicates that the activity 236 * can itself handle changes to the navigation type. Set from the 237 * {@link android.R.attr#configChanges} attribute. 238 */ 239 public static final int CONFIG_NAVIGATION = 0x0040; 240 /** 241 * Bit in {@link #configChanges} that indicates that the activity 242 * can itself handle changes to the screen orientation. Set from the 243 * {@link android.R.attr#configChanges} attribute. 244 */ 245 public static final int CONFIG_ORIENTATION = 0x0080; 246 /** 247 * Bit in {@link #configChanges} that indicates that the activity 248 * can itself handle changes to the screen layout. Set from the 249 * {@link android.R.attr#configChanges} attribute. 250 */ 251 public static final int CONFIG_SCREEN_LAYOUT = 0x0100; 252 /** 253 * Bit in {@link #configChanges} that indicates that the activity 254 * can itself handle changes to the font scaling factor. Set from the 255 * {@link android.R.attr#configChanges} attribute. This is 256 * not a core resource configutation, but a higher-level value, so its 257 * constant starts at the high bits. 258 */ 259 public static final int CONFIG_FONT_SCALE = 0x40000000; 260 261 /** 262 * Bit mask of kinds of configuration changes that this activity 263 * can handle itself (without being restarted by the system). 264 * Contains any combination of {@link #CONFIG_FONT_SCALE}, 265 * {@link #CONFIG_MCC}, {@link #CONFIG_MNC}, 266 * {@link #CONFIG_LOCALE}, {@link #CONFIG_TOUCHSCREEN}, 267 * {@link #CONFIG_KEYBOARD}, {@link #CONFIG_NAVIGATION}, 268 * {@link #CONFIG_ORIENTATION}, and {@link #CONFIG_SCREEN_LAYOUT}. Set from the 269 * {@link android.R.attr#configChanges} attribute. 270 */ 271 public int configChanges; 272 273 /** 274 * The desired soft input mode for this activity's main window. 275 * Set from the {@link android.R.attr#windowSoftInputMode} attribute 276 * in the activity's manifest. May be any of the same values allowed 277 * for {@link android.view.WindowManager.LayoutParams#softInputMode 278 * WindowManager.LayoutParams.softInputMode}. If 0 (unspecified), 279 * the mode from the theme will be used. 280 */ 281 public int softInputMode; 282 283 public ActivityInfo() { 284 } 285 286 public ActivityInfo(ActivityInfo orig) { 287 super(orig); 288 theme = orig.theme; 289 launchMode = orig.launchMode; 290 permission = orig.permission; 291 taskAffinity = orig.taskAffinity; 292 targetActivity = orig.targetActivity; 293 flags = orig.flags; 294 screenOrientation = orig.screenOrientation; 295 configChanges = orig.configChanges; 296 softInputMode = orig.softInputMode; 297 } 298 299 /** 300 * Return the theme resource identifier to use for this activity. If 301 * the activity defines a theme, that is used; else, the application 302 * theme is used. 303 * 304 * @return The theme associated with this activity. 305 */ 306 public final int getThemeResource() { 307 return theme != 0 ? theme : applicationInfo.theme; 308 } 309 310 public void dump(Printer pw, String prefix) { 311 super.dumpFront(pw, prefix); 312 pw.println(prefix + "permission=" + permission); 313 pw.println(prefix + "taskAffinity=" + taskAffinity 314 + " targetActivity=" + targetActivity); 315 pw.println(prefix + "launchMode=" + launchMode 316 + " flags=0x" + Integer.toHexString(flags) 317 + " theme=0x" + Integer.toHexString(theme)); 318 pw.println(prefix + "screenOrientation=" + screenOrientation 319 + " configChanges=0x" + Integer.toHexString(configChanges) 320 + " softInputMode=0x" + Integer.toHexString(softInputMode)); 321 super.dumpBack(pw, prefix); 322 } 323 324 public String toString() { 325 return "ActivityInfo{" 326 + Integer.toHexString(System.identityHashCode(this)) 327 + " " + name + "}"; 328 } 329 330 public int describeContents() { 331 return 0; 332 } 333 334 public void writeToParcel(Parcel dest, int parcelableFlags) { 335 super.writeToParcel(dest, parcelableFlags); 336 dest.writeInt(theme); 337 dest.writeInt(launchMode); 338 dest.writeString(permission); 339 dest.writeString(taskAffinity); 340 dest.writeString(targetActivity); 341 dest.writeInt(flags); 342 dest.writeInt(screenOrientation); 343 dest.writeInt(configChanges); 344 dest.writeInt(softInputMode); 345 } 346 347 public static final Parcelable.Creator<ActivityInfo> CREATOR 348 = new Parcelable.Creator<ActivityInfo>() { 349 public ActivityInfo createFromParcel(Parcel source) { 350 return new ActivityInfo(source); 351 } 352 public ActivityInfo[] newArray(int size) { 353 return new ActivityInfo[size]; 354 } 355 }; 356 357 private ActivityInfo(Parcel source) { 358 super(source); 359 theme = source.readInt(); 360 launchMode = source.readInt(); 361 permission = source.readString(); 362 taskAffinity = source.readString(); 363 targetActivity = source.readString(); 364 flags = source.readInt(); 365 screenOrientation = source.readInt(); 366 configChanges = source.readInt(); 367 softInputMode = source.readInt(); 368 } 369} 370