我正在开发SIP应用程序。我使用了SipDemo中的sipdemo样本,但有问题。我得到了nullpointerexception=>“尝试关闭管理器时出错。”在这里(异常“e”):
public void initiateCall() {
updateStatus(sipAddress);
try {
SipAudioCall.Listener listener = new SipAudioCall.Listener() {
@Override
public void onCallEstablished(SipAudioCall call) {
call.startAudio();
call.setSpeakerMode(true);
call.toggleMute();
updateStatus(call);
}
@Override
public void onCallEnded(SipAudioCall call) {
updateStatus("Ready.");
}
};
call = manager.makeAudioCall(me.getUriString(), sipAddress, listener, 30);
}
catch (Exception e) {
Log.i("WalkieTalkieActivity/InitiateCall", "Error when trying to close manager.", e);
if (me != null) {
try {
manager.close(me.getUriString());
} catch (Exception ee) {
Log.i("WalkieTalkieActivity/InitiateCall",
"Error when trying to close manager.", ee);
ee.printStackTrace();
}
}
if (call != null) {
call.close();
}
}
}
另外,我检查了这个
SipManager.isApiSupported()
和SipManager.isVoipSupported()
都返回了false。我在tab上用4.0.3操作系统测试这个。我想知道问题是否出在不支持本机SIP上,但我可以很容易地用SIPDroid或其他来自Market的应用程序打电话。编辑
日志堆栈跟踪:
05-15 22:29:11.255: INFO/WalkieTalkieActivity/InitiateCall(4247): Error when trying to close manager.
05-15 22:29:11.255: INFO/WalkieTalkieActivity/InitiateCall(4247): java.lang.NullPointerException
05-15 22:29:11.255: INFO/WalkieTalkieActivity/InitiateCall(4247): at com.example.android.sip.WalkieTalkieActivity.initiateCall(WalkieTalkieActivity.java:212)
05-15 22:29:11.255: INFO/WalkieTalkieActivity/InitiateCall(4247): at com.example.android.sip.WalkieTalkieActivity$4.onClick(WalkieTalkieActivity.java:324)
05-15 22:29:11.255: INFO/WalkieTalkieActivity/InitiateCall(4247): at com.android.internal.app.AlertController$ButtonHandler.handleMessage(AlertController.java:165)
05-15 22:29:11.255: INFO/WalkieTalkieActivity/InitiateCall(4247): at android.os.Handler.dispatchMessage(Handler.java:99)
05-15 22:29:11.255: INFO/WalkieTalkieActivity/InitiateCall(4247): at android.os.Looper.loop(Looper.java:130)
05-15 22:29:11.255: INFO/WalkieTalkieActivity/InitiateCall(4247): at android.app.ActivityThread.main(ActivityThread.java:3691)
05-15 22:29:11.255: INFO/WalkieTalkieActivity/InitiateCall(4247): at java.lang.reflect.Method.invokeNative(Native Method)
05-15 22:29:11.255: INFO/WalkieTalkieActivity/InitiateCall(4247): at java.lang.reflect.Method.invoke(Method.java:507)
05-15 22:29:11.255: INFO/WalkieTalkieActivity/InitiateCall(4247): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:907)
05-15 22:29:11.255: INFO/WalkieTalkieActivity/InitiateCall(4247): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:665)
05-15 22:29:11.255: INFO/WalkieTalkieActivity/InitiateCall(4247): at dalvik.system.NativeStart.main(Native Method)
最佳答案
我想我有办法了。并非每个版本的android都支持sip。因此,您应该查找第三部分库。例如,您可以查看Sipdroid或CSipSimple的源代码并根据自己的需要进行转换。