Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/226.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/firebase/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 如何通过Firebase控制台发送包含自定义数据的通知?_Android_Firebase_Android Notifications_Firebase Cloud Messaging_Firebase Notifications - Fatal编程技术网

Android 如何通过Firebase控制台发送包含自定义数据的通知?

Android 如何通过Firebase控制台发送包含自定义数据的通知?,android,firebase,android-notifications,firebase-cloud-messaging,firebase-notifications,Android,Firebase,Android Notifications,Firebase Cloud Messaging,Firebase Notifications,我必须在通知中发送一个URL,我想在点击通知后,Chrome会立即打开链接。目前,当我单击通知时,它只打开我的应用程序 对于我想要的行为,我必须在代码中实现哪些更改 private void sendNotification(String messageBody, String title) { Intent intent = new Intent(this, MainActivity.class); intent.addFlags(Intent.FLAG_ACTIVITY_CL

我必须在通知中发送一个URL,我想在点击通知后,Chrome会立即打开链接。目前,当我单击通知时,它只打开我的应用程序

对于我想要的行为,我必须在代码中实现哪些更改

private void sendNotification(String messageBody, String title) {
    Intent intent = new Intent(this, MainActivity.class);
    intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
    PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent,
            PendingIntent.FLAG_ONE_SHOT);

    Uri defaultSoundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
    NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this)
            .setSmallIcon(R.drawable.ic_launcher)
            .setContentTitle(title)
            .setContentText(messageBody)
            .setAutoCancel(true)
            .setSound(defaultSoundUri)
            .setContentIntent(pendingIntent);

    NotificationManager notificationManager =
            (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);

    notificationManager.notify(0, notificationBuilder.build());
}
建议:为什么不使用
openwith
功能?我认为问题在于“如何在单击通知时打开另一个应用程序?”