我正在使用Alarm Manager创建一个在特定时间触发的通知,它能够正常工作,但是当按下音量按钮时无法停止播放声音,就像接听电话时一样。
以下是我创建通知的方式:
NotificationCompat.Builder notification = new NotificationCompat.Builder(this);
notification.setAutoCancel(true);
notification.setSmallIcon(R.drawable.notification_icon);
notification.setTicker("This's the ticker");//status bar text
notification.setContentTitle("title");
notification.setContentText("text");
notification.setPriority(1);
Uri sound = Uri.parse("android.resource://" + getPackageName() + "/" + R.raw.notifysound);
notification.setSound(sound);
String ns = Context.NOTIFICATION_SERVICE;
NotificationManager manager = (NotificationManager) this.getSystemService(ns);
manager.notify(0,notification.build());
希望有人能帮助我解决如何实现这个问题。提前感谢。