android - 使用 alljoyn 发送数据

标签 android alljoyn

我在使用 alljoyn 转换为字节数组后发送字符串,该字符串也包含图像(在使用 Base64 转换为字符串后)。它工作正常,但在某些图像的情况下会出现以下错误

08-08 18:55:21.158  20724-21095/co.coinflipsrl.infomage E/ALLJOYN﹕ 20.237 ****** ERROR ALLJOYN external          ...oyn_core/src/MsgArg.cc:790 |  0x900d
08-08 18:55:21.159  20724-21095/co.coinflipsrl.infomage E/ALLJOYN_JAVA﹕ 20.238 ****** ERROR ALLJOYN_JAVA external     .../jni/alljoyn_java.cc:11480 |  0x0001
08-08 18:55:21.161  20724-21095/co.coinflipsrl.infomage E/SimpleClient﹕ SimpleInterface.Ping(): org.alljoyn.bus.MarshalBusException: cannot marshal class [B into 'ay'
org.alljoyn.bus.MarshalBusException: cannot marshal class [B into 'ay'
        at org.alljoyn.bus.MsgArg.marshal(MsgArg.java:534)
        at org.alljoyn.bus.MsgArg.marshal(MsgArg.java:556)
        at org.alljoyn.bus.ProxyBusObject.methodCall(Native Method)
        at org.alljoyn.bus.ProxyBusObject.access$300(ProxyBusObject.java:35)
        at org.alljoyn.bus.ProxyBusObject$Handler.invoke(ProxyBusObject.java:264)
        at java.lang.reflect.Proxy.invoke(Proxy.java:397)
        at $Proxy2.Ping(Unknown Source)
        at co.coinflipsrl.infomage.sharing.alljoynshare.ClientFragment$BusHandler.handleMessage(ClientFragment.java:292)
        at android.os.Handler.dispatchMessage(Handler.java:102)
        at android.os.Looper.loop(Looper.java:135)
        at android.os.HandlerThread.run(HandlerThread.java:61)
 Caused by: org.alljoyn.bus.BusException: ER_BUS_BAD_VALUE
        at org.alljoyn.bus.MsgArg.set(Native Method)
        at org.alljoyn.bus.MsgArg.marshal(MsgArg.java:464)


发送代码是:

 sendUiMessage(MESSAGE_PING, msg.obj);
                        byte[] sentObj = (byte[]) msg.obj;
                        Object reply = mSimpleInterface.Ping((byte[]) msg.obj);
                        byte[] receivedObj = (byte[]) reply;
                        if (Arrays.equals(sentObj, receivedObj)) {
                            sendUiMessage(MESSAGE_PING_REPLY, true);
                        } else {
                            sendUiMessage(MESSAGE_PING_REPLY, false);
                        }

接收码为:

 public byte[] Ping(byte[] inStr) {

        sendUiMessage(MESSAGE_PING, inStr);

         //Simply echo the ping message.
        sendUiMessage(MESSAGE_PING_REPLY, inStr);
        return inStr;
    }

    /* Helper function to send a message to the UI thread. */
    private void sendUiMessage(int what, Object obj) {
        mHandler.sendMessage(mHandler.obtainMessage(what, obj));
    }

最佳答案

我认为您的数据为空。 无法通过 alljoyn 发送 null

Object reply = mSimpleInterface.Ping((byte[]) msg.obj);

关于android - 使用 alljoyn 发送数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31893846/

相关文章:

Android建表失败(near "autoincrement": syntax error)?

android - 如何在 Android 中将 bin 文件传输到支持 Alljoyn 的开发板

android - AllJoyn 中的 BUS_BLOCKING_CALL_NOT_ALLOWED 错误

java - Android - EBADF(错误文件号)OnClickInfoMarker

android - 无法更改应用程序图标

android - 长按android webview中的链接时如何打开上下文菜单?

java - ER_BUS_SET_WRONG_SIGNATURE - 通过 Alljoyn 进行 Android 和 Windows 交互

android - 使用没有互联网连接的WiFi连接iOS和Android设备

ios - Alljoyn 支持 iOS 吗

android - 处理双向 1 :m in Green-DAO 的正确方法