Question

I am working on an Android project that has a part which dose this: 1) the user enter a data from a data field and save it in a text file 2) the app should send notification even if the application is killed by the os, at that date, the one wrote by the user.

For example: I write 31.01.2015

The app will notify my only on 31.01.2015 even if i don't open that app anymore.

The question is how do i have to do this?

Thanks!

Was it helpful?

Solution

It sounds like you want a notification to be posted to the notification bar.

If so I advise using an alarm.

However, chances are if this is days in the future, the phone may be shut off. So you should store when the alarm should go off, create a Broadcast receiver for the on boot complete event (this requires a permission), and re-setup the alarm when the boot is complete.

This should allow the notification to appear, independent of the apps life-cycle, as long as the app is not uninstalled.

Note: You will have to calculate the milliseconds between the date for the alarm, and the current time. Calendar should help.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top