Advertisement
Guest User

Untitled

a guest
Mar 30th, 2017
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.10 KB | None | 0 0
  1. Intent intent = new Intent(this, NotificationReceiverActivity.class);
  2. PendingIntent pendingIntent = PendingIntent.getActivity(this, (int) System.currentTimeMillis(), intent, 0);
  3.  
  4. Notification notification = new Notification.Builder(this).setContentTitle("Notification Test")
  5. .setContentText("Hello from CreateNotificationActivity")
  6. .setSmallIcon(R.drawable.notification_icon)
  7. .setContentIntent(pendingIntent)
  8. .addAction(R.drawable.notification_icon, "Action 1", pendingIntent)
  9. .addAction(R.drawable.notification_icon, "Action 2", pendingIntent)
  10. .addAction(R.drawable.notification_icon, "Action 3", pendingIntent)
  11. .build();
  12. NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
  13. notification.flags = Notification.FLAG_AUTO_CANCEL;
  14. notificationManager.notify(0, notification);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement