Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Debashis-Sinha/36cfe44ce4ae92c56a39a59fdaa9cd27 to your computer and use it in GitHub Desktop.
Save Debashis-Sinha/36cfe44ce4ae92c56a39a59fdaa9cd27 to your computer and use it in GitHub Desktop.
Open new activity from notification action using intent
private void openNewActivity(String title, String description){
Intent testIntent = new Intent(this,TestActivity.class);
testIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK|Intent.FLAG_ACTIVITY_CLEAR_TASK);
PendingIntent pen = PendingIntent.getActivity(this,15,testIntent,PendingIntent.FLAG_ONE_SHOT);
NotificationCompat.Builder builder = new NotificationCompat.Builder(this);
builder.setContentTitle(title)
.setContentText(description)
.setSmallIcon(R.mipmap.ic_launcher)
.setOngoing(true)
.addAction(R.drawable.ic_play, "Test", pen)
.setVisibility(NotificationCompat.VISIBILITY_PUBLIC);
NotificationManagerCompat notificationManagerCompat = NotificationManagerCompat.from(this);
notificationManagerCompat.notify(5,builder.build());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment