Background task to run even when application is not running

274 views
Skip to first unread message

luane...@gmail.com

unread,
Jun 9, 2014, 7:47:03 AM6/9/14
to codenameone...@googlegroups.com
Sorry if this has been answered before, but I did search the forum to try find something like this.

I created a Codename One feature phone app. Every time you start the app it calls (http post) our server API to retrieve messages.
The messages it retrieves will be displayed as a list on the MessagesContainer which is part of the MainForm.

I have successfully added a background task that runs every minute to call the server to retrieve messages again - this all happens when you are inside the application.

My question is: 

Is it possible to have a background task running even when the Codename One application is not open? So I want to call the server API to retrieve messages even
when the application is not running.

Shai Almog

unread,
Jun 9, 2014, 10:11:03 AM6/9/14
to codenameone...@googlegroups.com, luane...@gmail.com
No. That would drain the battery and is prohibited by most OS's.
Android has services which will allow you to do that (you can write them using Codename One's native interfaces) however, if your service does this it will be killed after a while.
iOS has a background connection option starting with iOS 7 but it too will be killed.

Push notification is the only officially sanctioned way to achieve something like this.
Reply all
Reply to author
Forward
0 new messages