Private Sub btnTransaction_Click
Try
Main.DatafonoPCL.WriteBytes(ser.ConvertObjectToBytes(DoTrans(DoTransaction))) 'problem is here
Catch
Log(LastException)
End Try
End Sub
Private Sub DoTrans(DoTran As DoTransactionTask) As Object()
Return Array(DoTran.transIn1,DoTran.transOut1)
End Sub
Type DoTransactionTask(transIn1 As TransactionIn, transOut1 As TransactionOut)
Private DoTransaction As DoTransactionTask
Private transIn As TransactionIn
Private transOut As TransactionOut
Private Sub B4XPage_Created (Root1 As B4XView)
transOut.Initialize
transOut.cAmount(0) = 0
transOut.cNumAuto(0) = 0
transOut.cCardEndValidityDate(0) = 0
transOut.cCmc7(0) = 0
transOut.cIso2(0) = 0
transOut.cPan(0) = 0
transOut.cCurrencyCode(0) = 0
transOut.cC3Error(0) = 0
transOut.cNumTerm(0) = 0
transOut.cUserData1(0) = 0
transIn.Initialize
transIn.setAmount("20000")
transIn.setCurrencyCode("978")
transIn.setOperation("978")
transIn.setTermNum("58")
transIn.setAuthorizationType("2")
transIn.setCtrlCheque("2")
transIn.setUserData1("Johan Hormaza")
DoTransaction.Initialize
DoTransaction.transIn1 = transIn
DoTransaction.transOut1 = transOut
End Sub
Error occurred on line: 96 (B4XMainPage)
java.lang.RuntimeException: Cannot serialize object: [b4xcollections=null, b4xpages=null, camount=[B@fd2073b
, camount2=[B@d433e58, cautotype=[B@2b08bb1, ccashnum=[B@ba19896
, ccmc7=[B@a4fdc17, ccryptovad=[B@9d9e804, cctrlcheque=[B@d9131ed
, ccurrencycode=[B@e56a822, ccurrencycode2=[B@e6c22b3, ccustomerpresent=[B@f8070
, cdatefinvalidite=[B@65bffe9, cdateinitvalidite=[B@45b246e, cidentcheque=[B@afc370f
, ciso2=[B@ac4339c, cnumauto=[B@3ebb1a5, cnumcontexte=[B@619197a
, cnumdossier=[B@ccf352b, cnumticket=[B@aeed88, coperation=[B@60ac321
, coption=[B@68f5346, cpan=[B@489f907, creadertype=[B@b095a34
, ctendertype=[B@4af705d, ctermnum=[B@7dd5dd2, ctrnsnum=[B@e431ea3
, ctutorialmode=[B@afbe5a0, ctypefacture=[B@6f7b559, cuserdata1=[B@c8f851e
, cuserdata2=[B@6df01ff, ffu=[B@9c9bbcc, main=null
, starter=null]
at anywheresoftware.b4a.randomaccessfile.B4XSerializator.writeType(B4XSerializator.java:275)
at anywheresoftware.b4a.randomaccessfile.B4XSerializator.writeObject(B4XSerializator.java:241)
at anywheresoftware.b4a.randomaccessfile.B4XSerializator.writeList(B4XSerializator.java:269)
at anywheresoftware.b4a.randomaccessfile.B4XSerializator.writeObject(B4XSerializator.java:237)
at anywheresoftware.b4a.randomaccessfile.B4XSerializator.WriteObject(B4XSerializator.java:121)
at anywheresoftware.b4a.randomaccessfile.B4XSerializator.ConvertObjectToBytes(B4XSerializator.java:79)
at java.lang.reflect.Method.invoke(Native Method)
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 anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:144)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:193)
at anywheresoftware.b4a.objects.ViewWrapper$1.onClick(ViewWrapper.java:80)
at android.view.View.performClick(View.java:7297)
at android.view.View.performClickInternal(View.java:7274)
at android.view.View.access$3600(View.java:819)
at android.view.View$PerformClick.run(View.java:28017)
at android.os.Handler.handleCallback(Handler.java:914)
at android.os.Handler.dispatchMessage(Handler.java:100)
at android.os.Looper.loop(Looper.java:225)
at android.app.ActivityThread.main(ActivityThread.java:7564)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:539)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:950)
** Activity (main) Pause event (activity is not paused). **
** Service (starter) Destroy (ignored)**
Yes, but the Type DoTransactionTask object is a TypeYou're right about Arrays of objects. But the objects in your case are class instances, aren't they?
And what do you recommend I do with the TransactionIn and TransactionOut classes to be able to enter them into a Type DoTransactionTask (transIn1 As TransactionIn, transOut1 As TransactionOut)?You can serialize custom types but they cannot hold class intances.
Thanks friend, I based myself precisely on this example ?You seem to be trying to serialize class instances of TransactionIn and ttransactionOut which I don't think B4XSerializator supports. It can only serialize certain types of objects. See the splash screen here
[B4X] Network + AsyncStreams + B4XSerializator
Better implementation, based on B4XPages: https://www.b4x.com/android/forum/threads/b4x-b4xpages-network-asyncstreams-b4xserializator.119011/#content New video tutorial: This is a simple and important example. It demonstrates several good practices related to network...www.b4x.com
Thanks Erel, you mean that they are not classes but Type? Something like that?It depends on all kinds of things. Making them custom types is a good option.
Type TransactionIn(...)
Type TransactionOut(...)
Type DoTransactionTask(transIn1 As TransactionIn, transOut1 As TransactionOut)