Is there any way to programmatically pause an Android app in Phonegap? I would like to mimic the behavior that occurs when you hit the HOME button. I've already had to overwrite the back button handler using this, and while in most cases I want it to do my action, when in a particular state the user would expect the app to minimize, and I want to replicate this behavior.
Keep in mind, on Android this is not the same as closing the app. That is quite easy to do with device.exitApp();
but I would like it to remember its state and keep running in the background. Especially if there's still an asynchronous job being done in the background.
Is there a feature in Phonegap to achieve this?
Possible duplicate of Manually pause an application in Android Phonegap, but I couldn't find some of the tools the OP mentioned there such as navigator
, so I was nervious to totally edit and rewrite their post
where C:\PhoneGap\App is your PhoneGap application's main directory, then run the following command that will build the PhoneGap application and produce the Android debug APK version: The build command would produce the debug version of the apks as well as creating some other necessary gradle build files if they are not yet created.
PhoneGap is a software development framework by Adobe System, which is used to develop mobile applications. To develop apps using PhoneGap, the developer does not require to have knowledge of mobile programming language but only web-development languages like, HTML, CSS, and JScript.
Now go to the PhoneGap Build page and sign in. Now click the “New App” button on the build page. This will ask you to enter the path to your GitHub repository, so do so, and then click “Pull from .git reposity”. Now back on the main build page, click “Update code” and “Pull latest”. Finally, click “Build”.
To create a workspace for your PhoneGap app on android, go to the “phonegap-android” folder on the command prompt or terminal: android_sdk_path: Where you installed the SDK. name: The name to give the new application.
The simple answer appears to be: no.
However, for anyone else that comes down this path, its not impossible. It's just that there isn't a feature of Phonegap to do it for you.
The Android equivalent of "sleeping an app" is actually just opening another intent. Specifically, opening the "Home" intent would sleep the running app and bring you back to the home screen. But as far as I can tell from asking around and scoping the docs, Phonegap doesn't have a direct way of opening intents.
What you (supposedly) can do is one of two things:
This plugin is supposed to be promising
Call the Java code that does it yourself using the means described here
Mind you, as of right now I've decided to not go any further with this, so I make no promises about either of those means, having not attempted them myself.
I invite anyone else who decides to pursue this further to update their experience here.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With