Clique de notificação: atividade já aberta
Eu tenho um aplicativo com notificações que abrem uma determinada atividade se eu clicar nelas. Eu quero isso, se eu clicar na notificação e a atividade já estiver aberta, énão começou de novo, mas apenas trouxe para frente.
Eu pensei que poderia fazer isso com a bandeiraFLAG_ACTIVITY_BROUGHT_TO_FRONT
ouFLAG_ACTIVITY_REORDER_TO_FRONT
, mas continua abrindo de novo, então eu tenho a atividade duas vezes.
Este é o meu código:
event_notification = new Notification(R.drawable.icon,
mContext.getString(R.string.event_notif_message), System.currentTimeMillis());
Intent notificationIntent = new Intent(mContext, EventListActivity.class);
notificationIntent.setFlags(Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT);
sendNotification(event_notification, notificationIntent, mContext.getString(R.string.event_notif_title),
body, Utils.PA_NOTIFICATIONS_ID);
Posso gerenciá-lo com sinalizadores ou devo armazenar uma variável em SharedPreferences para verificar se ela está aberta ou não?
Obrigado!