如何自我卸载的应用程序?应用程序、自我

2023-09-06 09:09:14 作者:朕の愛妃

问题是这样的 - 我的应用程序获取管理员权限,让他们从UI POV是很容易的。然而,一旦应用程序有这些权利,这是麻烦的将其卸载(用户必须首先撤销这些管理权限;如果没有,卸载时,有没有什么信息与卸载怎么了 - 至少在一点2的Andr​​oid 2.3)。

The problem is this -- my app gets admin rights, to get them, from UI POV is quite easy. However once app has those rights, it is cumbersome to uninstall it (user has to first revoke those admin rights; and if not, when uninstalling there is no info what is going wrong with uninstall -- at least at Ace 2 Android 2.3).

因此​​这将是有益的,以在应用程序中的卸载功能 - 它会撤销管理权限,然后再按照正常卸载

Thus it would be useful, to have a uninstall feature in app -- it would revoke admin rights first, and then follow normal uninstall.

另一种方法是将通知应用程序是要卸载的程序,但AFAIK是不可能的 - 见:http://$c$c.google.com/p/android/issues/detail?can=2&q=33315&colspec=ID%20Type%20Status%20Owner%20Summary%20Stars&id=33315

Another approach would be to be notified app is about to be uninstalled, however AFAIK it is not possible -- see: http://code.google.com/p/android/issues/detail?can=2&q=33315&colspec=ID%20Type%20Status%20Owner%20Summary%20Stars&id=33315

到目前为止,我想出了只与解决方法 - 保存用户的问题添加一个按钮明确的卸载,状态信息,如果应用程序已准备好进行卸载。但用户必须卸载我的应用程序的另一个步骤。麻烦呢。

So far I came up only with workaround -- to save user a problem add a button "clear for uninstall" with status info if app is ready to be uninstalled. But then user has to make another step of uninstalling my app. Troublesome anyway.

所以 - 如何卸载自我?

So -- how to uninstall self?

就在为了保持code对SO网站:

Just in sake to keep the code on SO site:

Uri packageURI = Uri.parse("package:"+MyMainActivity.class.getPackage().getName());
Intent uninstallIntent = new Intent(Intent.ACTION_DELETE, packageURI);
startActivity(uninstallIntent);

在code从的Andr​​oid故事博客复制。

推荐答案

就这些夫妇的问题,一起来看看(它们都涉及到安装/卸载)

Take a look on these couple of questions (they are related to installation/uninstallation)

隐性意图卸载应用程序?

install /卸载的APK编程(PackageManager VS意图)