KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I am trying to open the browser with a url when the user click on the push notification, i search in stackoverflow and i find this Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(url)); startActivity(browserIntent); but it doesnt work for me, when i put that the notification doesnt appear, i debugged it and it only throw the class file editor no error or anything. this is the code 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); }
Tags (comma-separated)
Save Edits
Cancel