0

I have Client-Server Socket that listen-push messages. Is there a way to get content from Message msg obj and put to setNotificationMessage() to show the message from server like notification message

I get this error

incompatible types: Message cannot be converted to CharSequence
            Message msg = new Message();
            Bundle bundle = new Bundle();
            bundle.putString(BUNDLE_DATA_KEY_VALUE, sb.toString());
            msg.setData(bundle);
            messageHandler.handleMessage(msg);
            setNotificationMessage(msg);
        }
    }


    private void setNotificationMessage(CharSequence message) {
        NotificationCompat.Builder builder = new NotificationCompat.Builder(this, "1");
        builder.setSmallIcon(R.drawable.ic_launcher);
        builder.setContentTitle("Connection status");
        builder.setContentText(message);

        NotificationManagerCompat nm = NotificationManagerCompat.from(this);
        nm.notify(NOTIFICATION_ID, builder.build());
    }
Zoe
  • 27,060
  • 21
  • 118
  • 148
  • `Message.toString()` but seriously, we don't know what is inside and how you wana convert it to string – Selvin Apr 10 '19 at 11:31
  • Message.toString() give it me http://prntscr.com/na0tiw PHP SocketServer, write message. `$msg = $row["message"]. chr(0); socket_write($msgsock, utf8_encode($msg), strlen($msg));` – Valentin Gjorgoski Apr 10 '19 at 11:38

0 Answers0