I send here such data

{ 'title' : "title", 'body' : "http://google.com", } "data" : { "url" : "http://google.com" } 

I try to do this:

 Intent resultIntent = new Intent(Intent.ACTION_VIEW); resultIntent.setData(Uri.parse( remoteMessage.getData().get("url") )); Log.e("msg", remoteMessage.getData().get("url")); PendingIntent pending = PendingIntent.getActivity(this, 0, resultIntent, PendingIntent.FLAG_UPDATE_CURRENT); builder.setContentIntent(pending); 

URL is parsed in D / MainActivity: Key: url Value: http://google.com

but when you click on the notification program opens

This is essentially the entire program code:

 @Override public void onMessageReceived(RemoteMessage remoteMessage) { Uri sound= RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION); NotificationCompat.Builder builder = new NotificationCompat.Builder(this); builder.setSound(sound); NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); // pending implicit intent to view url Intent resultIntent = new Intent(Intent.ACTION_VIEW); resultIntent.setData(Uri.parse( remoteMessage.getData().get("url") )); Log.e("msg", remoteMessage.getData().get("url")); PendingIntent pending = PendingIntent.getActivity(this, 0, resultIntent, PendingIntent.FLAG_UPDATE_CURRENT); builder.setContentIntent(pending); notificationManager.notify(0, builder.build()); } 
  • I don’t know if it’s possible in principle to open a third-party browser right away by clicking on the notification, but you’ll definitely not be bothered to launch a browser in your open activation - YuriySPb
  • did not understand how? the program only displays notifications - John Doe
  • You wrote a program in question. - Yuriy SPb
  • there it was just necessary to add intent-filter and create 1 more activit - John Doe
  • data taken from getIntent () - John Doe

0