0

In some cases my app should show block screen. This screen pop up over alll screens, cover all UI elements and doesn't react on presses on back and home button, but should have ability to input password into.

Could you please suggest me a way how I can do that?

3 Answers3

1

You really shouldn't even try that. The user should be in control of his own phone. If I want to check my email, see my notifications, swap to another app or whatever I should be able to do so whenever I can.

Having said that: blocking the back button can be done by overriding this method in your activity (to do nothing for example)

public void onBackPressed() {
}
Mattias Isegran Bergander
  • 11,811
  • 2
  • 41
  • 49
1

Create fullscreen Activity with transparent background, put your "input password info" logic, override "Home" and "BackButton" actions in that Activity.

But this is not the best Android practice.

Veaceslav Gaidarji
  • 4,261
  • 3
  • 38
  • 61
0

I'll ignore the question of why you would want to do this, and just focus on the how. If you want to display UI full screen over all other screens, you will need to use an system alert window. You will need permissions SYSTEM_ALERT_WINDOW, and set your window type to

WindowManager.LayoutParams.TYPE_SYSTEM_ALERT
yoah
  • 7,180
  • 2
  • 30
  • 30