Reputation: 1289
I have a problem with Linphone library in android. When I have an incoming call, if I pick up, everything is okay, but if I hang up, the application crashes.
I have a LinphoneCore private variable:
private LinphoneCore mLc;
And this is the function that crashes.
private void declineCall() {
Log.e("CSR","Decline Call");
mLc.terminateAllCalls();
}
Here, the output:
04-07 10:48:40.599: E/CSR(4409): Decline Call
04-07 10:48:40.609: E/AndroidRuntime(4409): FATAL EXCEPTION: main
04-07 10:48:40.609: E/AndroidRuntime(4409): Process: com.test.myapp, PID: 4409
04-07 10:48:40.609: E/AndroidRuntime(4409): java.lang.NullPointerException: Attempt to invoke interface method 'void org.linphone.core.LinphoneCore.terminateAllCalls()' on a null object reference
04-07 10:48:40.609: E/AndroidRuntime(4409): at com.test.myapp.IncomingCallActivity.declineCall(IncomingCallActivity.java:165)
04-07 10:48:40.609: E/AndroidRuntime(4409): at com.test.myapp.IncomingCallActivity.onClick(IncomingCallActivity.java:138)
I suppose that the LinphoneCore variable has to be initialized, but I dont know what I have to put.
Somebody has the same problem or can help with the solution?
Thanks.
Upvotes: 0
Views: 427
Reputation: 1289
I found two possible solutions reading the linphone's code and trying different options.
Solution 1:
private void declineCall() {
mLc = LinphoneManager.getLcIfManagerNotDestroyedOrNull();
if (mLc != null) {
mLc.terminateAllCalls();
}
}
Solution 2:
private void declineCall() {
mLc = LinphoneManager.getLc();
if (mLc != null) {
mLc.terminateAllCalls();
}
}
Now it works and doesn't crash anymore :-)
Upvotes: 0