我已經使用了較新的NotificationCompat構建器,並且無法通知發出聲音。它會振動並閃光。 Android文檔說設置我已經完成的風格:Android通知聲音
builder.setStyle(new NotificationCompat.InboxStyle());
但沒有聲音?
的完整代碼:
NotificationCompat.Builder builder =
new NotificationCompat.Builder(this)
.setSmallIcon(R.drawable.ic_launcher)
.setContentTitle("Notifications Example")
.setContentText("This is a test notification");
Intent notificationIntent = new Intent(this, MenuScreen.class);
PendingIntent contentIntent = PendingIntent.getActivity(this, 0, notificationIntent,
PendingIntent.FLAG_UPDATE_CURRENT);
builder.setContentIntent(contentIntent);
builder.setAutoCancel(true);
builder.setLights(Color.BLUE, 500, 500);
long[] pattern = {500,500,500,500,500,500,500,500,500};
builder.setVibrate(pattern);
builder.setStyle(new NotificationCompat.InboxStyle());
// Add as notification
NotificationManager manager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
manager.notify(1, builder.build());
builder.setSound(Settings.System.DEFAULT_NOTIFICATION_URI)也應努力 – Nepster 2016-06-20 09:12:47