Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
displayNotificationWithOneAction
public void displayNotification(String title, String message, int icon, int id) {
// Create PendingIntent that launches an activity
Intent intent = new Intent(getContext(), LoginRequestActivity.class);
PendingIntent pendingIntent = PendingIntent.getActivity(getContext(), 0, intent, PendingIntent.FLAG_ONE_SHOT);
// Build the notification
Notification notification = new NotificationCompat.Builder()
.setContentTitle(title)
.setContentText(message)
.setSmallIcon(icon)
.setContentIntent(pendingIntent)
.build();
// Post the notification
NotificationManager nm = (NotificationManager) getContext().getSystemService(Context.NOTIFICATION_SERVICE);
nm.notify(id, notification);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.