What can be wrong when I get a java.nio.BufferUnderflowException in the AsyncStreamsObject Class?
B4X:
Private Sub astream_NewStream (Dir As String, FileName As String)
Dim value As Object
Dim deleteFile As Boolean = True
If waitingForAnotherStream Then
waitingForAnotherStream = False
'this is the second part of the object
Select waitingForType
Case TYPE_BITMAP
value = LoadBitmap(Dir, FileName)
Case TYPE_FILE
value = FileName 'just return the file name
deleteFile = False
End Select
Else
Dim raf As RandomAccessFile
raf.Initialize(Dir, FileName, True)
waitingForKey = raf.ReadObject(raf.CurrentPosition) ' <--- Crashes here
waitingForName = raf.ReadObject(raf.CurrentPosition)
waitingForType = raf.ReadSignedByte(raf.CurrentPosition)
Select waitingForType
Case TYPE_OBJECT
value = raf.ReadObject(raf.CurrentPosition)
raf.Close
Case TYPE_FILE, TYPE_BITMAP
'wait for the second part of the message
waitingForAnotherStream = True
raf.Close
File.delete(Dir, FileName)
Return '<--- return!!!
End Select
End If
asyncstreamsobject_astream_newstream (B4A line: 124)
waitingForKey = raf.ReadObject(raf.CurrentPositi
java.nio.BufferUnderflowException
at java.nio.DirectByteBuffer.getInt(DirectByteBuffer.java:230)
at anywheresoftware.b4a.randomaccessfile.RandomAccessFile.ReadInt(RandomAccessFile.java:137)
at anywheresoftware.b4a.randomaccessfile.RandomAccessFile.readHelper(RandomAccessFile.java:406)
at anywheresoftware.b4a.randomaccessfile.RandomAccessFile.ReadObject(RandomAccessFile.java:395)
at se.iqpd.checkout.plus.asyncstreamsobject._astream_newstream(asyncstreamsobject.java:230)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:187)
at anywheresoftware.b4a.BA$3.run(BA.java:334)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:211)
at android.app.ActivityThread.main(ActivityThread.java:5321)
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:1016)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:811)