如何以编程方式在Flutter中卸载应用程序? [英] How to uninstall an app in flutter programatically?

查看:434
本文介绍了如何以编程方式在Flutter中卸载应用程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个启动器应用程序。但是我无法添加卸载功能。请帮我。

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

推荐答案

清单文件

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

在您的 pubspec.yaml 中添加一个包文件

add a package in your pubspec.yaml file

intent: ^1.3.4

使用以下显示的代码,并

Use the below shown code and

要卸载应用,请向其传递软件包名称。 $ packageName 是变量
ex, some.app.id

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.

因此,使用此工具,您可以以编程方式使用flutter卸载Android设备上的应用。

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

这篇关于如何以编程方式在Flutter中卸载应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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