可以使用Flutter应用程序中的Intent启动另一个Activity: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!')
)
)
));
}
Run Code Online (Sandbox Code Playgroud)
但是当Intent传递给应用程序时,可以使用Flutter Activity Intent服务执行以下操作吗? http://developer.android.com/training/sharing/receive.html
. . .
void onCreate (Bundle savedInstanceState) {
...
// Get intent, action and MIME type
Intent intent = getIntent();
. . .
Run Code Online (Sandbox Code Playgroud) 我需要将我的 Flutter 应用程序与文件类型关联起来.foo。例如,如果用户打开本地文件管理器,然后单击文件,bar.fooandroid 会提示他们使用我的 flutter 应用程序打开该文件。
到目前为止,我了解到,这基本上是一个传入的 Android 意图,必须使用所谓的intent-filter此处所述进行注册:创建打开自定义文件扩展名的应用程序。但更进一步,我不明白如何在 Kotlin 中处理它。
因此,下一个合乎逻辑的事情是找出传入意图在 Flutter 中如何工作。然而,该文档对我没有帮助,因为它仅以Java 而非 Kotlin进行解释进行解释。我完全没有 Java 经验,但无论如何我还是想坚持使用 Kotlin,因为我还有用 Kotlin 编写的其他平台特定代码。
在这篇文章中,Deep Shah似乎也有同样的问题,但没有分享解决方案: Support custom file extension in a flutter app (Open file with extension .abc in flutter)。
Shanks的这篇文章悄然消亡:用 Flutter App 打开自定义文件扩展名。
我希望找到答案或指向相关资源的指示。