ActivityInfo.java revision 9066cfe9886ac131c34d59ed0e2d287b0e3c0087
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 font scaling factor. Set from the 239 * {@link android.R.attr#configChanges} attribute. This is 240 * not a core resource configutation, but a higher-level value, so its 241 * constant starts at the high bits. 242 */ 243 public static final int CONFIG_FONT_SCALE = 0x40000000; 244 245 /** 246 * Bit mask of kinds of configuration changes that this activity 247 * can handle itself (without being restarted by the system). 248 * Contains any combination of {@link #CONFIG_FONT_SCALE}, 249 * {@link #CONFIG_MCC}, {@link #CONFIG_MNC}, 250 * {@link #CONFIG_LOCALE}, {@link #CONFIG_TOUCHSCREEN}, 251 * {@link #CONFIG_KEYBOARD}, {@link #CONFIG_NAVIGATION}, and 252 * {@link #CONFIG_ORIENTATION}. Set from the 253 * {@link android.R.attr#configChanges} attribute. 254 */ 255 public int configChanges; 256 257 /** 258 * The desired soft input mode for this activity's main window. 259 * Set from the {@link android.R.attr#windowSoftInputMode} attribute 260 * in the activity's manifest. May be any of the same values allowed 261 * for {@link android.view.WindowManager.LayoutParams#softInputMode 262 * WindowManager.LayoutParams.softInputMode}. If 0 (unspecified), 263 * the mode from the theme will be used. 264 */ 265 public int softInputMode; 266 267 public ActivityInfo() { 268 } 269 270 public ActivityInfo(ActivityInfo orig) { 271 super(orig); 272 theme = orig.theme; 273 launchMode = orig.launchMode; 274 permission = orig.permission; 275 taskAffinity = orig.taskAffinity; 276 targetActivity = orig.targetActivity; 277 flags = orig.flags; 278 screenOrientation = orig.screenOrientation; 279 configChanges = orig.configChanges; 280 softInputMode = orig.softInputMode; 281 } 282 283 /** 284 * Return the theme resource identifier to use for this activity. If 285 * the activity defines a theme, that is used; else, the application 286 * theme is used. 287 * 288 * @return The theme associated with this activity. 289 */ 290 public final int getThemeResource() { 291 return theme != 0 ? theme : applicationInfo.theme; 292 } 293 294 public void dump(Printer pw, String prefix) { 295 super.dumpFront(pw, prefix); 296 pw.println(prefix + "permission=" + permission); 297 pw.println(prefix + "taskAffinity=" + taskAffinity 298 + " targetActivity=" + targetActivity); 299 pw.println(prefix + "launchMode=" + launchMode 300 + " flags=0x" + Integer.toHexString(flags) 301 + " theme=0x" + Integer.toHexString(theme)); 302 pw.println(prefix + "screenOrientation=" + screenOrientation 303 + " configChanges=0x" + Integer.toHexString(configChanges) 304 + " softInputMode=0x" + Integer.toHexString(softInputMode)); 305 super.dumpBack(pw, prefix); 306 } 307 308 public String toString() { 309 return "ActivityInfo{" 310 + Integer.toHexString(System.identityHashCode(this)) 311 + " " + name + "}"; 312 } 313 314 public int describeContents() { 315 return 0; 316 } 317 318 public void writeToParcel(Parcel dest, int parcelableFlags) { 319 super.writeToParcel(dest, parcelableFlags); 320 dest.writeInt(theme); 321 dest.writeInt(launchMode); 322 dest.writeString(permission); 323 dest.writeString(taskAffinity); 324 dest.writeString(targetActivity); 325 dest.writeInt(flags); 326 dest.writeInt(screenOrientation); 327 dest.writeInt(configChanges); 328 dest.writeInt(softInputMode); 329 } 330 331 public static final Parcelable.Creator<ActivityInfo> CREATOR 332 = new Parcelable.Creator<ActivityInfo>() { 333 public ActivityInfo createFromParcel(Parcel source) { 334 return new ActivityInfo(source); 335 } 336 public ActivityInfo[] newArray(int size) { 337 return new ActivityInfo[size]; 338 } 339 }; 340 341 private ActivityInfo(Parcel source) { 342 super(source); 343 theme = source.readInt(); 344 launchMode = source.readInt(); 345 permission = source.readString(); 346 taskAffinity = source.readString(); 347 targetActivity = source.readString(); 348 flags = source.readInt(); 349 screenOrientation = source.readInt(); 350 configChanges = source.readInt(); 351 softInputMode = source.readInt(); 352 } 353} 354