简体   繁体   English

以编程方式卸载应用程序 Android 10

[英]Uninstall application programmatically Android 10

I am developing an application which will uninstall itself after a button click.我正在开发一个应用程序,它会在单击按钮后自行卸载。 The following code works for the uninstallation of application running in Android.以下代码适用于卸载在 Android 中运行的应用程序。

Uri uri = Uri.fromParts("package", getClass().getPackage().getName(), null);
Intent uninst_intent = new Intent(Intent.ACTION_DELETE, uri);
startActivityForResult(uninst_intent, EXIT_REQUEST);

But this is not working for the new versions of android such as Android 9 and 10. This Action intent is not deprecated in the newer APIs.但这不适用于 Android 9 和 10 等新版本的 android。此 Action Intent 在较新的 API 中并未弃用。 What am i missing here?我在这里缺少什么?

There is permission missing in Manifest please add this permission in manifest...清单中缺少权限,请在清单中添加此权限...

 <uses-permission android:name="android.permission.REQUEST_DELETE_PACKAGES"></uses-permission>

this will work...!!!这将工作......!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM