I decided to write simple alarm clock (using AlarmManager). When alarm works out I want to show simple dialog with 2 buttons: OK and Snooze. So I have a question: what should I connect with my Pending Intent? I mean Service, Activity or BroadcastReceiver? At present version I use BroadcastReceiver where I start Activity that shows the dialog. I start it with flag FLAG_ACTIVITY_NEW_TASK. In onStrat() method I start music serv开发者_C百科ice. When OK button's pressed I call finish() for activity and stop music. In OnPause() I call finish() also. I do it because if two alarms run simultaneously then according to activity life cycle method onPause() will be called. It works... but sometime the music starts for a few seconds then finishes....then start again and finishes and so on. Why? Thanks.
So I have a question: what should I connect with my Pending Intent? I mean Service, Activity or BroadcastReceiver?
Probably an activity in this case. Theme your activity to look the way you want (e.g., Theme.Dialog
) rather than fussing around with a regular dialog box.
It works... but sometime the music starts for a few seconds then finishes....then start again and finishes and so on. Why?
It is impossible to answer this question with the information you have supplied, sorry.
精彩评论