是否可以将Flutter应用注册为Android意图过滤器并处理传入意图? [英] Is it possible to register a Flutter app as an Android Intent Filter and to handle Incoming Intents?

查看:57
本文介绍了是否可以将Flutter应用注册为Android意图过滤器并处理传入意图?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

一个人可以使用Flutter应用中的Intent启动另一个活动:
https://github.com/flutter/flutter/blob/master/examples/widgets/launch_url.dart

One can launch another Activity using an Intent from a Flutter app: https://github.com/flutter/flutter/blob/master/examples/widgets/launch_url.dart

import 'package:flutter/widgets.dart';
import 'package:flutter/services.dart';

void main() {
  runApp(new GestureDetector(
    onTap: () {
      Intent intent = new Intent()
        ..action = 'android.intent.action.VIEW'
        ..url = 'http://flutter.io/';
      activity.startActivity(intent);
    },
    child: new Container(
      decoration: const BoxDecoration(
        backgroundColor: const Color(0xFF006600)
      ),
      child: new Center(
        child: new Text('Tap to launch a URL!')
      )
    )
  ));
}

但是,当Intent为时,可以使用Flutter Activity Intent服务执行以下操作传递给应用程序?
http://developer.android.com/training/sharing/receive.html

But can one do the following with the Flutter Activity Intent services when an Intent is passed to the app? http://developer.android.com/training/sharing/receive.html

. . .
void onCreate (Bundle savedInstanceState) {
    ...
    // Get intent, action and MIME type
    Intent intent = getIntent();
. . .


推荐答案

据我所知,没有办法处理传入的目前来自Dart代码的意图。具体来说, https://github.com/flutter/flutter/跟踪处理传入URL的情况。 issues / 357

To my knowledge, there is no way to handle incoming Intents from Dart code at this time. Specifically the case of handling incoming URLs is tracked by https://github.com/flutter/flutter/issues/357.

还可以使用 https://flutter.io/platform-services/

更新2020 -从Flutter Doc接受Flutter中的传入意图

这篇关于是否可以将Flutter应用注册为Android意图过滤器并处理传入意图?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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