如何停止并继续播放通知?

问题描述:

我要实现这一点:如何停止并继续播放通知?

  • 当警报响起的通知声音应不断播放,直到用户拖动通知栏。
  • 当我向下拖动通知栏时,声音应停止播放
+0

您可以设置声音广播接收器,并在活动停止播放声音,你已经从设置的意图通知。你知道我在想什么。 – 2013-03-08 06:04:33

+0

亚我知道了我通过服务 – Ramya 2013-03-08 09:42:02

+0

伟大的工作:-)你怎么做? – 2013-03-08 09:48:13

在通知有被用来停止通知几个标志自动u必须使用他们那些。

  1. Notification.DEFAULT_SOUND:用于播放声音。

2.Notification.FLAG_INSISTENT:该标志使您的声音持续响起,直到您对通知进行了一​​些操作,即拖动栏或单击栏。

3.Notification.FLAG_AUTO_CANCEL:这个标志是用来自动取消通知你已经看到后

why the nastiness with reflection? 

因为它不是在Android SDK的一部分。只有对创建不可靠应用感兴趣的人才会尝试与Android源代码本身之外的StatusBarManager进行交互。由于欢迎核心Android团队和设备制造商随时随地更改SDK以外的任何内容。

Why can't I find a reference to the StatusBarManager class directly? 

因为它不是在Android SDK的一部分。但是也有一些标有@hide标注在Android框架许多伟大的类和方法,对各种原因:不愿“默默无闻安全”承诺无限期地支持该API,等

Why is there not a constant in the Context class for the "statusbar" service? 

因为它不是Android SDK的一部分。当然欢迎您为AOSP提供补丁,使StatusBarManager被“提升”到与其他系统服务(例如LocationManager,NotificationManager)相同的状态。如果StatusBarManager的情况仅仅是在〜2007年创建SDK之后的疏忽,那么您的补丁程序可能会被接受,并且您会看到即将发布的Android版本中的更改。

Why can't I find a reference to the StatusBarManager class directly?