Android 卸载DevicePolicyManager应用程序
我的应用程序使用DevicePolicyManager。如果我的用户想要卸载应用程序,他们必须执行以下步骤: 设置->位置和安全->设备管理员 取消选择我的应用程序,然后他们就可以卸载它了Android 卸载DevicePolicyManager应用程序,android,uninstallation,device-admin,device-policy-manager,Android,Uninstallation,Device Admin,Device Policy Manager,我的应用程序使用DevicePolicyManager。如果我的用户想要卸载应用程序,他们必须执行以下步骤: 设置->位置和安全->设备管理员 取消选择我的应用程序,然后他们就可以卸载它了 我认为对于游戏商店应用程序来说,这不是一个好的解决方案。我是否可以在代码中为我的用户执行这些步骤,以便他们可以从启动器轻松卸载我的应用程序?是的,您可以。这样做: DevicePolicyManager dpm; ComponentName admin; try
我认为对于游戏商店应用程序来说,这不是一个好的解决方案。我是否可以在代码中为我的用户执行这些步骤,以便他们可以从启动器轻松卸载我的应用程序?是的,您可以。这样做:
DevicePolicyManager dpm;
ComponentName admin;
try
{
dpm = (DevicePolicyManager) getSystemService(Context.DEVICE_POLICY_SERVICE);
admin = new ComponentName(YourActivity.class, AdminReceiverActivity.class);
if(dpm.isAdminActive(admin))
{
dpm.removeActiveAdmin(admin);
}
}
catch(Exception e)
{
e.printStackTrace();
}
finally
{
Intent intent = new Intent(Intent.ACTION_DELETE);
intent.setData(Uri.parse("package:" + this.getPackageName()));
startActivity(intent)
}
是的,你可以。这样做:
DevicePolicyManager dpm;
ComponentName admin;
try
{
dpm = (DevicePolicyManager) getSystemService(Context.DEVICE_POLICY_SERVICE);
admin = new ComponentName(YourActivity.class, AdminReceiverActivity.class);
if(dpm.isAdminActive(admin))
{
dpm.removeActiveAdmin(admin);
}
}
catch(Exception e)
{
e.printStackTrace();
}
finally
{
Intent intent = new Intent(Intent.ACTION_DELETE);
intent.setData(Uri.parse("package:" + this.getPackageName()));
startActivity(intent)
}
旁白:可以从Google Play应用程序中卸载。旁白:可以从Google Play应用程序中卸载。