我已經搜索了這個,很抱歉,如果這已被回答(我很樂意被重定向),但具體而言,我們的問題是間歇性的。Android通知聲音沒有播放,間歇性地
我們的客戶抱怨說,當通過我們的軟件將事件發送到他們的手機時,通知音頻間歇性地不會「鳴叫」。它可以很好地工作一段時間,然後「停下來幾個小時」(從客戶的投訴中推斷出來)。
我們沒有能夠在內部重現這一點,但我們從客戶那裏得到的挫折是我們真的需要修復它。
我們的客戶堅持說他們沒有撥打電話,播放音頻或運行其他軟件,也沒有看到他們的手機,我基本上相信他們。
我們已經注意到這在很大程度上在果凍豆,因爲這是我們大多數客戶正在運行,但它可能不孤立到這種情況。
我做錯了什麼,或者是否有更好的方式來爲通知'編鐘'。在這個階段,我很高興地嘗試不同的東西
void updateNotification()
{
Notification.Builder builder = new Notification.Builder(_context);
// Set the appearance of the notification:
int icon;
String title;
String description;
// ...
//CODE setting icon, title and description
// ...
builder.setSmallIcon(icon);
builder.setContentTitle(title);
builder.setContentText(description);
builder.setTicker(description);
// Set the sound for the notification:
builder.setSound(RingtoneManager.getDefaultUri(RingtoneManager.TYPE_ALARM));
Intent intent = new Intent(_context, MainActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_SINGLE_TOP);
intent.putExtra(MainActivity.EXTRA_TAB, MainActivity.EXTRA_TAB_TASKS);
builder.setContentIntent(PendingIntent.getActivity(_context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT));
// Update the notification:
NotificationManager manager = (NotificationManager)_context.getSystemService(Context.NOTIFICATION_SERVICE);
manager.notify(_notificationId, builder.build());
}
謝謝,我會放棄這一點。 – johnc 2014-10-06 22:20:31
感謝您的編輯,你是指的AudioManager.getRingerMode()? – johnc 2014-10-06 22:28:54
是的,如果「getRingerMode()!= AudioManager.RINGER_MODE_NORMAL」,表示它處於靜音或振動狀態。看到我的其他編輯。 – 2014-10-06 22:38:33