How to check if an action (application attachment) is locked in android Lollipop

I would like to know if activity will be blocked when attaching an application in android 5.0 and higher programmatically. Please help me with this!

Thanks!

+7
android-activity android-5.0-lollipop task android-screen-pinning
source share
1 answer

The method of obtaining if the activity is in the task lock mode.
The activityManager.isInLockTaskMode () API is deprecated at API level 23. Use the activityManager.getLockTaskModeState () method 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; } 

Hope this helps you!

+18
source share

All Articles