我在Service中创建了一个通知(从BroadcastReceiver启动):
this.notification = new NotificationCompat.Builder(getApplicationContext())
.setContentTitle("Foo")
.setContentText("Bar")
.setSmallIcon(R.drawable.logo)
.setContentIntent(pIntent)
.build();
this.initializeNotificationSound(volumne, Uri.parse(melody));
this.initializeNotificationVibration();
notification.flags = Notification.FLAG_INSISTENT;
this.notificationManager.cancelAll();
this.notificationManager.notify(0, notification);
收到特定短信时会设置此通知。我想创建一个通知,它将播放定义的旋律,不会被标准的短信通知中断。
此功能非常有用,但在棒棒糖中,会出现以下情况:
仅当铃声模式静音时才会发生这种情况。否则,它会按预期工作,因为cancelAll()方法会中断SMS通知。
提前感谢您的回复。
答案 0 :(得分:0)
你不能改变它。如果您注意到,当同时创建多个通知时,即使是来自单一应用程序(例如Facebook),它们所发出的声音也会同时播放。这与android系统本身的通知管理有关。也许您遇到的问题是由于对特定Android系统版本(API级别)进行了一些代码更改,可能是cancelAll()
方法。一种解决方案是找到用于检查当前系统版本的适当代码行。例如:
if(System_version <= lollipop) {
//code works fine. Keep as it is
}
else{
//find the appropriate method and call it here.
}