0
I am in a situation that I need to save the notification even if it is open, at the time of reading the notification I check if it has connection, if it has it opens normally, if it does not have it sends an msg informing that it has no connection, the problem is that the notification has already been opened and it disappears, so I wanted that in case it was saved there, until the user read with connection. How do I do? I want that before clicking on the notification it check if it has connection, if it has not played a msg, and the notification can not disappear. Code :
public void gerarNotificacao() {
NotificationManager nm = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
PendingIntent p = PendingIntent.getActivity(this, 0, new Intent(this,
ReaderNotificacao.class), 0);
NotificationCompat.Builder builder = new NotificationCompat.Builder(
this).setLights(Color.WHITE, 500, 500);
builder.setDefaults(0);
builder.setTicker("Fadire");
builder.setContentTitle("Fadire notificação");
builder.setContentText("Você tem uma nova notícia");
builder.setSmallIcon(R.drawable.icone);
builder.setLargeIcon(BitmapFactory.decodeResource(getResources(),
R.drawable.icone));
builder.setContentIntent(p);
Notification n = builder.build();
n.vibrate = new long[] { 150, 300, 150, 600 };
n.flags = Notification.FLAG_AUTO_CANCEL;
nm.notify(R.drawable.ic_launcher, n);
try {
Uri som = RingtoneManager
.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
Ringtone toque = RingtoneManager.getRingtone(this, som);
toque.play();
} catch (Exception e) {
}
}
Reading activity:
if(verificaConexao())
lerNotificacoes();
else {
Toast.makeText(ReaderNotificacao.this, "Sem conexão, não é possivel ler", 1000).show();
Notification.Builder builder = new Notification.Builder(getApplicationContext());
finish();
}
The Notification you refer to is Android Toast?
– Tony