【问题标题】:How to handle incoming intents from external applications in Flutter如何在 Flutter 中处理来自外部应用程序的传入意图
【发布时间】:2019-10-08 12:04:08
【问题描述】:

有些服务在 Android 和 iPhone 之间有所不同,例如浮动小部件,主屏幕上的小部件,我可以使用 Flutter 制作它们吗

我可以像这个例子一样在主屏幕上查看对话框吗?

更新 谢谢大家的回答,但我需要如何在 Flutter 中得到它

【问题讨论】:

  • 尝试使用透明活动:stackoverflow.com/questions/2176922/…
  • 对不起,你不能在 Flutter 中做,因为在 Flutter 中做意味着为两个平台做,因为 iOS 不支持,你根本不能单独使用 Flutter,你会必须在本地使用方法通道。
  • 我希望这仅适用于 Android,我使用 Platform.isAndroid
  • Android 和 iPhone 的某些服务有所不同,例如浮动小部件、主屏幕上的小部件,我可以使用 Flutter 制作它们吗

标签: android flutter


【解决方案1】:

是的,你可以证明这一点

 new AlertDialog.Builder(YourActivity.this)
                                .setTitle("Alert")
                                .setMessage("Alert Message")
                                .setCancelable(false)
                                .setPositiveButton("OK", new DialogInterface.OnClickListener() {
                                    @Override
                                    public void onClick(DialogInterface dialog, int which) {
                                        //Here you can do whatever you want to do on click 
                                    }
                                }).show();

【讨论】:

    【解决方案2】:

    抱歉,您在 iOS 中无法做到这一点,但在 Android 中,您可以,您只需编写特定于平台的代码即可。

    您可以使用Theme.Dialog 主题创建Activity。在您的 AndroidManifest.xml 文件中将主题添加到活动中,如下所示:

    <activity android:name=".DialogActivity" android:theme="@android:style/Theme.Dialog"></activity>
    

    从您的服务只需启动此Activity。您必须使用 Intent.FLAG_ACTIVITY_NEW_TASK 标志开始活动。见How to start an Activity from a Service

    Source

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-03-26
      • 1970-01-01
      • 1970-01-01
      • 2018-02-13
      • 2020-06-20
      • 1970-01-01
      相关资源
      最近更新 更多