I am working on an android application that uses phonegap/cordova. This app uses a javascript to fetch content from the server from time to time and issues a systemtray alert if there is new content. The problem I was facing was that the app would eventually just quit when android was short on memory or whatsoever.
So I added a service to my manifest (everybody says a service would solve the problem).
<service android:name="UpdateService" />
Verywell, but just having this service there does nothing (obviously). So how do I make my service trigger the main application to keep running?
ADDITION: I also managed to start the service in my main application
Try registering a PendingIntent with the AlarmManager that will check to make sure your application is running every n milliseconds. If it isn't running have the service start your application again.
Use some code like this to start your application:
Intent serviceIntent = new Intent("com.myapp.LaunchActivity");
startService(serviceIntent);
Replace com.myapp.LaunchActivity with your package name and LaunchActivity.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.