Java Code Examples for android.app.activitymanager#isInLockTaskMode()
The following examples show how to use
android.app.activitymanager#isInLockTaskMode() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: KioskModeActivity.java From android-testdpc with Apache License 2.0 | 6 votes |
@Override protected void onStart() { super.onStart(); // 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 (Util.SDK_INT < VERSION_CODES.M) { if (!am.isInLockTaskMode()) { startLockTask(); } } else { if (am.getLockTaskModeState() == ActivityManager.LOCK_TASK_MODE_NONE) { startLockTask(); } } }
Example 2
Source File: PolicyManagementFragment.java From android-testdpc with Apache License 2.0 | 6 votes |
@TargetApi(VERSION_CODES.P) private void relaunchInLockTaskMode() { ActivityManager activityManager = getContext().getSystemService(ActivityManager.class); final Intent intent = new Intent(getActivity(), getActivity().getClass()); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); // Ensure a new task is actually created if not already running in lock task mode if (!activityManager.isInLockTaskMode()){ intent.addFlags(Intent.FLAG_ACTIVITY_MULTIPLE_TASK); } final ActivityOptions options = ActivityOptions.makeBasic(); options.setLockTaskEnabled(true); try { startActivity(intent, options.toBundle()); getActivity().finish(); } catch (SecurityException e) { showToast("You must first whitelist the TestDPC package for LockTask"); } }