开发者

Triggering an alert dialog from AlarmManager (Android)

开发者 https://www.devze.com 2023-01-30 02:23 出处:网络
(I know I can just use the built-in alarm clock app but I\'m a noob and I want to learn to do this myself...)

(I know I can just use the built-in alarm clock app but I'm a noob and I want to learn to do this myself...)

I want to write a reminder app where I can set a time for it pop up a dialog to remind me of something important. (I want something annoying that I have to dismiss hence a dialog with a message, not just a Notification beep.) I can pick a time with the TimePicker and execute a service - that's easy. But now what?

I've read you shouldn't (or can't) launch an AlertDialog from a service. Should I bind an Activity to the service a开发者_Python百科nd launch an AlertDialog from there? What's best practice?

Thanks in advance!!


The behaviour you have described is ok. On alarm you can launch the activity and it will show an alert dialog.

Yes, you definitely can't show an AlertDialog from service, because service doesn't have anything connected to user interface.

0

精彩评论

暂无评论...
验证码 换一张
取 消