如何处理Android中的警报通知?

编程入门 行业动态 更新时间:2024-10-15 00:20:43
本文介绍了如何处理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每当任何其他应用程序(即使是闹钟)被激活时,您的活动肯定会进入后台.所以我想你可以覆盖 OnPause 和 OnResume 函数来放置你的代码.就贪睡或其他事情而言,它们都会导致警报活动被破坏(或暂停,对此知之甚少)并且您的活动将被恢复.所以这不会成为你关心的问题!

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中的警报通知?

本文发布于:2023-11-27 19:51:18,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1639373.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:警报   如何处理   通知   Android

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!