Hey guys!
I would like to build a business app with main functionality in the background (server requests). Does Corona SDK support such features Android calling services?
Thanks in advance!
Hey guys!
I would like to build a business app with main functionality in the background (server requests). Does Corona SDK support such features Android calling services?
Thanks in advance!
Corona does not support backgrounding and coding background services.
Corona was designed to make it easy to develop a cross-platform OpenGL driven applications. The Corona API and the Corona runtime is closely tied to the rendering system. So, Android background services really don’t fit in this model. Especially since there is no iOS equivalent cross-platform equivalent. Because of this, I really recommend that you do this via Java and the Android SDK.
Sent you PM
Thank you, Joshua.
Corona does not support backgrounding and coding background services.
Corona was designed to make it easy to develop a cross-platform OpenGL driven applications. The Corona API and the Corona runtime is closely tied to the rendering system. So, Android background services really don’t fit in this model. Especially since there is no iOS equivalent cross-platform equivalent. Because of this, I really recommend that you do this via Java and the Android SDK.
Sent you PM
Thank you, Joshua.
So, if I understand correctly, an “alarm”-like app on Android (which would need to wake at random times) would be unreliable, because the app, even if not explicitly exited, could be killed off at any time by the OS.
It would be incredibly useful if the Corona library came with a build option to include a simple service which exists only to keep the notification around and to trigger main.lua in the case that the app is not already running. This would be standard for everybody and would enable a lot of functionality. It doesn’t cover the original poster’s need (actually doing real work in the background), but it would cover probably 90% of users’ needs.
Such a feature would make notifications seem identical on iOS and Android. Coding it would be easy, I imagine.
If we wanted to build such a service ourselves (using Java), is it even possible to connect that with our Corona app? Is that what the Enterprise license would enable?
Is this possible using two apps: one notification app written in Java and a Corona app, where the Java app runs the Corona app with an Intent? Are Intents usable in Corona? Is there some other way to do this?
I know (remote) push notifications solve most of these problems, but relying on a connection to, say, wake the user at a given time is not really an option. (In our case, we’d like to provide medication reminders as a small part of our service.)
yo1,
Corona for Android already has background services to handle notifications, in-app purchases, etc. This is how Corona is able to handle push notifications and post them on the status bar today. What we do not support is to allow Corona developers to create and code their own services in Lua. The reason why is exactly what I’ve posted above. Android services are a platform specific thing and if you want to do them, then you need to write them in Java. You can do this with Corona Enterprise.
And by the way, our notification service on Android is as close as it’ll get to iOS. The big difference is that status bar notifications on Android are managed by the application and not the OS. So, if you kill the application process, then all of its status bar notifications will disappear. There is nothing that you can do on the application’s end to prevent this. Try killing the Mail app on Android and you’ll see exactly this behavior. That’s just how it is, but that’s also how it works for all Android apps… so it’s nothing to worry about.
Thanks for the reply, Joshua.
My experience on Android is that services generally are not killed by the OS. If I “quit” Gmail by using the task manager, for instance, Gmail no longer appears on the task list, but the notifications are still there (just tried it) and tapping on it re-launches Gmail. Presumably this is handled by the service, which is not killed off by the task manager (though of course you could use a process manager to kill it).
I understand your argument about services generally being platform specific, but the general solution I outlined seems to be generally applicable for notifications, though not for background processes. (Android services do both.) Thus, we are not really asking for a general background processes solution (I see how that would be difficult), but a kind of “wake-up” solution based on time or tapping a notification. Thus, it is just simulating iOS, not providing anything different. To be more specific: there could be exactly one corona-coded service–the same for every Android app–which merely handles notification text and, upon a timer-defined alarm or a notification tap, “wakes” the main app and launches an event defined in the main app.
But more to the point are the practical questions should one try to do this right now:
Is it possible to create Intents and their respective Actions with Corona? (for the 2-app solution I outlined)
Does creating a Java service require the Enterprise license? (I guess this is certainly preferable to doing #1.)
If you want to create/code your own services and launch intents, then you need to do so in Java. Corona Enterprise gives you that option.
I recommend that you give Android services a go via the Android SDK first. Because I have experience writing them and what I’ve stated up above is true. If you end the process which hosts the service, then it does terminate the service. However, the process which hosts the service can be brought back to life (so to speak) if it has a broadcast receiver set up that’ll be invoked by the operating system. For example, a Google Play push notification would start up the process again. There’s also a startup broadcast intent that an app can be set up for that’ll startup your app when you boot-up your phone (Corona supports this).
There’s also a “persistent” setting that you can add to the AndroidManifest.xml file to keep the process alive (which not all forks of the Android OS may respect), but Google warns that it is only intended for “system applications”. Which could mean that an app reviewer may reject an app that uses it.
http://developer.android.com/guide/topics/manifest/application-element.html#persistent
In any case, I’m just giving you a bit of forewarning based on my experience. I don’t want you to commit to an enterprise license and be disappointed by the results, because what you want isn’t that simple. How Corona implements its notification handling services is how most Android apps handle it and is based on Google’s recommendations.
So, if I understand correctly, an “alarm”-like app on Android (which would need to wake at random times) would be unreliable, because the app, even if not explicitly exited, could be killed off at any time by the OS.
It would be incredibly useful if the Corona library came with a build option to include a simple service which exists only to keep the notification around and to trigger main.lua in the case that the app is not already running. This would be standard for everybody and would enable a lot of functionality. It doesn’t cover the original poster’s need (actually doing real work in the background), but it would cover probably 90% of users’ needs.
Such a feature would make notifications seem identical on iOS and Android. Coding it would be easy, I imagine.
If we wanted to build such a service ourselves (using Java), is it even possible to connect that with our Corona app? Is that what the Enterprise license would enable?
Is this possible using two apps: one notification app written in Java and a Corona app, where the Java app runs the Corona app with an Intent? Are Intents usable in Corona? Is there some other way to do this?
I know (remote) push notifications solve most of these problems, but relying on a connection to, say, wake the user at a given time is not really an option. (In our case, we’d like to provide medication reminders as a small part of our service.)
yo1,
Corona for Android already has background services to handle notifications, in-app purchases, etc. This is how Corona is able to handle push notifications and post them on the status bar today. What we do not support is to allow Corona developers to create and code their own services in Lua. The reason why is exactly what I’ve posted above. Android services are a platform specific thing and if you want to do them, then you need to write them in Java. You can do this with Corona Enterprise.
And by the way, our notification service on Android is as close as it’ll get to iOS. The big difference is that status bar notifications on Android are managed by the application and not the OS. So, if you kill the application process, then all of its status bar notifications will disappear. There is nothing that you can do on the application’s end to prevent this. Try killing the Mail app on Android and you’ll see exactly this behavior. That’s just how it is, but that’s also how it works for all Android apps… so it’s nothing to worry about.
Thanks for the reply, Joshua.
My experience on Android is that services generally are not killed by the OS. If I “quit” Gmail by using the task manager, for instance, Gmail no longer appears on the task list, but the notifications are still there (just tried it) and tapping on it re-launches Gmail. Presumably this is handled by the service, which is not killed off by the task manager (though of course you could use a process manager to kill it).
I understand your argument about services generally being platform specific, but the general solution I outlined seems to be generally applicable for notifications, though not for background processes. (Android services do both.) Thus, we are not really asking for a general background processes solution (I see how that would be difficult), but a kind of “wake-up” solution based on time or tapping a notification. Thus, it is just simulating iOS, not providing anything different. To be more specific: there could be exactly one corona-coded service–the same for every Android app–which merely handles notification text and, upon a timer-defined alarm or a notification tap, “wakes” the main app and launches an event defined in the main app.
But more to the point are the practical questions should one try to do this right now:
Is it possible to create Intents and their respective Actions with Corona? (for the 2-app solution I outlined)
Does creating a Java service require the Enterprise license? (I guess this is certainly preferable to doing #1.)
If you want to create/code your own services and launch intents, then you need to do so in Java. Corona Enterprise gives you that option.
I recommend that you give Android services a go via the Android SDK first. Because I have experience writing them and what I’ve stated up above is true. If you end the process which hosts the service, then it does terminate the service. However, the process which hosts the service can be brought back to life (so to speak) if it has a broadcast receiver set up that’ll be invoked by the operating system. For example, a Google Play push notification would start up the process again. There’s also a startup broadcast intent that an app can be set up for that’ll startup your app when you boot-up your phone (Corona supports this).
There’s also a “persistent” setting that you can add to the AndroidManifest.xml file to keep the process alive (which not all forks of the Android OS may respect), but Google warns that it is only intended for “system applications”. Which could mean that an app reviewer may reject an app that uses it.
http://developer.android.com/guide/topics/manifest/application-element.html#persistent
In any case, I’m just giving you a bit of forewarning based on my experience. I don’t want you to commit to an enterprise license and be disappointed by the results, because what you want isn’t that simple. How Corona implements its notification handling services is how most Android apps handle it and is based on Google’s recommendations.