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

3

9

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?

Pozsony answered 29/6, 2017 at 15:2 Comment(1)
If this helps in any way, I did it by disabling the back press and volume keys and pinning the app since my app had only single screen. Other attempts went futile for me.Tilth
H
5

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();
}
...
Heehaw answered 1/8, 2017 at 17:16 Comment(0)
R
3

You might want to try Google's new Android Management API, it allows to manage COSU devices without having to build an on-device agent (a device policy controller).

Rapport answered 5/8, 2017 at 12:22 Comment(0)
L
1

I decided neither way was very good. I used device policy ownership to prevent installing any other apps, wrote a launcher app (so we were the homescreen), made it a system app and used the statusbar manager apis (which aren't well known) to remove the recents button and prevent the status bar from being opened so there was no way to launch any app but mine.

Lasko answered 1/8, 2017 at 15:53 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.