I have a call service which opens the call screen whenever a incoming call is received, the problem is if my app is in background and if there is a call and when the call is over, the app automatically opens from background activity. If the app is not in background and a call is received and when it is over the app doesn't open ups.
Is this a default behavior or I am doing something wrong.
I don't want the app to automatically launch from background.
private val callReceiver = object : BroadcastReceiver() {
override fun onReceive(context: Context, intent: Intent?) {
val callId = intent?.getStringExtra(KEY_CALL_ID)
val isVideoCall = intent?.getBooleanExtra(KEY_IS_VIDEO, false) ?: false
callId?.let {
RtcCallActivity.startIncomingCall(context, callId, isVideoCall)
}
}
}
fun startIncomingCall(context: Context, callId: String?, videoEnabled: Boolean) {
val intent = Intent(context, CallActivity::class.java).apply {
addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
putExtra(CallService.VIDEO_ENABLED, videoEnabled)
putExtra(INCOMING_CALL, true)
putExtra(CALL_ID, callId)
}
context.startActivity(intent)
}
We are implementing call feature like whatsapp->
- Incoming call (app could be in background)
- Call is over
- Now the phone should be in previous state (The whatsapp will not be open up after the call is over)