android - 无法使用 Linking.openURL 打开电话
问题描述
描述
无法使用 Linking.openURL('tel:+123456789') 打开电话
环境
环境:操作系统:macOS High Sierra 10.13.4 节点:8.5.0 纱线:未找到 npm:5.8.0 守望者:未找到 Xcode:Xcode 9.3 Build 版本 9E145 Android Studio:2.3 AI-162.4069837
包:(需要 => 已安装)反应:16.3.1 => 16.3.1 react-native:https ://github.com/expo/react-native/archive/sdk-27.0.0.tar.gz => 0.55 .2 世博会:27.0.1,
重现步骤
import ...
export default class App extends React.Component {
_pressCall=()=>{
const url='tel:+123456789'
Linking.openURL(url)
}
render() {
return (
<View style={styles.container}>
<Button title='call' onPress={this._pressCall}/>
</View>
);
}
}
https://snack.expo.io/@kikoololmdrxdd/test-linking-phone-call
预期行为
打开电话
实际行为
[Android]Error message
attempt to invoke virtual method 'boolean java.lang.string.endsWith(java.
lang.String)' on a null object reference
解决方案
我找到了解决方案:您需要将 'tel:' 转换为 'tel://'
推荐阅读
- webdriver - Appium提交网址
- java - 在 Java 中发送带有文件 curl 模拟的 --data-binary
- c# - C# For 循环索引返回 ascii 而不是当前迭代
- javascript - audio.play 不是使用 ref 的箭头函数组件的函数错误
- .net - 在 .NET / .NET Core 中的异步 I/O 期间,线程池的完成端口线程如何表现?
- ionic-framework - 为什么我的图像没有在 Ionic 4 中显示?
- routing - OSPF unnumbered 交换机和虚拟机之间不能 ping
- azure - 如何在 Azure Log Analytics 中每天将日志事件滚动到文件中
- powershell - 将开关传递给计划作业的参数列表
- laravel - npm 运行生产时无法读取未定义 vue 的属性“调用”