我有以下代码来生成通知.通知出现但没有声音.我有以下代码来打开声音
notification.defaults |= Notification.DEFAULT_SOUND;
代码清单
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);
摊晒
你应该尝试设置
notification.defaults = Notification.DEFAULT_SOUND | Notification.DEFAULT_LIGHTS;
或明确设置:
notification.sound = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);