Guillermo
Guillermo

Reputation: 57

How to have an android phonegap app allways running

I have an Android app (internal for my company, not public) developed using JQM and Phonegap. The app check each 15 minutes if the company server have some news for the device (1 device = an employee).

But it only works if the device is not in sleep mode.

I would like at least be able to do the same as whatsapp and other apps, send a little message to the notification area and/or shows a little window, sounds a beep... I can do some of this (as shows a window, sounds a beep) but only if the device is running in visible (not sleep) mode.

Then my question is: How to have an android phonegap app that is always running, or at least run each x minutes?

I this is not possible... Is possible then create an "mini" real native app only for this purpose, thus "call" to my app each x minutes?

Thanks, Guillermo, Spain.

Upvotes: 0

Views: 381

Answers (1)

sunil
sunil

Reputation: 701

link http://www.tipsfromsiliconvalley.com/2013/07/06/create-a-service-on-android-with-phonegap-application/

There is this article on how to create a service on Android with Phonegap which gives some good information on your problem.

It's using a great plugin in order to build a background service with phonegap easily. But you can't use JS though

I didn't find a way to make JS to run in the Background. BUT you can pass parameters from Java to JS and vice versa with the plugin...which is pretty useful. You would still need to rewrite your JS code in Java though.

you could create a service that calls a javascript callback? For example, you could have a service in Java code that when it receives a text message it calls a javascript callback function to execute some JS code? That would be perfect. plugin that seems to create a service and call Js code:

https://github.com/marknutter/GCM-Cordova

Upvotes: 1

Related Questions