ActivityInfo.java revision cf4550c3198d6b3d92cdc52707fe70d7cc0caa9f
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 * Options that have been set in the activity declaration in the 131 * manifest: {@link #FLAG_MULTIPROCESS}, 132 * {@link #FLAG_FINISH_ON_TASK_LAUNCH}, {@link #FLAG_CLEAR_TASK_ON_LAUNCH}, 133 * {@link #FLAG_ALWAYS_RETAIN_TASK_STATE}, 134 * {@link #FLAG_STATE_NOT_NEEDED}, {@link #FLAG_EXCLUDE_FROM_RECENTS}, 135 * {@link #FLAG_ALLOW_TASK_REPARENTING}, {@link #FLAG_NO_HISTORY}. 136 */ 137 public int flags; 138 139 /** 140 * Constant corresponding to <code>unspecified</code> in 141 * the {@link android.R.attr#screenOrientation} attribute. 142 */ 143 public static final int SCREEN_ORIENTATION_UNSPECIFIED = -1; 144 /** 145 * Constant corresponding to <code>landscape</code> in 146 * the {@link android.R.attr#screenOrientation} attribute. 147 */ 148 public static final int SCREEN_ORIENTATION_LANDSCAPE = 0; 149 /** 150 * Constant corresponding to <code>portrait</code> in 151 * the {@link android.R.attr#screenOrientation} attribute. 152 */ 153 public static final int SCREEN_ORIENTATION_PORTRAIT = 1; 154 /** 155 * Constant corresponding to <code>user</code> in 156 * the {@link android.R.attr#screenOrientation} attribute. 157 */ 158 public static final int SCREEN_ORIENTATION_USER = 2; 159 /** 160 * Constant corresponding to <code>behind</code> in 161 * the {@link android.R.attr#screenOrientation} attribute. 162 */ 163 public static final int SCREEN_ORIENTATION_BEHIND = 3; 164 /** 165 * Constant corresponding to <code>sensor</code> in 166 * the {@link android.R.attr#screenOrientation} attribute. 167 */ 168 public static final int SCREEN_ORIENTATION_SENSOR = 4; 169 170 /** 171 * Constant corresponding to <code>sensor</code> in 172 * the {@link android.R.attr#screenOrientation} attribute. 173 */ 174 public static final int SCREEN_ORIENTATION_NOSENSOR = 5; 175 /** 176 * The preferred screen orientation this activity would like to run in. 177 * From the {@link android.R.attr#screenOrientation} attribute, one of 178 * {@link #SCREEN_ORIENTATION_UNSPECIFIED}, 179 * {@link #SCREEN_ORIENTATION_LANDSCAPE}, 180 * {@link #SCREEN_ORIENTATION_PORTRAIT}, 181 * {@link #SCREEN_ORIENTATION_USER}, 182 * {@link #SCREEN_ORIENTATION_BEHIND}, 183 * {@link #SCREEN_ORIENTATION_SENSOR}, 184 * {@link #SCREEN_ORIENTATION_NOSENSOR}. 185 */ 186 public int screenOrientation = SCREEN_ORIENTATION_UNSPECIFIED; 187 188 /** 189 * Bit in {@link #configChanges} that indicates that the activity 190 * can itself handle changes to the IMSI MCC. Set from the 191 * {@link android.R.attr#configChanges} attribute. 192 */ 193 public static final int CONFIG_MCC = 0x0001; 194 /** 195 * Bit in {@link #configChanges} that indicates that the activity 196 * can itself handle changes to the IMSI MNC. Set from the 197 * {@link android.R.attr#configChanges} attribute. 198 */ 199 public static final int CONFIG_MNC = 0x0002; 200 /** 201 * Bit in {@link #configChanges} that indicates that the activity 202 * can itself handle changes to the locale. Set from the 203 * {@link android.R.attr#configChanges} attribute. 204 */ 205 public static final int CONFIG_LOCALE = 0x0004; 206 /** 207 * Bit in {@link #configChanges} that indicates that the activity 208 * can itself handle changes to the touchscreen type. Set from the 209 * {@link android.R.attr#configChanges} attribute. 210 */ 211 public static final int CONFIG_TOUCHSCREEN = 0x0008; 212 /** 213 * Bit in {@link #configChanges} that indicates that the activity 214 * can itself handle changes to the keyboard type. Set from the 215 * {@link android.R.attr#configChanges} attribute. 216 */ 217 public static final int CONFIG_KEYBOARD = 0x0010; 218 /** 219 * Bit in {@link #configChanges} that indicates that the activity 220 * can itself handle changes to the keyboard being hidden/exposed. 221 * Set from the {@link android.R.attr#configChanges} attribute. 222 */ 223 public static final int CONFIG_KEYBOARD_HIDDEN = 0x0020; 224 /** 225 * Bit in {@link #configChanges} that indicates that the activity 226 * can itself handle changes to the navigation type. Set from the 227 * {@link android.R.attr#configChanges} attribute. 228 */ 229 public static final int CONFIG_NAVIGATION = 0x0040; 230 /** 231 * Bit in {@link #configChanges} that indicates that the activity 232 * can itself handle changes to the screen orientation. Set from the 233 * {@link android.R.attr#configChanges} attribute. 234 */ 235 public static final int CONFIG_ORIENTATION = 0x0080; 236 /** 237 * Bit in {@link #configChanges} that indicates that the activity 238 * can itself handle changes to the screen layout. Set from the 239 * {@link android.R.attr#configChanges} attribute. 240 */ 241 public static final int CONFIG_SCREEN_LAYOUT = 0x0100; 242 /** 243 * Bit in {@link #configChanges} that indicates that the activity 244 * can itself handle changes to the font scaling factor. Set from the 245 * {@link android.R.attr#configChanges} attribute. This is 246 * not a core resource configutation, but a higher-level value, so its 247 * constant starts at the high bits. 248 */ 249 public static final int CONFIG_FONT_SCALE = 0x40000000; 250 251 /** 252 * Bit mask of kinds of configuration changes that this activity 253 * can handle itself (without being restarted by the system). 254 * Contains any combination of {@link #CONFIG_FONT_SCALE}, 255 * {@link #CONFIG_MCC}, {@link #CONFIG_MNC}, 256 * {@link #CONFIG_LOCALE}, {@link #CONFIG_TOUCHSCREEN}, 257 * {@link #CONFIG_KEYBOARD}, {@link #CONFIG_NAVIGATION}, 258 * {@link #CONFIG_ORIENTATION}, and {@link #CONFIG_SCREEN_LAYOUT}. Set from the 259 * {@link android.R.attr#configChanges} attribute. 260 */ 261 public int configChanges; 262 263 /** 264 * The desired soft input mode for this activity's main window. 265 * Set from the {@link android.R.attr#windowSoftInputMode} attribute 266 * in the activity's manifest. May be any of the same values allowed 267 * for {@link android.view.WindowManager.LayoutParams#softInputMode 268 * WindowManager.LayoutParams.softInputMode}. If 0 (unspecified), 269 * the mode from the theme will be used. 270 */ 271 public int softInputMode; 272 273 public ActivityInfo() { 274 } 275 276 public ActivityInfo(ActivityInfo orig) { 277 super(orig); 278 theme = orig.theme; 279 launchMode = orig.launchMode; 280 permission = orig.permission; 281 taskAffinity = orig.taskAffinity; 282 targetActivity = orig.targetActivity; 283 flags = orig.flags; 284 screenOrientation = orig.screenOrientation; 285 configChanges = orig.configChanges; 286 softInputMode = orig.softInputMode; 287 } 288 289 /** 290 * Return the theme resource identifier to use for this activity. If 291 * the activity defines a theme, that is used; else, the application 292 * theme is used. 293 * 294 * @return The theme associated with this activity. 295 */ 296 public final int getThemeResource() { 297 return theme != 0 ? theme : applicationInfo.theme; 298 } 299 300 public void dump(Printer pw, String prefix) { 301 super.dumpFront(pw, prefix); 302 pw.println(prefix + "permission=" + permission); 303 pw.println(prefix + "taskAffinity=" + taskAffinity 304 + " targetActivity=" + targetActivity); 305 pw.println(prefix + "launchMode=" + launchMode 306 + " flags=0x" + Integer.toHexString(flags) 307 + " theme=0x" + Integer.toHexString(theme)); 308 pw.println(prefix + "screenOrientation=" + screenOrientation 309 + " configChanges=0x" + Integer.toHexString(configChanges) 310 + " softInputMode=0x" + Integer.toHexString(softInputMode)); 311 super.dumpBack(pw, prefix); 312 } 313 314 public String toString() { 315 return "ActivityInfo{" 316 + Integer.toHexString(System.identityHashCode(this)) 317 + " " + name + "}"; 318 } 319 320 public int describeContents() { 321 return 0; 322 } 323 324 public void writeToParcel(Parcel dest, int parcelableFlags) { 325 super.writeToParcel(dest, parcelableFlags); 326 dest.writeInt(theme); 327 dest.writeInt(launchMode); 328 dest.writeString(permission); 329 dest.writeString(taskAffinity); 330 dest.writeString(targetActivity); 331 dest.writeInt(flags); 332 dest.writeInt(screenOrientation); 333 dest.writeInt(configChanges); 334 dest.writeInt(softInputMode); 335 } 336 337 public static final Parcelable.Creator<ActivityInfo> CREATOR 338 = new Parcelable.Creator<ActivityInfo>() { 339 public ActivityInfo createFromParcel(Parcel source) { 340 return new ActivityInfo(source); 341 } 342 public ActivityInfo[] newArray(int size) { 343 return new ActivityInfo[size]; 344 } 345 }; 346 347 private ActivityInfo(Parcel source) { 348 super(source); 349 theme = source.readInt(); 350 launchMode = source.readInt(); 351 permission = source.readString(); 352 taskAffinity = source.readString(); 353 targetActivity = source.readString(); 354 flags = source.readInt(); 355 screenOrientation = source.readInt(); 356 configChanges = source.readInt(); 357 softInputMode = source.readInt(); 358 } 359} 360