Reputation: 438
Intent intent = new Intent(this, CalcActivity.class); PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT); builder.setContentIntent(pendingIntent); ((NotificationManager)getSystemService(Context.NOTIFICATION_SERVICE)).notify(0, builder.build());
The problem is that when user taps my notification, previous visible activity closes, home screen appears and my dialog is displayed on top of home screen. How to prevent closing of previous activity? Please note that previous activity might not come from my app.
Upvotes: 2
Views: 541
Reputation: 300
Use Intent as below :
Intent intent = new Intent(this,MainActivity.class).setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
and in AndroidManifest.xml
register activity and use theme as dialog
:
<activity android:name=".MainActivity" android:theme="@style/Theme.AppCompat.Light.Dialog"/>
Upvotes: 0