Use Service's context if activity not available
This commit is contained in:
parent
a0b2feecb2
commit
07e5982fc8
1 changed files with 5 additions and 3 deletions
|
@ -1026,7 +1026,7 @@ public final class LinphoneManager implements LinphoneCoreListener {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Context getActivity() {
|
public Context getContext() {
|
||||||
try {
|
try {
|
||||||
if (LinphoneActivity.isInstanciated())
|
if (LinphoneActivity.isInstanciated())
|
||||||
return LinphoneActivity.instance();
|
return LinphoneActivity.instance();
|
||||||
|
@ -1034,6 +1034,8 @@ public final class LinphoneManager implements LinphoneCoreListener {
|
||||||
return InCallActivity.instance();
|
return InCallActivity.instance();
|
||||||
else if (IncomingCallActivity.isInstanciated())
|
else if (IncomingCallActivity.isInstanciated())
|
||||||
return IncomingCallActivity.instance();
|
return IncomingCallActivity.instance();
|
||||||
|
else
|
||||||
|
return LinphoneService.instance().getApplicationContext();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
@ -1064,7 +1066,7 @@ public final class LinphoneManager implements LinphoneCoreListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (state == CallEnd || state == Error) {
|
if (state == CallEnd || state == Error) {
|
||||||
Context activity = getActivity();
|
Context activity = getContext();
|
||||||
if (activity != null) {
|
if (activity != null) {
|
||||||
TelephonyManager tm = (TelephonyManager) activity.getSystemService(Context.TELEPHONY_SERVICE);
|
TelephonyManager tm = (TelephonyManager) activity.getSystemService(Context.TELEPHONY_SERVICE);
|
||||||
if (tm.getCallState() == TelephonyManager.CALL_STATE_IDLE) {
|
if (tm.getCallState() == TelephonyManager.CALL_STATE_IDLE) {
|
||||||
|
@ -1444,7 +1446,7 @@ public final class LinphoneManager implements LinphoneCoreListener {
|
||||||
enableCamera(call, sendCamera);
|
enableCamera(call, sendCamera);
|
||||||
}
|
}
|
||||||
|
|
||||||
Context activity = getActivity();
|
Context activity = getContext();
|
||||||
if (activity != null) {
|
if (activity != null) {
|
||||||
TelephonyManager tm = (TelephonyManager) activity.getSystemService(Context.TELEPHONY_SERVICE);
|
TelephonyManager tm = (TelephonyManager) activity.getSystemService(Context.TELEPHONY_SERVICE);
|
||||||
if (state == State.CallEnd && mLc.getCallsNb() == 0 && tm.getCallState() == TelephonyManager.CALL_STATE_IDLE) {
|
if (state == State.CallEnd && mLc.getCallsNb() == 0 && tm.getCallState() == TelephonyManager.CALL_STATE_IDLE) {
|
||||||
|
|
Loading…
Reference in a new issue