android无法通过通知播放声音

Ted*_*tel 2 audio notifications android

我有以下代码来生成通知.通知出现但没有声音.我有以下代码来打开声音

notification.defaults |= Notification.DEFAULT_SOUND;
Run Code Online (Sandbox Code Playgroud)

代码清单

    NotificationManager manager = (NotificationManager)     gContext.getSystemService(Context.NOTIFICATION_SERVICE);

    Notification notification = new Notification(R.drawable.icon, "Teeth Alert", System.currentTimeMillis());
    PendingIntent contentIntent = PendingIntent.getActivity(gContext, 0, new Intent(gContext, NotifyMessage.class), 0);
    notification.setLatestEventInfo(gContext, "Your teeth appoitmernt:", "Date:", contentIntent);

    notification.defaults |= Notification.DEFAULT_SOUND;
    notification.defaults |= Notification.DEFAULT_LIGHTS;

    manager.notify(1,notification);
    cDates.SetAlarm(i);
Run Code Online (Sandbox Code Playgroud)

摊晒

rek*_*eru 11

你应该尝试设置

notification.defaults = Notification.DEFAULT_SOUND | Notification.DEFAULT_LIGHTS;
Run Code Online (Sandbox Code Playgroud)

或明确设置:

notification.sound = 
    RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
Run Code Online (Sandbox Code Playgroud)