如何处理Android中的警报通知? [英] How to handle Alarm notification in Android?

查看:29
本文介绍了如何处理Android中的警报通知?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为 Android 开发一个媒体播放器应用程序,我需要处理任何警报通知,并基于此我将暂停播放.当闹钟进入暂停或解除时,我将恢复播放.

I'm developing an media player application for Android, for which I need to handle any Alarm notification, and based on that I'll pause my playback. When the Alarm in snoozed or dismissed, I'll then resume the playback.

我在谷歌上搜索了很多警报处理,但我发现的是通过代码启用警报通知、设置意图然后处理它的方法.但是,我无法找到仅处理警报通知部分的位置.我不需要设置闹钟,它可以由用户设置,我不需要以编程方式.我所需要的只是处理该通知.

I googled a lot for the Alarm handling, but what I found was the way to enable Alarm notifications through code, set the intent and then handle it. However, no where could I locate just handling the Alarm notification part. I don't need to set the Alarm on, it could've been set by the user, and I don't need to programmatically. All I need is just handle that notification.

对此有什么想法会非常有用吗?

Any ideas on this would be extremely useful?

谢谢,阿什什

推荐答案

HI Asheesh Vashishtha,

HI Asheesh Vashishtha,

纠正我这一点,但是AFAIK每当任何其他应用程序(即使是闹钟)被激活时,您的活动肯定会进入后台.所以我想你可以覆盖 OnPauseOnResume 函数来放置你的代码.就贪睡或其他事情而言,它们都会导致警报活动被破坏(或暂停,对此知之甚少)并且您的活动将被恢复.所以这不会成为你关心的问题!

Correct me on this, but AFAIK whenever any other application even if it is the alarm clock, is activated, your activity will surely go in background. So i guess u can override the OnPause and OnResume functions to put your bit of code. As far as snooze or other things are concerned, they all will result in the Alarm Activity getting destroyed(or paused, don know much about it) and your activity will get resumed. So that wont be a matter of concern for u!

希望这有帮助...

这篇关于如何处理Android中的警报通知?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆