How can I bring the call screen forward programmatically?
I am working on a home replacement program for people with vision problems. I don't want users to leave the call screen during a conversation by mistake.
I'm trying to bring the screen to the foreground programmatically if the user accidentally returned to my launcher during a call, but I haven't been able to figure out how to do this. This is what I am currently trying to do:
@Override
public void onResume() {
// If call state offhook, go back to current call
TelephonyManager telephony = (TelephonyManager) getApplicationContext().getSystemService(Context.TELEPHONY_SERVICE);
if (telephony.getCallState() == TelephonyManager.CALL_STATE_OFFHOOK) {
Intent i = new Intent(Intent.ACTION_DIAL, null);
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK );
getApplicationContext().startActivity(i);
}
How do I bring the call screen to the front?
+3
source to share
1 answer
I would suggest a different approach, hide the menu at the bottom of the screen. Thus, the user cannot mistakenly press any of the buttons during a call. To do this, you need to add the following line of code during the call:
getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_HIDE_NAVIGATION);
Therefore, it will look like the screen below:
How does this approach sound? Hope this can help you :)
0
source to share