Android通知声音没有停止

时间:2015-08-29 13:08:13

标签: android notifications

我使用旧方式显示通知。这是我的代码:

Notification n = new Notification(R.drawable.facebookicon,"New Message",System.currentTimeMillis());


intent=new Intent(mContext,NotificationMessageShower.class);
intent.putExtra("message",message);
// use System.currentTimeMillis() to have a unique ID for the pending intent
PendingIntent pIntent = PendingIntent.getActivity(mContext, (int) System.currentTimeMillis(), intent, 0);

n.setLatestEventInfo(mContext, "New Message", message,pIntent);
n.flags = Notification.DEFAULT_LIGHTS | Notification.FLAG_AUTO_CANCEL;
Uri uri= RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
n.sound=uri;
n.audioStreamType = AudioManager.STREAM_NOTIFICATION;

int curNotificationId= Calendar.getInstance().get(Calendar.MILLISECOND);
notificationManager.notify(curNotificationId, n);

问题是,当收到通知时,通知声音会一直重复,直到我打开非常烦人的通知栏。如何摆脱这种情况,以便通知声音只播放一次?

我正在使用旧方式,因为我希望应用程序在Android Api等级8上运行。在印度,很多人仍然使用旧版本的android,所以我不想错过那些用户。

0 个答案:

没有答案
相关问题