3

I'm working on a home replacement app for people with eyesight problems. I don't want users to leave the call screen during a call by mistake.

I'm trying to bring the screen to front programatically if the user accidentally went back to my launcher during a call, but I haven't been able to figure how to do it. This is what I'm trying right now:

@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 can I bring the call screen to front?

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
lisovaccaro
  • 32,502
  • 98
  • 258
  • 410
  • 1
    I may be oversimplifying this, but wouldn't a simple Intent like ACTION_CALL (with no data - should just open the app) or ACTION_CALL_BUTTON do? Maybe even ACTION_DIAL? – Janis F Feb 08 '15 at 22:58
  • Are you building a system app with system privileges? What Android version(s) are you targeting? – David Wasser Feb 11 '15 at 20:02
  • [have a look on this answer](http://stackoverflow.com/a/4538431/3049917) – Top Cat Feb 14 '15 at 08:27
  • I'm support versions from 2.2. I would accept an answer that fits the purpose even if it doesn't support some versions. – lisovaccaro Feb 15 '15 at 21:43

1 Answers1

0

I would give it a different approach, hide the menu at the bottom of the screen. In this way the user cannot mistakenly hit any of the buttons during a call. To do this all you need to do is add the following line of code during a call:

getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_HIDE_NAVIGATION);

It would therefore look similar to the screen below:

enter image description here

How does that approach sound? Hope it may help you :)

Michele La Ferla
  • 6,775
  • 11
  • 53
  • 79
  • 1
    Hi Michele, I'm sorry but it's not what I'm looking for. Just curious where should I add that line? it seems to me if I do it before opening the call I'll only hide the menu on my activity. – lisovaccaro Feb 11 '15 at 01:38