Created
October 4, 2018 12:01
-
-
Save Dviejopomata/01ad99000ef50e4f26e0b6e891fdac2b to your computer and use it in GitHub Desktop.
Show android notification with alarm sound
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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