我的应用中有通知,我需要在每个新的(更新的)通知中播放通知音频。在5.0之前的Android上它可以正常工作,但Lollipop只播放一次音频。如果我拨打电话,之后会播放音频通知,但只会再次播放(振动始终有效)。
NotificationManager mNotifyMgr = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
NotificationCompat.Builder builder = new NotificationCompat.Builder(Application.getInstance().getApplicationContext());
builder.setSmallIcon(iconSmall).setTicker("AppName ticker" + currentTime).setWhen(System.currentTimeMillis());
builder.setContentTitle("contentTitle");
builder.setSound(soundURI);
long[] patternr = {100, 100};
builder.setVibrate(patternr);
builder.setAutoCancel(false);
Notification notification = builder.setContentIntent(pIntent).build();
notification.category = Notification.CATEGORY_ALARM;
mNotifyMgr.notify(NOTIFI_ID, notification);
我尝试使用:
notification.sound = soundUri;
没有用。