我已经搜索了这个,很抱歉,如果这已被回答(我很乐意被重定向),但具体而言,我们的问题是间歇性的。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