Catch hardware home button - Treat back button as home

How to catch android hardware home button. I want to trigger hardware home button if some one press back button. Is that possible? In short I want to minimize the app by clicking the back button.

1 Like

Hello,

There is no need to trigger the home button, all You need is to exit the app :smile:

ionic.Platform.exitApp()

Here’s more info in the Ionic docs

@psyche Actually I am working on android Media Plugin. So my problem is if I press back button then app is exiting and audio is getting stopped. So I thought of catching the back action and trigger it as home action.

I did’t get any solution for this. So I have created one plugin for this. Back as Home Plugin
Which will treat back button as home button. It won’t exit the app. It will minimize the app.

oooooh ok, I understand what You needed to do now!

Hello, amitsinha559.

I have got a similar problem with you.

I want to minimize my app when there is no back view to go instead of exit app.

I tried the background mode plugin, but it doesn’t work well.

I am new with android native code, so I am not sure if your Home Plugin can work on my problem.

Is there a js function i can use? Thank you.