Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/182.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
Java 如何显示来自其他用户的通知?_Java_Android_Android Layout_Material Design_Chat - Fatal编程技术网

Java 如何显示来自其他用户的通知?

Java 如何显示来自其他用户的通知?,java,android,android-layout,material-design,chat,Java,Android,Android Layout,Material Design,Chat,我在使用android qiscus sdk实现通知时遇到一些问题 我创建类FirebaseService扩展FirebaseMessagingService 然而,当有人和我聊天时,我无法在onMessageReceived中接收到消息。有人能帮我吗?谢谢。您必须使用QiscusFirebaseService进行扩展,并将remoteMessege设置为handleMessageReceived try { NotificationManager notificatio

我在使用android qiscus sdk实现通知时遇到一些问题

我创建类FirebaseService扩展FirebaseMessagingService


然而,当有人和我聊天时,我无法在onMessageReceived中接收到消息。有人能帮我吗?谢谢。

您必须使用QiscusFirebaseService进行扩展,并将remoteMessege设置为handleMessageReceived

try {
            NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
            String title = "" + "";

            PendingIntent intent = PendingIntent.getActivity(context, 0, notificationIntent, PendingIntent.FLAG_UPDATE_CURRENT);

            Uri defaultSound = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);

            if (defaultSound == null) {
                defaultSound = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_RINGTONE);
                if (defaultSound == null) {
                    defaultSound = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_ALARM);
                }
            }

            Notification.Builder builder = new Notification.Builder(context)
                    .setContentTitle(title)
                    .setContentText(message)
                    .setContentIntent(intent)
                    .setSmallIcon(icon)
                    .setLights(Color.BLUE, 20, 80)
                    .setAutoCancel(true)
                    .setSound(defaultSound);

            if (bitmap != null) {
                builder.setLargeIcon(bitmap);
            }

            Notification not = new Notification.BigTextStyle(builder).bigText(message).build();

            if (defaultSound == null) {
                not.defaults |= Notification.DEFAULT_VIBRATE;
                not.defaults |= Notification.DEFAULT_SOUND;
            }

            notificationManager.notify(0, not);
        }
        catch (Exception e) {
            e.printStackTrace();
        }`
QiscusFirebaseService.handleMessageReceivedremoteMessage

举个详细的例子

我希望它能帮助你解决你的问题