How to implement single application mode (COSU) in Android?

cjd picture cjd · Jun 29, 2017 · Viewed 8.5k times · Source

Looking for solution to integrate COSU mode in Android.I have already gone through below links,

https://developer.android.com/work/cosu.html

Has anyone implemented it successfully?

Answer

Andrii Omelchenko picture Andrii Omelchenko · Aug 1, 2017

Take a look at this tutorial and that repository with example.

...
if (mDevicePolicyManager.isLockTaskPermitted(
        getApplicationContext().getPackageName())) {
    Intent lockIntent = new Intent(getApplicationContext(),
            LockedActivity.class);
    lockIntent.putExtra(EXTRA_FILEPATH, mCurrentPhotoPath);
    startActivity(lockIntent);
    finish();
} else {
    Toast.makeText(getApplicationContext(),
            R.string.not_lock_whitelisted,Toast.LENGTH_SHORT)
            .show();
}
...