I am going to create alarm application for android.
Could you help me please how to create background alarm process for android using Corona to start my application (it may be closed) by schedule ? [import]uid: 43048 topic_id: 34362 reply_id: 334362[/import]
I don’t understand the Android side as well as I do iOS, but apps are generally limited as to what they can do in the background and I’m not sure this is one of those things. However, this is something where “local notifications” can do what you want. Basically you set an event to fire in the future that can when the user responds to the notification on their device cause your app to launch.
[import]uid: 199310 topic_id: 34362 reply_id: 136603[/import]
I recommend that you schedule a local notification on the device via our [lua]system.scheduleNotification()[/lua] function.
http://docs.coronalabs.com/api/library/system/scheduleNotification.html
This allows your app to schedule an alarm, which when it triggers, will display a notification in the top status bar along with making a sound. When the user taps on the status bar notification, that will launch your app. Have a look at sample app “Notifications/LocalNotifications” that is included with the Corona SDK for an example.
Also, Corona does not provide a means to automatically launch the app when the scheduled notification triggers… but that’s a good thing. It would be extremely rude to the end-user to suddenly launch the app while they’re in the middle of doing something else on their Android device.
I hope this helps! [import]uid: 32256 topic_id: 34362 reply_id: 136623[/import]
Thanx a lot, for your answers, 
So this means I can’t create alarm which asks you to calculate simple math expression to stop the sound? If user at first have to close notification and only after then have to going through simple exercise … So there is no sence to creating alarm with this stuff.
May be I didn’t get somthing …
[import]uid: 43048 topic_id: 34362 reply_id: 136624[/import]
I’m not sure I understand what you want.
How does a local scheduled notification not work for you?
When the user taps on the notification in the status bar, it raises a notification event within your app that you can receive in Lua to handle it. The scheduling of the notification is handled via Android’s AlarmManager class which was designed exactly for this purpose.
http://developer.android.com/reference/android/app/AlarmManager.html
Now, are newest daily build #994 will raise an event immediately if your app is in the foreground. Is this the behavior that you are after? If so, then at the moment, that version is only available to subscribers since it is beta. [import]uid: 32256 topic_id: 34362 reply_id: 136632[/import]
I don’t understand the Android side as well as I do iOS, but apps are generally limited as to what they can do in the background and I’m not sure this is one of those things. However, this is something where “local notifications” can do what you want. Basically you set an event to fire in the future that can when the user responds to the notification on their device cause your app to launch.
[import]uid: 199310 topic_id: 34362 reply_id: 136603[/import]
I recommend that you schedule a local notification on the device via our [lua]system.scheduleNotification()[/lua] function.
http://docs.coronalabs.com/api/library/system/scheduleNotification.html
This allows your app to schedule an alarm, which when it triggers, will display a notification in the top status bar along with making a sound. When the user taps on the status bar notification, that will launch your app. Have a look at sample app “Notifications/LocalNotifications” that is included with the Corona SDK for an example.
Also, Corona does not provide a means to automatically launch the app when the scheduled notification triggers… but that’s a good thing. It would be extremely rude to the end-user to suddenly launch the app while they’re in the middle of doing something else on their Android device.
I hope this helps! [import]uid: 32256 topic_id: 34362 reply_id: 136623[/import]
Thanx a lot, for your answers, 
So this means I can’t create alarm which asks you to calculate simple math expression to stop the sound? If user at first have to close notification and only after then have to going through simple exercise … So there is no sence to creating alarm with this stuff.
May be I didn’t get somthing …
[import]uid: 43048 topic_id: 34362 reply_id: 136624[/import]
I’m not sure I understand what you want.
How does a local scheduled notification not work for you?
When the user taps on the notification in the status bar, it raises a notification event within your app that you can receive in Lua to handle it. The scheduling of the notification is handled via Android’s AlarmManager class which was designed exactly for this purpose.
http://developer.android.com/reference/android/app/AlarmManager.html
Now, are newest daily build #994 will raise an event immediately if your app is in the foreground. Is this the behavior that you are after? If so, then at the moment, that version is only available to subscribers since it is beta. [import]uid: 32256 topic_id: 34362 reply_id: 136632[/import]
Local Notification doesn’t work if you are attempting to build an alarm clock. Here is an excerpt from a posting on Local Notifications, http://www.coronalabs.com/blog/2012/12/05/faq-wednesday-local-notifications/:
2. How do I detect that a user ignored a local notification?
The answer is you can’t. If the user deletes (or ignores) a notification, the notification listener is never called and your app has no idea that it fired and and was ignored. (Your app could keep track of notifications scheduled and determine if a notification should have fired.)
None of the logic you might want to build into the alarm clock to ensure you are waking up the user is going to get executed unless they mess-around with the status bar, such as:
-
repeating the audio.
-
turning up the volume.
-
change to a different audio file
That basically means you are not on par with an alarm clock built natively for iOS or Android. Built natively, the notification can open the desired app so when you go to smack your phone to snooze or turn off the alarm, you are presented with an interface ripe for the smacking.
I was hoping to use Corona to make an Alarm Clock as well. I guess not. Its a bummer because it seems like a pretty entertaining environment to work in. Granted, I am just now looking into this, so maybe I am missing something. That would be great if it was the case.
[import]uid: 227180 topic_id: 34362 reply_id: 144243[/import]
This is an iOS limitation, not a Corona limitation. iOS does not notify the app when a notification is ignored or cleared by the end-user. Nor does iOS provide an API for the functionality that you are requesting, accept for repeating the notification which Corona does not currently support. My point being is that you are limited to the API as documented by Apple here…
http://developer.apple.com/library/ios/#documentation/iPhone/Reference/UILocalNotification_Class/Reference/Reference.html
[import]uid: 32256 topic_id: 34362 reply_id: 144302[/import]
Local Notification doesn’t work if you are attempting to build an alarm clock. Here is an excerpt from a posting on Local Notifications, http://www.coronalabs.com/blog/2012/12/05/faq-wednesday-local-notifications/:
2. How do I detect that a user ignored a local notification?
The answer is you can’t. If the user deletes (or ignores) a notification, the notification listener is never called and your app has no idea that it fired and and was ignored. (Your app could keep track of notifications scheduled and determine if a notification should have fired.)
None of the logic you might want to build into the alarm clock to ensure you are waking up the user is going to get executed unless they mess-around with the status bar, such as:
-
repeating the audio.
-
turning up the volume.
-
change to a different audio file
That basically means you are not on par with an alarm clock built natively for iOS or Android. Built natively, the notification can open the desired app so when you go to smack your phone to snooze or turn off the alarm, you are presented with an interface ripe for the smacking.
I was hoping to use Corona to make an Alarm Clock as well. I guess not. Its a bummer because it seems like a pretty entertaining environment to work in. Granted, I am just now looking into this, so maybe I am missing something. That would be great if it was the case.
[import]uid: 227180 topic_id: 34362 reply_id: 144243[/import]
This is an iOS limitation, not a Corona limitation. iOS does not notify the app when a notification is ignored or cleared by the end-user. Nor does iOS provide an API for the functionality that you are requesting, accept for repeating the notification which Corona does not currently support. My point being is that you are limited to the API as documented by Apple here…
http://developer.apple.com/library/ios/#documentation/iPhone/Reference/UILocalNotification_Class/Reference/Reference.html
[import]uid: 32256 topic_id: 34362 reply_id: 144302[/import]
Local Notification doesn’t work if you are attempting to build an alarm clock. Here is an excerpt from a posting on Local Notifications, http://www.coronalabs.com/blog/2012/12/05/faq-wednesday-local-notifications/:
2. How do I detect that a user ignored a local notification?
The answer is you can’t. If the user deletes (or ignores) a notification, the notification listener is never called and your app has no idea that it fired and and was ignored. (Your app could keep track of notifications scheduled and determine if a notification should have fired.)
None of the logic you might want to build into the alarm clock to ensure you are waking up the user is going to get executed unless they mess-around with the status bar, such as:
-
repeating the audio.
-
turning up the volume.
-
change to a different audio file
That basically means you are not on par with an alarm clock built natively for iOS or Android. Built natively, the notification can open the desired app so when you go to smack your phone to snooze or turn off the alarm, you are presented with an interface ripe for the smacking.
I was hoping to use Corona to make an Alarm Clock as well. I guess not. Its a bummer because it seems like a pretty entertaining environment to work in. Granted, I am just now looking into this, so maybe I am missing something. That would be great if it was the case.
[import]uid: 227180 topic_id: 34362 reply_id: 144243[/import]
This is an iOS limitation, not a Corona limitation. iOS does not notify the app when a notification is ignored or cleared by the end-user. Nor does iOS provide an API for the functionality that you are requesting, accept for repeating the notification which Corona does not currently support. My point being is that you are limited to the API as documented by Apple here…
http://developer.apple.com/library/ios/#documentation/iPhone/Reference/UILocalNotification_Class/Reference/Reference.html
[import]uid: 32256 topic_id: 34362 reply_id: 144302[/import]
Local Notification doesn’t work if you are attempting to build an alarm clock. Here is an excerpt from a posting on Local Notifications, http://www.coronalabs.com/blog/2012/12/05/faq-wednesday-local-notifications/:
2. How do I detect that a user ignored a local notification?
The answer is you can’t. If the user deletes (or ignores) a notification, the notification listener is never called and your app has no idea that it fired and and was ignored. (Your app could keep track of notifications scheduled and determine if a notification should have fired.)
None of the logic you might want to build into the alarm clock to ensure you are waking up the user is going to get executed unless they mess-around with the status bar, such as:
-
repeating the audio.
-
turning up the volume.
-
change to a different audio file
That basically means you are not on par with an alarm clock built natively for iOS or Android. Built natively, the notification can open the desired app so when you go to smack your phone to snooze or turn off the alarm, you are presented with an interface ripe for the smacking.
I was hoping to use Corona to make an Alarm Clock as well. I guess not. Its a bummer because it seems like a pretty entertaining environment to work in. Granted, I am just now looking into this, so maybe I am missing something. That would be great if it was the case.
[import]uid: 227180 topic_id: 34362 reply_id: 144243[/import]
This is an iOS limitation, not a Corona limitation. iOS does not notify the app when a notification is ignored or cleared by the end-user. Nor does iOS provide an API for the functionality that you are requesting, accept for repeating the notification which Corona does not currently support. My point being is that you are limited to the API as documented by Apple here…
http://developer.apple.com/library/ios/#documentation/iPhone/Reference/UILocalNotification_Class/Reference/Reference.html
[import]uid: 32256 topic_id: 34362 reply_id: 144302[/import]