How to prevent a user from closing an application - Android 4.0.3

So my question is: if you can prevent the user from closing the application.

The problem is that I cannot hide the action bar, and I use the tablet only for registering working hours. Therefore, if someone pressed the home button or the back button, this is unacceptable.

It is so interesting, can I somehow handle the onclose event?

Can I open the application in full screen mode (without an action bar)?

+5
source share
5 answers

, "". . , .

+4

- .

, , . , : , , , back power , ,

+4

, , , , , .

, , , , , .

, , - , , , 2 3 , , .

, , , "", . , , - .

+3

...

//Remove title bar

this.requestWindowFeature(Window.FEATURE_NO_TITLE);


//Remove notification bar

this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);

Ref- > Activity XML

........

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    if(keyCode==KeyEvent.KEYCODE_BACK || keyCode==KeyEvent.KEYCODE_HOME){
                    // pass some msg ......
        return true;
    }
    return super.onKeyDown(keyCode, event);
}
+2

, , ...

SureLock. . .

, HideBar

...

+2
source

All Articles