Notification bring app to front without change activity
Working solution for me was :
//Resume or restart the app (same as the launcher click)
val resultIntent = Intent(context, MyLauncherActivity::class.java)
resultIntent.addCategory(Intent.CATEGORY_LAUNCHER)
resultIntent.setAction(Intent.ACTION_MAIN)
resultIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
val pendingIntent = PendingIntent.getActivity(context, 0, resultIntent, PendingIntent.FLAG_UPDATE_CURRENT)
builder.setContentIntent(pendingIntent) //builder is the notificationBuilder
You don't ever set Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT
. That flag is set by Android when it brings the activity to the front. You setting it has no effect.
There's a few ways to do what you want. Check out this answer