Problem: Create an android application that checks a local SQLite database at a given interval (say every day @ 12:00 am), does something with that data, then displays a notification to the user.
Seemed like a trivial thing to do.
Initially I thought I would need only a Service that my Activity starts. I was wrong.
After reading more thoroughly through the Android API documentation, numerous stackoverflow articles, and some trial and error I figured it out.
In order to do this on android you have to understand the following concepts:
- Services (more specifically IntentServices)
- Intents (more specifically PendingIntents)
- Reading/Writing to an SQLite database
- The AlarmManager
- How notifications work
- + a few other things
The short answer is the following.
Solution: You have to implement a custom broadcast receiver, that uses the AlarmManager to schedule a PendingIntent that starts a custom Service which does the work, which creates a Notification at (or around) a set time for the user to click on.
There's some quirks too you have to consider:
- How do you make sure your app continues to run after the user reboots the android device?
- How do you schedule the first Notification after your app is started by the user for the first time?
- When do you schedule the alarm to run? What happens if the device is off?
So if you just got an awesome idea for an Android app, great. I hope you'll be able to use your skills to build it and make it a success. But be warned, you need not only coding skills, but passion and patience, and don't fool yourself into thinking that it will take you a few hours.
Building an app (a non trivial app that is) is one thing. Building an android application that is well designed and coded, runs well, and provides a true service to your users is hard.
If you don't have the luxury of time, the patience required, or the necessary skills to build an Android Application yourself, don't sweat it, it's not easy stuff.
So do yourself a favor and hire a developer to build it for you.