Hi all,
What we are trying to do is to send an image via xml.
I'm using the CameraExClass to take a picture (max width 1280) and we encode this to B64 (EncodeBtoS). xML-string is created but after a few pictures the application hangs. the XML-string is null. Any thoughts?
The error which is given:
(Line: 278) If (sXMLFile <>"" AND sXML<>"") Then
java.lang.NullPointerException
java.lang.RuntimeException: java.lang.NullPointerException
at anywheresoftware.b4a.shell.Shell.virtualAssets(Shell.java:159)
at anywheresoftware.b4a.shell.Shell.start(Shell.java:91)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:76)
at lmmobile.jds.android.lm_tebezorgen.afterFirstLayout(lm_tebezorgen.java:90)
at lmmobile.jds.android.lm_tebezorgen.access$100(lm_tebezorgen.java:16)
at lmmobile.jds.android.lm_tebezorgen$WaitForLayout.run(lm_tebezorgen.java:76)
at android.os.Handler.handleCallback(Handler.java:587)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:150)
at android.app.ActivityThread.main(ActivityThread.java:4277)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.NullPointerException
at anywheresoftware.b4a.shell.ShellConnector.sendControlMessage(ShellConnector.java:61)
at anywheresoftware.b4a.shell.Shell.virtualAssets(Shell.java:119)
... 14 more
What we are trying to do is to send an image via xml.
I'm using the CameraExClass to take a picture (max width 1280) and we encode this to B64 (EncodeBtoS). xML-string is created but after a few pictures the application hangs. the XML-string is null. Any thoughts?
B4X:
Sub Camera1_PictureTaken (Data() As Byte)
Dim sXMLFile,sTime As String
DataFoto = Data
sTime = Globaal.getTimeNoLimiter
sFotoFilename = iZendingID & "_" & sTime & ".jpg"
camEx.SavePictureToFile(DataFoto, File.DirInternal, sFotoFilename)
camEx.StartPreview 'restart preview
oImageView.Bitmap = LoadBitmap(File.DirInternal,sFotoFilename)
Dim B64 As Base64
camEx.Release
sFile=""
sFile = B64.EncodeBtoS(DataFoto,0,DataFoto.Length-1)
iPressBack = 1
sDate = Globaal.GetDate
sTime = Globaal.GetTime
sLon = (Globaal.GPS_Long/1000000)
sLat = (Globaal.GPS_Lat/1000000)
sOms = ""
sOms = EditText1.Text.Trim
sXML = ""
sXML = "<zending><foto>"
sXML = sXML & "<f01>" & Globaal.PDAID & "</f01>"
sXML = sXML & "<f02>" & Globaal.def_Datum & "</f02>"
sXML = sXML & "<f03>" & Globaal.def_RID & "</f03>"
sXML = sXML & "<f04>" & sTime & "</f04>"
sXML = sXML & "<f05>" & sDate & "</f05>"
sXML = sXML & "<f06>" & iZendingID & "</f06>"
sXML = sXML & "<f07>" & sFotoFilename & "</f07>"
sXML = sXML & "<f08>" & sFile & "</f08>"
sXML = sXML & "<f09>" & sLon & "</f09>" 'sometimes the app fails here
sXML = sXML & "<f10>" & sLat & "</f10>"
sXML = sXML & "<f11>" & sOms & "</f11>"
sXML = sXML & "</foto></zending>"
sTime = Globaal.getTimeNoLimiter
sXMLFile = Globaal.PDAID & "-" & sTime & "-" & iZendingID & ".xml"
If (sXMLFile <>"" AND sXML<>"") Then 'most of the time the application fails at "sXML<>"" "
File.WriteString(Globaal.Map_Foto, sXMLFile, sXML)
iPressBack = 0
ProgressDialogHide
camEx.Release
Activity.Finish
Else
iPressBack = 0
ProgressDialogHide
ToastMessageShow("Bestandsopbouw mislukt. Probeer nogmaals.", True)
End If
End Sub
The error which is given:
(Line: 278) If (sXMLFile <>"" AND sXML<>"") Then
java.lang.NullPointerException
java.lang.RuntimeException: java.lang.NullPointerException
at anywheresoftware.b4a.shell.Shell.virtualAssets(Shell.java:159)
at anywheresoftware.b4a.shell.Shell.start(Shell.java:91)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:76)
at lmmobile.jds.android.lm_tebezorgen.afterFirstLayout(lm_tebezorgen.java:90)
at lmmobile.jds.android.lm_tebezorgen.access$100(lm_tebezorgen.java:16)
at lmmobile.jds.android.lm_tebezorgen$WaitForLayout.run(lm_tebezorgen.java:76)
at android.os.Handler.handleCallback(Handler.java:587)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:150)
at android.app.ActivityThread.main(ActivityThread.java:4277)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.NullPointerException
at anywheresoftware.b4a.shell.ShellConnector.sendControlMessage(ShellConnector.java:61)
at anywheresoftware.b4a.shell.Shell.virtualAssets(Shell.java:119)
... 14 more