Created
May 29, 2018 18:23
-
-
Save pedromassango/1461ec95663956192d2ff331732d3d9a to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| /** | |
| * Created by Pedro Massango on 5/28/18. | |
| */ | |
| class AlarmBroadcastReceiver : BroadcastReceiver() { | |
| override fun onReceive(context: Context?, intent: Intent?) { | |
| // Create the notification to be shown | |
| val mBuilder = NotificationCompat.Builder(context!!, "my_app") | |
| .setSmallIcon(R.mipmap.ic_launcher) | |
| .setContentTitle("Alarm Manager") | |
| .setContentText("Hora de tomar seus comprimidos.") | |
| .setPriority(NotificationCompat.PRIORITY_DEFAULT) | |
| // Get the Notification manager service | |
| val am = context.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager | |
| // Generate an Id for each notification | |
| val id = System.currentTimeMillis()/1000 | |
| // Show a notification | |
| am.notify(id.toInt(), mBuilder.build()) | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment