Reputation: 235
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!
Thanks!
Upvotes: 12
Views: 5688
Reputation: 722
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;
}
Hope this helps you!
Upvotes: 32