How do I know if it's Device owner mode?

Asked 2 years ago, Updated 2 years ago, 32 views

Is there a way for the application to know if the terminal is operating in Device owner mode?

android

2022-09-30 16:32

1 Answers

Hello
By implementing the sample code below in the application, you can determine whether the application is a device downer or not.
Create an instance of DevicePolicyManager and use the isDeviceOwnerApp function
Determine if it is the device owner.
Below is the sample code.

//import android.app.admin.DevicePolicyManager;
// import android.widget.Toast;

DevicePolicyManager=(DevicePolicyManager) getSystemService(Context.DEVICE_POLICY_SERVICE);

if(!manager.isDeviceOwnerApp(getApplicationContext().getPackageName())))
{
    Toast.makeText(MainActivity.this, "device owner is not configured", Toast.LENGTH_LONG).show();

}


2022-09-30 16:32

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.