Hi there,
I am working on a project using Samsung accessory protocol which is usually called “Companion app”. I includes 2 parts:
- Android app to send data.
- Tizen web APIs: watch app to receive and show data.
As provided in Samsung sample apps, I understand that we can send String data like this:
private ServiceConnection mConnectionHandler = null;
...
this.mConnectionHandler = (ServiceConnection) socket;
...
public boolean sendData(final String data) {
boolean retvalue = false;
if (mConnectionHandler != null) {
try {
mConnectionHandler.send(getServiceChannelId(0), data.getBytes());
retvalue = true;
} catch (IOException e) {
e.printStackTrace();
}
addMessage("Sent: ", data);
}
return retvalue;
}
Then, in watch app using Web APIs, I receive data like this:
dataOnReceive = function dataOnReceive (channelId, data) {
var newData;
if (!SAAgent.channelIds[0]) {
createHTML("Something goes wrong...NO CHANNEL ID!");
return;
}
newData = data + " :: " + new Date();
/* Send new data to Consumer */
SASocket.sendData(SAAgent.channelIds[0], newData);
createHTML("Send massage:<br />" +
newData);
};
The above codes work perfectly. But in my case, I need to send a data including 2 parts:
- A String
- An Drawable Icon:
import android.graphics.drawable.Icon;
It seems like the function always considers the data as a simple string:
dataOnReceive = function dataOnReceive (channelId, data) {
newData = data + " :: " + new Date();
So my question is: How to send string and Icon at the same time, how to retrieve and separate them in Web APIs so that I can display a text and an Icon on my watch app? Can we send a json data so that It can be easier to process in Web APIs?
Thank you very much!