Skip to content

Instantly share code, notes, and snippets.

@smaugho
Created May 3, 2017 13:13
Show Gist options
  • Save smaugho/d42f4b47be8c19034907f7dde642a05d to your computer and use it in GitHub Desktop.
Save smaugho/d42f4b47be8c19034907f7dde642a05d to your computer and use it in GitHub Desktop.
Notifications Action Example
//Prepare the intent
Intent intent = $MainActivity().intent()
.flags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK)
.get();
//Prepare pending intent
PendingIntent contentIntent = PendingIntent.getActivity(
this, 0, notificationIntent,
PendingIntent.FLAG_CANCEL_CURRENT);
//Send notification
$Notification(NOTIFICATION_ID)
.contentTitle("Notification title")
.contentText("Notification Text")
.smallIcon(R.drawable.app_icon)
.contentIntent(contentIntent)
.autoCancel(true)
.defaults(Notification.DEFAULT_SOUND);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment