Sto cercando di aprire il browser con un URL quando l'utente clicca sulla notifica push, che cerco in StackOverflow e trovo questoBrowser Inaugurazione notifica push
Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
startActivity(browserIntent);
ma doesnt lavoro per me, quando ho messo che la notifica non appare, ho il debug e solo lanciare l'editor di file di classe nessun errore o altro.
Questo è il codice
public void mostrarNotificacion(Context context, String body,String title, String icon, String url,String superior)
{
String ns = Context.NOTIFICATION_SERVICE;
NotificationManager notManager = (NotificationManager) context.getSystemService(ns);
int icono = R.drawable.mydrawable;
CharSequence textoEstado = superior;
long hora = System.currentTimeMillis();
Notification notif = new Notification(icono, textoEstado, hora);
Context contexto = context.getApplicationContext();
CharSequence titulo = title;
CharSequence descripcion = body;
PendingIntent contIntent;
if(url.equalsIgnoreCase("NULL"))
{
Intent notIntent = new Intent(contexto,MainActivity.class);
contIntent = PendingIntent.getActivity(
contexto, 0, notIntent, 0);
}
else
{
// Intent i = new Intent(Intent.ACTION_VIEW);
//i.setData(Uri.parse(url));
// contIntent = PendingIntent.getActivity(contexto, 0, i, 0);
Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
startActivity(browserIntent);
}
// notif.setLatestEventInfo(contexto, titulo, descripcion, contIntent);
//AutoCancel:
notif.flags |= Notification.FLAG_AUTO_CANCEL;
//send notif
notManager.notify(1, notif);
}
Dove chiami il 'mostrarNotificacion' me THOD? – Eran
Ora funziona grazie a dror fichman, comunque chiamo il metodo onMessage – D4rWiNS
Ecco una soluzione alternativa http://stackoverflow.com/questions/39285006/android-lock-screen-notification-is-notable-to-open- il collegamento –