我正在开发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 。我正在使用4.0.3操作系统的Tab上测试它。我想知道故障是否不支持原生sip,但我可以轻松地使用SipDroid或市场上的其他应用程序拨打电话。
修改 Logcat堆栈跟踪:
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)
答案 0 :(得分:2)
我想我有一些解决方案。并非每个版本的android都支持sip。因此,您应该寻找第三方库。例如,您可以查看Sipdroid或CSipSimple的源代码,并根据自己的需要进行转换。