I have one notification, created in MainActivity's OnStop(). It looks like that:
@Override
protected void onStop() {
super.onStop();
if (!finish){
Intent intent = new Intent(this, MainActivity.class);
intent.setAction(QUIT);
PendingIntent pIntent = PendingIntent.getActivity(this, 0, intent, 0);
// build notification
// the addAction re-use the same intent to keep the example short
n = new Notification.Builder(this)
.setContentTitle("Still working")
.setContentText("Still getting data")
.setSmallIcon(R.drawable.ic)
.setContentIntent(pIntent)
.setAutoCancel(true)
.build();
mNotificationManager.notify(0, n);
}
}
It should reopen the MainActivity, but it is openning a new MainActivity, so I have two. What should I do for just open the same activity closed in OnStop()?
0 comments:
Post a Comment