谁能告诉我如何在 flutter 中从 dart 文件调用 android Activity 。 谢谢。
代码:
class FlutterScreen extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Screen'),
),
body: Center(
child: RaisedButton(
child: Text('Android'),
onPressed: () {
// Navigate to Android activity screen when tapped!
},
),
),
);
}
}
最佳答案
我认为您正在寻找的是 android_intent library .
有了它,很容易触发一个 Intent 。尽管不支持 iOS,但您必须确保不会以相同的方式在 iOS 上使用它。
android_intent 自述文件中的示例代码:
if (platform.isAndroid) {
AndroidIntent intent = new AndroidIntent(
action: 'action_view',
data: 'https://play.google.com/store/apps/details?'
'id=com.google.android.apps.myapp',
arguments: {'authAccount': currentUserEmail},
);
await intent.launch();
}
关于android - 如何在 flutter 中从 dart 文件调用 android Activity ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53718860/