Android   发布时间:2022-04-28  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了android – 如何知道我的应用程序是否管理员大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我是创作应用程序,使我的设备作为管理员工作伟大.

但是当我的应用程序从设备上卸载时,我想触发一些消息.

>当用户管理员删除
>如何知道我的应用程序设备管理员是否被选中?

我正在使用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
}

大佬总结

以上是大佬教程为你收集整理的android – 如何知道我的应用程序是否管理员全部内容,希望文章能够帮你解决android – 如何知道我的应用程序是否管理员所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。