Vibrate and Sound defaults on notification in android
We need to add sound and vibration when notification comes in.
Here I have written the way to get default sound when notification comes in. And vibration because of notification.
NotificationCompat.Builder mBuilder =
new NotificationCompat.Builder(this)
.setSmallIcon(R.drawable.ic_launcher)
.setContentTitle("My Application")
.setStyle(new NotificationCompat.BigTextStyle()
.bigText(extras.getString("message")))
.setContentText(extras.getString("message"));
//set Uri for sound
Uri alarmSound = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
//add sound when notification comes in.
mBuilder.setSound(alarmSound);
//add vibration when notification comes in.
mBuilder.setVibrate(new long[] { 1000, 1000, 1000, 1000, 1000 });
0 Comment(s)