【问题标题】:How to open device setting form flutter app?如何打开设备设置表单颤振应用程序?
【发布时间】:2020-07-04 03:21:18
【问题描述】:

我想在用户点击按钮时打开设置。

我可以看到为设置 here 定义的意图 Settings.ACTION_SETTINGS

我正在使用包Android_intent

代码:

AndroidIntent intent = AndroidIntent(
   action: 'Settings.ACTION_SETTINGS',
 );
await intent.launch();

但是,我得到了错误:-

E/flutter (14266): [ERROR:flutter/lib/ui/ui_dart_state.cc(157)] Unhandled Exception: PlatformException(error, No Activity found to handle Intent { act=Settings.ACTION_SETTINGS (has extras) }, null)

如何打开设置页面表单flutter?

【问题讨论】:

    标签: android flutter android-intent settings


    【解决方案1】:

    我使用了错误的设置意图, 以下正在工作 代码:-

    AndroidIntent intent = AndroidIntent(
      action: 'android.settings.SETTINGS',
    );
    await intent.launch();
    

    【讨论】:

      【解决方案2】:

      我经常用这个插件

      app_settings: 3.0.1

      然后导入

      import 'package:app_settings/app_settings.dart';

      然后我用

      onPressed() {
        AppSettings.openDataRoamingSettings(); //or whatever settings you want to open xD
      }
      

      告诉它是否有效:)

      【讨论】:

        【解决方案3】:

        您也可以使用 app_settings

        onPressed: () {
                  AppSettings.openDeviceSettings(
                    asAnotherTask: true,
                  );
                },
        

        应该适用于 Android 和 iOS。

        阅读更多:https://pub.dev/packages/app_settings

        【讨论】:

          猜你喜欢
          • 2020-07-04
          • 2019-05-15
          • 1970-01-01
          • 1970-01-01
          • 2019-01-19
          • 2019-11-25
          • 1970-01-01
          • 1970-01-01
          • 2017-11-26
          相关资源
          最近更新 更多