Created
August 27, 2018 02:09
-
-
Save Debashis-Sinha/36cfe44ce4ae92c56a39a59fdaa9cd27 to your computer and use it in GitHub Desktop.
Open new activity from notification action using intent
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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