Android Question error sending bitmap with socket

invocker

Active Member
Type Mymessage(icon() As Byte, name As String,lastname As String)

log
B4X:
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
Call B4XPages.GetManager.LogEvents = True to enable logging B4XPages events.
** Activity (main) Resume **
Connected
Error occurred on line: 42 (Starter)
java.lang.RuntimeException: Cannot serialize object: android.graphics.Bitmap@3e2ef029
    at anywheresoftware.b4a.randomaccessfile.B4XSerializator.writeType(B4XSerializator.java:275)
    at anywheresoftware.b4a.randomaccessfile.B4XSerializator.writeObject(B4XSerializator.java:241)
    at anywheresoftware.b4a.randomaccessfile.B4XSerializator.WriteObject(B4XSerializator.java:121)
    at anywheresoftware.b4a.randomaccessfile.B4XSerializator.ConvertObjectToBytes(B4XSerializator.java:79)
    at b4a.example.starter$ResumableSub_connecttorat.resume(starter.java:309)
    at anywheresoftware.b4a.shell.DebugResumableSub$DelegatableResumableSub.resumeAsUserSub(DebugResumableSub.java:48)
    at java.lang.reflect.Method.invoke(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:372)
    at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:732)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:348)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:255)
    at java.lang.reflect.Method.invoke(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:372)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:146)
    at anywheresoftware.b4a.BA.raiseEvent(BA.java:193)
    at anywheresoftware.b4a.shell.DebugResumableSub$DelegatableResumableSub.resume(DebugResumableSub.java:43)
    at anywheresoftware.b4a.BA.checkAndRunWaitForEvent(BA.java:267)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:139)
    at anywheresoftware.b4a.BA$2.run(BA.java:387)
    at android.os.Handler.handleCallback(Handler.java:739)
    at android.os.Handler.dispatchMessage(Handler.java:95)
    at android.os.Looper.loop(Looper.java:135)
    at android.app.ActivityThread.main(ActivityThread.java:5254)
    at java.lang.reflect.Method.invoke(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:372)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
** Activity (main) Pause event (activity is not paused). **


code
B4X:
If astream.IsInitialized Then
    astream.Close
    End If
    If socket.IsInitialized Then
        socket.Close
    End If
    socket.Initialize("socket")
    socket.Connect(host,port,0)
    Wait For socket_Connected (Successful As Boolean)
    If Successful Then
        Log("Connected")
        astream.InitializePrefix(socket.InputStream,True,socket.OutputStream,"astream")
        Dim mm As Mymessage
        mm.Initialize
        mm.icon=ser.ConvertObjectToBytes(Application.Icon)
        mm.name="myname"
        mm.lastname="mylastname"
        astream.Write(ser.ConvertObjectToBytes(mm))
        Else
            Log("wait for connection..")
    End If
 
Solution
Bitmap / B4XBitmap is not a type supported by B4XSerializator.

You need to first convert it to bytes:

Erel

B4X founder
Staff member
Licensed User
Longtime User
Bitmap / B4XBitmap is not a type supported by B4XSerializator.

You need to first convert it to bytes:
 
Upvote 0
Solution
Top