Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Manually pause an application in Android Phonegap

Would it be possible to pause an Android PhoneGap application manually? I need to pause the application and go to background when somebody click a button. I used navigator.app.exitApp(); but it completely closes the application. I do not want to close the application just unload just like is done with the native back button. Please help, thanks.

like image 782
Sarath DR Avatar asked Oct 07 '22 20:10

Sarath DR


1 Answers

Here's a solution which is similar to Joram Teusink's answer, but easier because you don't need to manually edit java code - just install a plugin with the phonegap / cordova CLI.

The plugin one function: goHome(). If you call this, the app will pause - just like pressing the home button.

Usage:

navigator.Backbutton.goHome(function() {
  console.log('success - the app will now pause')
}, function() {
  console.log('fail')
});

Installation:

phonegap local plugin add https://github.com/mohamed-salah/phonegap-backbutton-plugin.git

Here's the github page:

https://github.com/mohamed-salah/phonegap-backbutton-plugin.git

like image 107
Lucidity Avatar answered Oct 12 '22 12:10

Lucidity