此coud for mack icon call with INKWILL
_Call() async {
const _url = 'tel:01140654053' ;
if (await canLaunch(_url)) {
await launch(_url);
} else {
throw 'could not lanch ';
}
}
这个错误
E/flutter ( 8522): [ERROR:flutter/lib/ui/ui_dart_state.cc(199)] Unhandled Exception: could not lanch
E/flutter ( 8522): #0 _MyHomePageState._Call (package:oonco_helpp/main.dart:105:7)
E/flutter ( 8522): <asynchronous suspension>
E/flutter ( 8522):
Android 11在与其他应用程序交互时引入了更严格的安全性,即包可见性概念。这就是为什么canLaunch
在Android 11(API 30(上总是返回false,而launchUrl
在使用url_launcher包时将失败的原因。
从这个博客中,他们介绍了一个解决方案:
这可以通过配置您的应用程序来修复具有
android.intent.action.VIEW
意向筛选器的应用程序使用CCD_ 5中的CCD_。为了使
<queries>
元素正常工作,建议您升级您的Android Gradle插件(AGP(版本4.1。在您的项目级别渐变文件android/build.gradle
,如下所示:buildscript { repositories { google() jcenter() } dependencies { // Using gradle plugin version 4.1.1 classpath 'com.android.tools.build:gradle:4.1.1' } }
早期版本的Android还有其他dot版本渐变插件。从中了解更多信息在这里
升级gradle插件并构建应用程序后,添加以下内容元素块到您的
AndroidManifest.xml
:<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.sample"> <uses-permission android:name="android.permission.INTERNET"/> <!-- Add the block below to your manifest file to configure apps with action.VIEW intent filters as visible to your app --> <!-- START HERE --> <queries> <intent> <action android:name="android.intent.action.VIEW" /> <category android:name="android.intent.category.BROWSABLE" /> <data android:scheme="https" /> </intent> </queries> <!-- END HERE --> <application> ... </application> </manifest>
完成此操作后,重建应用程序,
canLaunch
应返回true
CCD_ 11也应该在Android 11(API 30(上打开url。