Hi, Im using OKHTTPUTILS2 with a Wait For; and it is causing me a .GetString error saying 'File Not Found'. I`ve been searching the forum for hours but can`t seem to find a solution. Below is the code I`m using, which I copied from the example:
B4X:
Dim login_job As HttpJob
Dim act As String
If Connected = True Then
ProgressDialogShow("Connecting to license server...")
login_job.Initialize("Login", Me)
login_job.Download2(strURL & "signin2.php", Array As String("user_id", GetDeviceId, "app", "Mob POS"))
Wait For (login_job) JobDone(login_job As HttpJob)
If login_job.Success Then
Dim parser As JSONParser
parser.Initialize(login_job.GetString)
act = parser.NextValue
Log(act)
Occasionally I get the correct value returned from my PHP script; but more often than not nothing is returned and the app crashes with the 'filenotfound' error although it passed the jobsuccess statement.
Here is the error message:
Error occurred on line: 225 (HttpJob)
java.io.FileNotFoundException: /data/user/0/Mobile.POS/cache/1: open failed: ENOENT (No such file or directory)
at libcore.io.IoBridge.open(IoBridge.java:452)
at java.io.FileInputStream.<init>(FileInputStream.java:76)
at anywheresoftware.b4a.objects.streams.File.OpenInput(File.java:214)
at Mobile.POS.httpjob._getstring2(httpjob.java:391)
at Mobile.POS.httpjob._getstring(httpjob.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:176)
at anywheresoftware.b4a.shell.DebugResumableSub$RemoteResumableSub.resume(DebugResumableSub.java:22)
at anywheresoftware.b4a.BA.checkAndRunWaitForEvent(BA.java:250)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:137)
at anywheresoftware.b4a.BA$2.run(BA.java:370)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:7331)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
Caused by: android.system.ErrnoException: open failed: ENOENT (No such file or directory)
at libcore.io.Posix.open(Native Method)
at libcore.io.BlockGuardOs.open(BlockGuardOs.java:186)
at libcore.io.IoBridge.open(IoBridge.java:438)
... 22 more
Ok, I think I may have found the problem myself. I as using the AppUdating library, which is sending off an HTTP query to a file on the server; and I`m also talking to an SQL database. I think the problem was the replies where getting mixed up, so I changed my code to make sure AppUpdating has finished first before talking to the SQL Server.