-1

My users require an alert in order to avoid leaving accidentally my app when clicking on Home button (otherwise, they loose their -long- work and have to restart it... Indeed, my AR app cannot recover its state at restart).

So, I want to display an alert asking if they really want to leave if they click on the home button.

I saw some posts explaining how to override the Home button in order to catch the click event.

Namely this one: Detect home button press in android (use of 'HomeWatcher' or of 'onUserLeaveHint()')

Ok great, I catch the click event but as far as I can see, the app is left anyway and the user is sent to the home screen (springboard).

Is there any way to to what I want:

  • catch the click event on Home button
  • display an alert
  • go home only if the users confirms that he wants to leave
Zoe
  • 27,060
  • 21
  • 118
  • 148
toto_tata
  • 14,526
  • 27
  • 108
  • 198

1 Answers1

4

No, for security reasons, there is no way of blocking the default behavior of home button.

Derek K
  • 2,756
  • 1
  • 21
  • 37