我目前已经为我的 flutter 应用程序编写了代码,其中图标需要重定向到 google chrome,但我的模拟器无法打开 chrome。这可能是问题吗?
期望重定向到从应用程序到外部应用程序的网络链接。 请给我这方面的建议,我真的需要帮助。
如果您的 Flutter 应用程序使用 url_launcher 包重定向到 Google Chrome,但模拟器未按预期打开 Chrome,则可能有多种原因导致此行为。以下是解决该问题的一些建议: 检查控制台中的错误: 在物理设备上测试: 检查模拟器网络连接: 查看 AndroidManifest.xml 配置
添加权限
<uses-permission android:name="android.permission.INTERNET" />
将传递给 canLaunchUrl 的任何 URL 方案添加为 AndroidManifest.xml 中的条目,否则从 Android 11 (API 30) 或更高版本开始,大多数情况下它将返回 false。检查 supportLaunchMode(LaunchMode.inAppBrowserView) 还需要一个条目返回除 false 之外的任何内容。必须将元素作为根元素的子元素添加到清单中。
<queries>
<!-- If your app checks for SMS support -->
<intent>
<action android:name="android.intent.action.VIEW" />
<data android:scheme="sms" />
</intent>
<!-- If your app checks for call support -->
<intent>
<action android:name="android.intent.action.VIEW" />
<data android:scheme="tel" />
</intent>
<!-- If your application checks for inAppBrowserView launch mode support -->
<intent>
<action android:name="android.support.customtabs.action.CustomTabsService" />
</intent>
</queries>