How to uninstall an app in flutter programatically?

限于喜欢 提交于 2020-06-27 10:09:22

问题


I am building a launcher app in flutter. But I couldn't add the uninstall feature. Please help me.


回答1:


Add a permission in manifest file

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

add a package in your pubspec.yaml file

intent: ^1.3.4

Use the below shown code and

To uninstall an app pass the package name to it. $packageName is a variable ex, some.app.id

android_intent.Intent()
  ..setAction(android_action.Action.ACTION_DELETE)
  ..setData(Uri.parse("package:$packageName"))
  ..startActivityForResult().then((data) {
    print(data);
  }, onError: (e) {
    print(e);
  });

using this a system generated popup will occur asking to uninstall the app.

So using this you can uninstall apps on your android device using flutter programmatically.



来源:https://stackoverflow.com/questions/55163793/how-to-uninstall-an-app-in-flutter-programatically

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!