android:launchMode,即Activity的启动模式,与Intent中的Flags共同作用,决定Activity如何启动。
android:launchMode分别有"standard", "singleTop", "singleTask", "singleInstance".
"standard": 每次都创建新的实例;
"singleTop": 如果目标Task的顶端是就是对应的实例,那么这个实例将会接受新的Intent;否则,创建新的实例;
"singleTask": 同一个Task中只允许存在一个实例,而且这个实例必须在该Task的Activity堆栈的低端,允许其他Activity实例存在;
"singleInstance": 同一个Task中只允许存在一个实例,而且不允许其他Activity实例存在。
android:configChanges
当一些配置发生改变时,Activity将会关闭,然后重启,但是配置了这个选项,可以捕获配置改变的事件,从而避免Activity重启。
可捕获的事件如:
Value | Description |
"mcc " | The IMSI mobile country code (MCC) has changed — a SIM has been detected and updated the MCC. 系统监测到SIM卡之后,会更新MCC。 |
"mnc " | The IMSI mobile network code (MNC) has changed — a SIM has been detected and updated the MNC. 系统监测到SIM卡之后,会更新MNC。 |
"locale " | The locale has changed — the user has selected a new language that text should be displayed in. 用户更改系统语言。 |
"touchscreen " | The touchscreen has changed. (This should never normally happen.) |
"keyboard " | The keyboard type has changed — for example, the user has plugged in an external keyboard. 键盘发生改变,如用户插入外接键盘。 |
"keyboardHidden " | The keyboard accessibility has changed — for example, the user has revealed the hardware keyboard. 键盘可见性改变。 |
"navigation " | The navigation type (trackball/dpad) has changed. (This should never normally happen.) |
"screenLayout " | The screen layout has changed — this might be caused by a different display being activated. 屏幕布局发生变化,如其他不同的显示器打开了。 |
"fontScale " | The font scaling factor has changed — the user has selected a new global font size. 用户修改了系统全局字体大小。 |
"uiMode " | The user interface mode has changed — this can be caused when the user places the device into a desk/car dock or when the night mode changes. See UiModeManager . Added in API level 8. 系统uiMode发生改变,如进入夜视模式。 |
"orientation " | The screen orientation has changed — the user has rotated the device. 屏幕方向改变了,如旋转屏幕。 Note: If your application targets API level 13 or higher (as declared by the |
"screenSize " | The current available screen size has changed. This represents a change in the currently available size, relative to the current aspect ratio, so will change when the user switches between landscape and portrait. However, if your application targets API level 12 or lower, then your activity always handles this configuration change itself (this configuration change does not restart your activity, even when running on an Android 3.2 or higher device). 当前可用屏幕大小发生改变(用户在切换屏幕横/纵向时)。 Added in API level 13. |
"smallestScreenSize " | The physical screen size has changed. This represents a change in size regardless of orientation, so will only change when the actual physical screen size has changed such as switching to an external display. A change to this configuration corresponds to a change in the smallestWidth configuration. However, if your application targets API level 12 or lower, then your activity always handles this configuration change itself (this configuration change does not restart your activity, even when running on an Android 3.2 or higher device). 物理屏幕发生改变时(连接外部显示器) Added in API level 13. |
"layoutDirection " | The layout direction has changed. For example, changing from left-to-right (LTR) to right-to-left (RTL). Added in API level 17.布局方向发生改变。 |