I've been working on a practice Android application to familiarize myself with the platform. Specifically, the app I'm trying to implement allows the user to select a sound file (MP3 or WAV) to play at a specific date and time showing a dialog with a progress bar and an OK/Cancel button allowing the user to stop the playing of the sound file. I want it to behave something like the countdown apps I've seen or even the built-in alarm clock app. As I'm implementing this simple (I thought!) app, I'm trying to better understand the platform and make the application conform to the Android way.
As I've been writing the app, I learn more about how things are supposed to work on the Android platform. And here's where I'm getting a bit confused. During my attempts to get the alarm to fire and display, I'm learning that properly formed Android applications are not supposed to show dialogs as a result of a background service or broadcast receiver being invoked through Android's alarm service. Instead, I think, the app is supposed to use a notification on the status bar to alert the user. The user then has the option to look at the notification to see what the app is trying to tell them.
I’ve managed to get the dialog I wanted to bring up to appear by launching a new activity from a service that was launched by Android’s alarm service. However, it appears that I’ve broken an Android rule by doing so. I knew this first because I saw a message in the DDMS LogCat window that asked if I was sure I wanted to start a new activity from a Service. Second, I read in several places that it was not nice to do so. One statement that comes to mind was from a Google developer that said he’d certainly uninstall an app that did something like that.
The app is instead, if I understand correctly, supposed to use the status bar and notification to get the user’s attention and allow them to see what the app wants at their leisure. This seems counter-intuitive to what my app is trying to do. Again, I’m trying to get it to behave, essentially, like the countdown apps I’ve seen or the built-in alarm clock application that comes on the Android phones. If my app is not behaving correctly, is the alarm clock app behaving? Obviously I’d say the alarm clock app is doing exactly what I’d expect. And a user of my app, I think, would expect the sound file to play with a dialog showing allowing the playing of the sound file to be stopped without having to go through the status bar.
Am I understanding the Android platform correctly? Any opinions on how an app like this could be implemented without being naughty by bringing up the dialog I mentioned? I’d like the application to be regarded as a well-formed Android app, but I’m having a difficult time seeing how my app is so different from others I’ve seen or even the built-in alarm clock application.
Thanks! Jeff