开发者

Broadcast Receiver and Service in Android

开发者 https://www.devze.com 2023-04-12 13:08 出处:网络
I am creating remi开发者_运维知识库nder type demo app. that include at every morning 7 a.m. it shows alert dialog with alarm sound.

I am creating remi开发者_运维知识库nder type demo app. that include at every morning 7 a.m. it shows alert dialog with alarm sound. I have use Broadcast Receiver for that. But I am confuse how can I show Alert with sound at 7 a.m.(I have create Transparent Activity for Displaying Alert Dialog).

Is there any suggestion?


If i where required to do such thing, i were guided by next logic :

  • Activity. It should be used for settings and such (like to define desired time).
  • BroadCastReceiver. It actually subscribes for system time and checks for desired time,which in its turn was passed by activity to BroadCastReceiver.
  • Inside BroadCastReceiver, onReceive method, you should check for desired time (with "if" for example). And if time is answering your requirements - do what you need. You can ran Toast, Akert or whatever you need.

Please notice that there is possibility to run program without any activity, but for better user experience some time it's better to allow more flexibility

Hope,it helps :)

0

精彩评论

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

关注公众号