我正在使用Activity.startLockTask()
并注意到如果我将屏幕固定在活动 A 中,我将无法转换到活动 B。似乎我必须startLockTask()
然后stopLockTask()
再startLockTask()
一次在活动 B 上转换。
有没有更好的方法来处理这个问题,这样我就可以固定整个应用程序,而不管我在做什么活动?
这就是我固定应用程序的方式:
// start lock task mode if it's not already active
ActivityManager am = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE);
// ActivityManager.getLockTaskModeState api is not available in pre-M
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) {
if (!am.isInLockTaskMode()) {
startLockTask();
}
} else {
if (am.getLockTaskModeState() == ActivityManager.LOCK_TASK_MODE_NONE) {
startLockTask();
}
}
这就是我停止固定的方式
stopLockTask()