How to decode space and Chinese character - android

My server send message through c2dm server
Original msg: This is a string containing 中文 character
But when i receive the message in my android app
Receive: This+is+a+string+containing+%E4%B8%AD%E6%96%87+character
How to decode the message?
Thanks

Construct the response string with UTF-8.Have you tried this?

try this online url decoder
http://meyerweb.com/eric/tools/dencoder/

Related

Decoding payload msg going through lorawan multitech conduit gateway

I managed to get a node to communicate to an android app. The message goes from the node to the gateway. Using node-red the gateway publishes the message to an mqtt broker and I subscribe to the right topic to receive that message on my android app.
Only problem I have now is that I never realized that the msg was encoded and I'm quite lost now. I receive an array of bytes on the app side and I'm not sure what is the next step I have to take to be able to read that message.
Thanks for the help!
You are actually receiving bytes from Node-Red. You could either convert the received bytes into String on your Android or modify your lora input node's data type from Bytes to UTF-8.
I have a function to decode it:
var x = Buffer.from(msg.payload.raw,"base64").toString()
msg.Decrypted = parseFloat(x)
return msg;
In this Instructable i explained how to decode Lora messages in node red
https://www.instructables.com/id/Lora-Temperature-Dashboard/
On a MultiTech Conduit, the message is base64 encoded by the internals of the MTC, then published to the internal mqtt broker at lora//up, so you need to base64 decode it, then do whatever you need to with it. You can use the built in mosquitto applications to subscribe to this topic, or any other mqtt client (paho libraries, etc)

Mosquitto publish message format to android app

I am working on a IoT project where i'm using mosquitto broker to get messages to my android app. But when i receive the published messages on my app, they appear to be in a weird format. how can i get the data in correct format. Do i need to change something in mosquitto configuration.
The data sent: "hello"
Received on app: [B#2df51a89
this is what i use to get the text in onMessageReceived(topic,message)
message.getPayload().toString();
Any help is appreciated.
[UPDATE] - When i publish data FROM mobile app, the data is received perfectly at the subscriber. Vice versa doesn't work.
You've printed out the object representation of the byte array (message payload). The correct thing to have done is to create a new String from the byte array using a known encoding (probably UTF8)
String payload = new String(message.getPayload(), "utf8")
Then print the payload String

GCM send message faulty fonts

I'm creating a JavaServer Faces project to send messages to my Android application as directed in https://github.com/google/gcm.
It works fine when I perform modal messaging in:
public static void main (String [] args) { sendMessage() }
But when I call the method to send messages from the web interface, the message appears in Android with faulty Vietnamese font.
I think the problem lies in the requests send from the server as notification. It seems like they are are properly encoded with the correct parameters. Please make sure that the requests are UTF-8 encoded where spaces are replaced by + symbol.
The URL encoding has a % symbol or a character and a two-character hex value corresponding to a UTF-8 character. This may differ from language to language.
Change to content type to specify the charset=UTF-8 and then encode the request likewise. Follow the instruction on the GCM docs.
The HTTP header must contain the following headers:
Authorization: key=YOUR_API_KEY
Content-Type: application/json for JSON; application/x-www-form-urlencoded;charset=UTF-8 for plain text.

Sending Image to server in android

In android I am trying to send image to the server.I am using Multipart request. But when I add image in format ByteArray to the Multipart UnsupportedEncodingException occurs.
following is my code.
Do I need to add mime type to request.
If possible please post the complete Sample code.
Try converting the Image to Base64 format string and then sending that string to the server.
Here's the link to convert image to base64 format.
And then at server end decode it.
I done it with the use of MultiPartEntity . Added image as byteArrayBody and done the HTTP request.

Is it possible to read and/or modify the SMS header on Android?

I am developing an Android application for 1.6 and above that sends and receives SMS messages through a port.
To send the SMS I am using the method:
SmsManager.sendDataMessage(String destinationAddress, String scAddress, short destinationPort, byte[] data, PendingIntent sentIntent, PendingIntent deliveryIntent)
but have discovered that the byte[] data should contain only the message body. There seems to be no method available to send multi-part data messages and no way of modifying the SMS header (UDH) to specify that the messages is, say, 1 of 3.
I'm having a similar problem on the receiving end when trying to extract the message count information from the SMS I have received through the specified port. I am using SMSMessage.getPdu() to extract a byte[] containing the message header and message body but have no way of extracting the specific information from the header data.
Does anyone know the format the Android platform uses for SMS headers?
You will need to check 3GPP SMS spec. For me, I got the destination port info from 30th and 31st byte.

Categories

Resources