是否有意向为所有用户的应用程序的卸载? [英] Is there an intent for uninstallation of an app for ALL users?

查看:358
本文介绍了是否有意向为所有用户的应用程序的卸载?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

背景

正常的方式来呼吁卸载的应用程序仅仅是使用的 ACTION_DELETE 意向:

  startActivity(新意图(Intent.ACTION_DELETE,Uri.parse(套餐+的packageName)));
 

问题

开始与一些Android版本(不记得),应用程序可以安装在同一台设备上的多个用户。

这意味着有一个新的方法来卸载应用程序,其中一个将卸载它为所有用户(图片取自棒棒堂 - 安卓5.0):

问题

我搜索的文档中,也没有找到答案的问题:

  1. 有没有办法通过一个意图来执行此操作?也许东西添加到我写上面的意图是什么?

  2. 亚行是否有一个新的命令来删除所有用户的应用程序?

  3. 有没有一种方法来检查,如果一个应用程序被安装为多个用户?

解决方案
  

有没有办法通过一个意图来执行此操作?有可能   东西添加到我写上面的意图是什么?

是的,但要小心。你可以通过在<一个href="https://github.com/android/platform_frameworks_base/blob/master/core/java/android/content/Intent.java#L1432"相对=nofollow> Intent.EXTRA_UNINSTALL_ALL_USERS

然而,它是隐藏的,因为它:

  

不应该是正常的应用程序流的一部分

您可以只通过在不断无论如何,如果你觉得有必要,并与谷歌的,一个不同意。只是举例,这里顺便之间的差异与恒

 最后乌里packageURI = Uri.parse(套餐+some.package.name);
    最终意图uninstallIntent =新的意图(Intent.ACTION_UNINSTALL_PACKAGE,packageURI);
    uninstallIntent.putExtra(android.intent.extra.UNINSTALL_ALL_USERS,或真或假);
    startActivity(uninstallIntent);
 

结果

  

亚行是否有一个新的命令来删除所有用户的应用程序?

没有,该命令是一样的。

 `亚行卸载'some.package.name'`
 

这将删除该应用程序的所有用户。我不知道一个方法来指定一个特定的用户。

  

有没有一种方法来检查,如果一个应用程序被安装为多个用户?

没有,不是我所知道的。事实上,当设置程序决定将<一href="https://github.com/android/platform_packages_apps_settings/blob/master/src/com/android/settings/applications/InstalledAppDetails.java#L518"相对=nofollow>卸载所有用户,在选项菜单选项,它基本上这样按照是否有多个用户时间,如果没有当前用户和其他用户双方都安装一个应用程序。

更何况,大部分在 的UserManager ,你会需要,即使知道,如果有设备,像的 UserManager.getUserCount ,需要<一href="https://github.com/android/platform_frameworks_base/blob/master/core/res/AndroidManifest.xml#L1438"相对=nofollow> MANAGE_USERS 这是一个系统的API和隐藏的权限。所以,我也不知道为什么,这是一个公共方法。

此外,您还可以轻松地测试您的所有问题,就像我一样,通过创建在设备上的虚拟用户。你甚至都不需要登录到一个谷歌帐户。

Background

The normal way to call for the uninstallation an app is simply by using the "ACTION_DELETE" intent :

startActivity(new Intent(Intent.ACTION_DELETE, Uri.parse("package:" +packageName)));

The problem

starting with some Android version (don't remember which) , apps can be installed for multiple users on the same device.

This means there is a new way to uninstall an app, one which will uninstall it for all users (image taken from Lollipop - Android 5.0 ) :

The question

I've searched in the documentation, but couldn't find the answer those questions:

  1. Is there any way to perform this operation via an intent? Maybe something to add to the intent I've written above ?

  2. Does ADB have a new command to remove an app for all users?

  3. Is there a way to check if an app is installed for multiple users?

解决方案

Is there any way to perform this operation via an intent? Maybe something to add to the intent I've written above ?

Yes, but be careful. You can pass in Intent.EXTRA_UNINSTALL_ALL_USERS.

However, it's hidden because it:

should not be part of normal application flow

You could just pass in the constant anyway, if you feel it's necessary and disagree with Google on that one. Just for example, here are the differences between passing in false and true with that constant

    final Uri packageURI = Uri.parse("package:" + "some.package.name");
    final Intent uninstallIntent = new Intent(Intent.ACTION_UNINSTALL_PACKAGE, packageURI);
    uninstallIntent.putExtra("android.intent.extra.UNINSTALL_ALL_USERS", false or true);
    startActivity(uninstallIntent);

Results

Does ADB have a new command to remove an app for all users?

No, the command remains the same.

`adb uninstall 'some.package.name'` 

This will remove that app for all users. I'm unaware of a way to specify a particular user.

Is there a way to check if an app is installed for multiple users?

No, not that I'm aware of. In fact, when the Settings apps decides to place the "Uninstall for all users" option in the options menu, it's basically doing so based on whether or not there are multiple users period, not if both the current user and another user have an app installed.

Not to mention, most of the methods in UserManager that you'd need to even tell if there are multiple users on the device, like UserManager.getUserCount, require the MANAGE_USERS permission which is a system API and hidden. So, I'm not even sure why that's a public method.

Also, you can easily test all of your questions, much like I did, by creating a dummy user on your device. You don't even need to log into a Google account.

这篇关于是否有意向为所有用户的应用程序的卸载?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆