0

Is there any way to set my application to run in foreground while pressing any key, even the home button? I have tried with avtivitymanager, but I didn't get o/p. I think you may be able to help me.

Ashwin Kanjariya

Null Set
  • 5,374
  • 24
  • 37

2 Answers2

0

I find out that you can catch keypresses by overriding one of the onKey..(int keyCode, KeyEvent event) functions in the activity, but you can not override the home key for some reasons.

Community
  • 1
  • 1
Blackguard
  • 193
  • 1
  • 2
  • 9
0

you can stop functioning of all buttons,,,,

You just override the home and back button of device

public boolean onKeyDown(int keyCode, KeyEvent keyEvent) {

    if (keyCode == KeyEvent.KEYCODE_Home) {
        //finish();
    }
    return super.onKeyDown(keyCode, keyEvent);

}

In your activity class your application will not be interrupted as the buttton default functionality is overrided as you desire...

Arpit Garg
  • 8,476
  • 6
  • 34
  • 59