android sip 开发中SipManager.newInstance()return null 解决方法

在将使用Google Sip电话API的项目从普通手机迁移到香蕉派时,遇到SipManager.newInstance()返回null的错误。问题并非权限或系统版本导致,而是由于/android.software.sip.voip.xml文件缺失。解决方案是将该文件复制到香蕉派的/system/etc/permissions目录下,需要设备root权限。分析源码中的isApiSupported方法有助于理解问题根本。
摘要由CSDN通过智能技术生成

我在项目中使用google原生的sip电话api开发网络电话的过程中,在一般手机上没有问题,当我把项目迁移到香蕉派上去测试的时候发现sipmanager.newInstance()一直返回null。

折腾了半天发现并不是权限的问题,也不是系统版本的问题。

问题出在android.software.sip.voip.xml这个文件上。

文件内容:

<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2009 The Android Open Source Project


     Licensed under the Apache License, Version 2.0 (the "License");
     you may not use this file except in compliance with the License.
     You may obtain a copy of the License at


          http://www.apache.org/licenses/LICENSE-2.0


     Unless required by applicable law or agreed to in writing, software
     distributed under the License is distributed on an "AS IS" BASIS,
     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     See the License for the specific language governing permissions and
     limitations under the License.
-->


<!-- This is the standard set of features for devices that support SIP-based VoIP. -->
<permissions>
    <feature name="android.software.sip" />
    <feature name="android.software.sip.voip" />
</permissions>

在香蕉派的系统中的/system/etc/permissions文件夹下并没有这个文件

解决方法:将这个文件copy到此目录中去(需要设备root)



分析原因:

我们看看SipManager.newInstance()方法

public static SipManager newInstance(Context context) {
    return (isApiSupported(context) ? new SipManager(context) : null);
}
首先会调用isApiSupported()方法判断设备是否支持s
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 4
    评论
sip.instance是一个SIP协议的属性,用于标识一个用户的实例。在引用的示例sip.instance的值是"<urn:uuid:00000000-0000-0000-0000-000041d7c640>"。这个值是由一个UUID(Universally Unique Identifier,通用唯一识别码)生成的,用于唯一标识一个用户实例。在SIP通信,这个属性可以用于识别和跟踪特定的用户实例。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* [IMS/SIP学习(4)——subscribe、notify、invite过程](https://blog.csdn.net/hitguolu/article/details/108767395)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 33.333333333333336%"] - *2* [sip-4.15.5.zip](https://download.csdn.net/download/u012510614/7351097)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 33.333333333333336%"] - *3* [sip注册协议格式](https://blog.csdn.net/maintyb011/article/details/103492423)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 33.333333333333336%"] [ .reference_list ]
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值