How to make Back emulate Home?

Monkey Targets Forums/Android/How to make Back emulate Home?

Oddball(Posted 2014) [#1]
Is it possible to make the Back button act like the Home button? i.e. Suspend the app instead of completely closing it. I know that pressing the Back button calls OnBack, but what do I put in OnBack to suspend the app?


Capn Lee(Posted 2014) [#2]
Hi Dave,
by default that is exactly what it does. It does this to mirror the iPhone button.
You only need to edit OnBack() if you want more custom than that.


Capn Lee(Posted 2014) [#3]
sorry, it appears that's wrong. I was sure that was how it was supposed to behave


Oddball(Posted 2014) [#4]
I've had a good look through the docs and I can't find anything that lets me suspend the app. I'm guessing it's not possible.


AdamRedwoods(Posted 2014) [#5]
http://stackoverflow.com/questions/3141996/android-how-to-override-the-back-button-so-it-doesnt-finish-my-activity

i don't know if it can be done in monkey, i havn't tried it. can you block the back button using monkey? if so, then you could try injecting some native code in the OnBack() to call home.


Gerry Quinn(Posted 2014) [#6]
You can block the Back button simply by overriding App.OnBack() with an empty function.

Better to start up an "Exit App (Yes/No)" dialog though IMO.

But anyway, App.OnBack() calls App.OnClose(), but you can override it to do whatever you want.


Oddball(Posted 2014) [#7]
I know I can, and how to, override OnBack. My question was, is there a function that suspends the app in the same manner as the home button does?