Gintas_
Gintas_

Reputation: 5030

How to disable status bar using Device Owner?

I'm trying to completely disable the status bar and had a solution which draws a black box on top of the status bar, however, requires the app to be a system app (which is fine). Recently I was shown a video in which disabling of the status bar was made by utilizing device owner sdk methods. I'm not able to find them using a quick google research. What are they?

Example video: http://static.lostpolygon.com/temp/uploads/mToCEZ2HRU.mp4

Upvotes: 1

Views: 1391

Answers (1)

JensV
JensV

Reputation: 4544

I'm pretty sure it's utilizing the "Lock Task Mode" (or KNOX Kiosk mode).

To utilize the "Lock Task Mode" you first need to give rights to the app that will use it. Then the app can start an activity in this mode.

Requirements

You must be the device owner application.

Whitelisting the app

To whitelist your app utilize the following code from the device owner application:

Context context = getContext();
DevicePolicyManager dpm =
    (DevicePolicyManager) context.getSystemService(Context.DEVICE_POLICY_SERVICE);
ComponentName adminName = getComponentName(context);
dpm.setLockTaskPackages(adminName, APP_PACKAGES);

Start lock task mode

// Set an option to turn on lock task mode when starting the activity.
ActivityOptions options = ActivityOptions.makeBasic();
options.setLockTaskEnabled(true);

// Start our kiosk app's main activity with our lock task mode option.
PackageManager packageManager = context.getPackageManager();
Intent launchIntent = packageManager.getLaunchIntentForPackage(KIOSK_PACKAGE);
if (launchIntent != null) {
  context.startActivity(launchIntent, options.toBundle());
}

I urge you to read the full documentation for lock task mode and it's different options:

Upvotes: 1

Related Questions