Skip to content

Instantly share code, notes, and snippets.

@Dviejopomata
Created October 4, 2018 12:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Dviejopomata/01ad99000ef50e4f26e0b6e891fdac2b to your computer and use it in GitHub Desktop.
Save Dviejopomata/01ad99000ef50e4f26e0b6e891fdac2b to your computer and use it in GitHub Desktop.
Show android notification with alarm sound
val textTitle = "Title"
val textContent = "Content"
val alarmSound = Settings.System.DEFAULT_ALARM_ALERT_URI
val mBuilder = NotificationCompat.Builder(this, "alarm-1")
.setSmallIcon(R.drawable.navigation_empty_icon)
.setContentTitle(textTitle)
.setContentText(textContent)
.setPriority(NotificationCompat.PRIORITY_DEFAULT)
.setSound(alarmSound, AudioManager.STREAM_ALARM)
with(NotificationManagerCompat.from(this)) {
notify(1234, mBuilder.build())
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment