April 9th, 2013, 11:01 AM
Design advice - services & broadcast receivers
I'm in the process of learning the Android SDK and creating some projects to get a grasp on the system. The current project I'm working with works just fine but I'd like to get some advice about other ways I can go about designing it.
Here's what it needs to do. When a text message is received from a specific number, it should fire off a toast message that repeats at a certain interval for a specific duration.
To make this work, I created an SMS BroadcastReceiver and checked the incoming messages for the number I'm looking for.
If found, an IntentService would be started that would pull out the interval and duration from saved shared prefs. The IntentService would then fire off a broadcast.
The BroadcastReceiver for this would catch it and use the AlarmManager to handle the toast message repetitions.
This all works just fine, but I'm wondering if there's a cleaner or more efficient way of going about doing this? Any suggestions or advice?