I've read some of the other posts on this subject and I think my code should be sounding an alarm, but it's not. It does vibrate, but no sound. Any suggestions on how to get this to convey sound ?
Another part of the program is able to play a ringtone so the problem seems to be specific this routine.
This is in a class that extends Service
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
Uri sound = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
if (sound == null) { Log.i("RECEIVER", "SOUND IS NULL"); }
NotificationManager myNM = (NotificationManager)getSystemService(NOTIFICATION_SERVICE);
Intent intentMain = new Intent(this.getApplicationContext(), MainActivity.class);
PendingIntent pIntent = PendingIntent.getActivity(this, 0, intentMain, 0);
long[] pattern = {500,500,500,500,500,500,500,500,500};
Notification myNote = new Notification.Builder(this)
.setContentTitle("NotificationDemo")
.setContentText("NotificatinDemo")
.setSmallIcon(R.drawable.ic_launcher)
.setSound(sound)
.setVibrate(pattern)
.setContentIntent(pIntent)
.build();
myNM.notify(1, myNote);
return super.onStartCommand(intent, flags, startId);
}
First Check your device notification sound settings.
Then try this