我在项目中使用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