Skip to content

Instantly share code, notes, and snippets.

@Lavanyagaur22
Last active January 4, 2020 19:29
Show Gist options
  • Save Lavanyagaur22/467395f46ebee5b98f3409e078f7f345 to your computer and use it in GitHub Desktop.
Save Lavanyagaur22/467395f46ebee5b98f3409e078f7f345 to your computer and use it in GitHub Desktop.
// Create an intent
val i = Intent()
i.action = Intent.ACTION_VIEW
i.data = Uri.parse("https://www.google.com")
// Craete a pending intent
val pi: PendingIntent =
PendingIntent.getActivity(this, 12345, i, PendingIntent.FLAG_UPDATE_CURRENT)
val actionedNotification = NotificationCompat.Builder(this, "first")
.setSmallIcon(R.drawable.ic_launcher_foreground)
.setContentTitle("Hello There")
.setContentText("General Master!")
// Set the intent that will fire when the user taps the notification
.setContentIntent(pi)
.setAutoCancel(true)
.setPriority(NotificationCompat.PRIORITY_DEFAULT).build()
nm.notify(2, actionedNotification)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment