Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Intent intent = new Intent(this, NotificationReceiverActivity.class);
- PendingIntent pendingIntent = PendingIntent.getActivity(this, (int) System.currentTimeMillis(), intent, 0);
- Notification notification = new Notification.Builder(this).setContentTitle("Notification Test")
- .setContentText("Hello from CreateNotificationActivity")
- .setSmallIcon(R.drawable.notification_icon)
- .setContentIntent(pendingIntent)
- .addAction(R.drawable.notification_icon, "Action 1", pendingIntent)
- .addAction(R.drawable.notification_icon, "Action 2", pendingIntent)
- .addAction(R.drawable.notification_icon, "Action 3", pendingIntent)
- .build();
- NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
- notification.flags = Notification.FLAG_AUTO_CANCEL;
- notificationManager.notify(0, notification);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement