6
我是创建应用程序,它使my device as a admin
工作伟大。如何知道我的应用程序管理员是否
但我想触发一些消息当我Application uninstall from device.
当用户
remove from admin
。如何知道我的
app Device admin is checked or not?
我使用的Android内置的管理应用程序的演示。
请给我一些想法。
我是创建应用程序,它使my device as a admin
工作伟大。如何知道我的应用程序管理员是否
但我想触发一些消息当我Application uninstall from device.
当用户remove from admin
。
如何知道我的app Device admin is checked or not?
我使用的Android内置的管理应用程序的演示。
请给我一些想法。
你将不得不延长DeviceAdminReceiver和
public class DeviceAdmin extends DeviceAdminReceiver {
@Override
public void onEnabled(Context context, Intent intent) {
Log.i(this, "admin_receiver_status_enabled");
// admin rights
App.getPreferences().edit().putBoolean(App.ADMIN_ENABLED, true).commit(); //App.getPreferences() returns the sharedPreferences
}
@Override
public CharSequence onDisableRequested(Context context, Intent intent) {
return "admin_receiver_status_disable_warning";
}
@Override
public void onDisabled(Context context, Intent intent) {
Log.info(this, "admin_receiver_status_disabled");
// admin rights removed
App.getPreferences().edit().putBoolean(App.ADMIN_ENABLED, false).commit(); //App.getPreferences() returns the sharedPreferences
}
}
在您的应用程序的任何地方:
DevicePolicyManager mDPM = (DevicePolicyManager)getSystemService(Context.DEVICE_POLICY_SERVICE);
ComponentName mAdminName = new ComponentName(this, DeviceAdmin.class);
if(mDPM != null &&mDPM.isAdminActive(mAdminName)) {
// admin active
}
我用这way.but时如何知道我的后台管理应用为disable。 – Harshid
即使您的应用程序处于后台或根本没有运行,onDisabled也会被调用。你可以将状态保存在sharedPreferences – malimo
嘿@malimo当我的应用程序不处于运行状态时,如何知道我的设备管理员。 – Harshid