flutter - 如何在 url_launcher 中打开 Gmail 应用程序(不创建电子邮件只是打开收件箱)?
问题描述
mailto:<email address>?subject=<subject>&body=<body>
这会创建一封电子邮件。我只想用url_launcher包打开 Gmail 应用程序(收件箱)。可能吗?
解决方案
您需要安装两个插件:android_intent 和 url_launcher 并尝试使用以下代码:
if (Platform.isAndroid) {
AndroidIntent intent = AndroidIntent(
action: 'android.intent.action.MAIN',
category: 'android.intent.category.APP_EMAIL',
);
intent.launch().catchError((e) {
;
});
} else if (Platform.isIOS) {
launch("message://").catchError((e){
;
});
}
推荐阅读
- android - 如何在 ViewHolder 中取消注册 LocalBroadcastManager?
- c++ - 向量大小 (C++)
- java - 将 Twitter 状态拆分为单词
- javascript - 如何为 Select 标签中的每个选项创建 HTML 引导工具提示?
- python - 由于 sys.path 中的嵌套路径,Python 模块两次以 2 个不同的名称添加到 sys.modules?
- python - 正则表达式 <.*?>
- python - 将 NumPy 数组填充到特定大小
- php - Codeigniter,Bootstrap,下拉列表,一个值而不是全部,保存到数据库
- python-3.x - 在python中使用服务器套接字运行后台线程
- c# - 为什么我不能向天蓝色表添加多行?