0

I am making an app to detect home key of d-pad but unfortunately there is no key provided by amazon but I tried another way by using

@Override
protected void onUserLeaveHint() {
    Log.e("Trend Activity", "Home Key pressed");
    finishAffinity();
    Log.e("Trend Activity", "Home Key pressed");
    super.onUserLeaveHint();
}

but still I am getting issue when pressing long home key of d-pad. It is killing all activity it is good but I don't want to kill activity on long press. Please help me thanks in Advance.

ajay
  • 101
  • 1
  • 6

1 Answers1

1

Firstly - it is bad practice to override the functionality of the Home key.

However if you really want to do it you will want to look for KeyEvent.KEYCODE_HOME.

Then check this answer out for differentiating different press types -> How to differentiate between long key press and regular key press?

Community
  • 1
  • 1
Jeff Sutton
  • 901
  • 7
  • 6