Skip to content

Instantly share code, notes, and snippets.

@brendan-fahy
Created January 19, 2017 22: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 brendan-fahy/e1730c75cb6525287bf6389383b40c6a to your computer and use it in GitHub Desktop.
Save brendan-fahy/e1730c75cb6525287bf6389383b40c6a to your computer and use it in GitHub Desktop.
private fun buildNotification(batteryStatus: Intent): Notification {
val level = batteryStatus.getIntExtra(BatteryManager.EXTRA_LEVEL, -1)
return NotificationCompat.Builder(this)
.setContentTitle(getString(R.string.app_name))
.setContentText("Phone is $level% charged.")
.setSmallIcon(R.mipmap.ic_launcher)
.setOnlyAlertOnce(true)
.build()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment