如何检查Android Lollipop中的活动是否已锁定(应用固定) [英] How to check if an activity is locked (app pinning) in android Lollipop
本文介绍了如何检查Android Lollipop中的活动是否已锁定(应用固定)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想知道某个活动是否在Android 5.0及更高版本中的应用固定下被锁定了.请帮助我!
I would like to know whether an activity is locked under app pinning in android 5.0 and above programatically. Please help me in this!
谢谢!
推荐答案
获取活动是否处于锁定任务模式的方法.
在API级别23中,不推荐使用activityManager.isInLockTaskMode()API.使用方法activityManager.getLockTaskModeState()
http://developer.android.com/reference/android/app/ActivityManager.html#getLockTaskModeState()
Method to get if the activity in lock task mode.
activityManager.isInLockTaskMode() API is deprecated in API level 23. Use the method activityManager.getLockTaskModeState()
http://developer.android.com/reference/android/app/ActivityManager.html#getLockTaskModeState()
public boolean isAppInLockTaskMode() {
ActivityManager activityManager;
activityManager = (ActivityManager)
this.getSystemService(Context.ACTIVITY_SERVICE);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
// For SDK version 23 and above.
return activityManager.getLockTaskModeState()
!= ActivityManager.LOCK_TASK_MODE_NONE;
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
// When SDK version >= 21. This API is deprecated in 23.
return activityManager.isInLockTaskMode();
}
return false;
}
希望这对您有所帮助!
这篇关于如何检查Android Lollipop中的活动是否已锁定(应用固定)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文