Hi, Im using the 3 Modules "DownloadService.bas" "HttpJob.bas" "HttpUtils2Service.bas" I make heavy use of them to Download large files! it all works great!
Now Im protecting my app, and making a version that only works on devices, that have the mac number in my database! im using PHP and simply posting the mac address to my server, if its in the database it responds yes, and if not it responds no! (This program is based on examples using the httputils2 lib)
At the moment both programs work well! separately! but im trying to make them into one program.
The Downloader part downloads large files and uses the progress bar (NEEDED) and works exactly how I want so i dont want to change that! (if i use the lib) i lose the progress bar and gain a system icon!)
If I use the modules, my PHP requests give the following error!
looking at the errors! i have changed the code in Sub hc_ResponseSuccess like so!
The problem with that is PHP works fine! but my downloads dont (i just get an icon in the system bar staring my file is downloading! - (I dont want that I want the progress bar!)
My Question is HOW can I have both, the download and progress, and PHP communication?
Thanks
Aidy
Now Im protecting my app, and making a version that only works on devices, that have the mac number in my database! im using PHP and simply posting the mac address to my server, if its in the database it responds yes, and if not it responds no! (This program is based on examples using the httputils2 lib)
At the moment both programs work well! separately! but im trying to make them into one program.
The Downloader part downloads large files and uses the progress bar (NEEDED) and works exactly how I want so i dont want to change that! (if i use the lib) i lose the progress bar and gain a system icon!)
If I use the modules, my PHP requests give the following error!
** Activity (main) Pause, UserClosed = false **
** Activity (main) Create, isFirst = true **
MAC = 58:12:43:A7:B7:54
** Activity (main) Resume **
** Service (httputils2service) Create **
** Service (httputils2service) Start **
Error occurred on line: 46 (httputils2service)
java.lang.RuntimeException: Field: CountingStream not found in: java.lang.Object
at anywheresoftware.b4a.shell.Shell$FieldCache.getField(Shell.java:833)
at anywheresoftware.b4a.shell.Shell.setField(Shell.java:581)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:317)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:238)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:121)
at anywheresoftware.b4a.BA$3.run(BA.java:332)
at android.os.Handler.handleCallback(Handler.java:605)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4430)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:792)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:559)
at dalvik.system.NativeStart.main(Native Method)
** Activity (main) Resume **
looking at the errors! i have changed the code in Sub hc_ResponseSuccess like so!
B4X:
Sub hc_ResponseSuccess (Response As HttpResponse, TaskId As Int)
' ************* TEST CODE
Dim job As HttpJob = TaskIdToJob.Get(TaskId)
job.Tag = Response.StatusCode
Response.GetAsynchronously("response", File.OpenOutput(TempFolder, TaskId, False), _
True, TaskId)
' ********** Modified code *************
'Dim cs As CountingOutputStream
'cs.Initialize(File.OpenOutput(TempFolder, TaskId, False))
'Dim j As HttpJob = TaskIdToJob.Get(TaskId)
'Dim jt As JobTag = j.Tag
'jt.CountingStream = cs
'jt.Total = Response.ContentLength
'If jt.Data.url = "" Then
' Log("Job cancelled before downloaded started")
' cs.Close
' End If
' Response.GetAsynchronously("response", cs , _
' True, TaskId)
'**************************************
End Sub
The problem with that is PHP works fine! but my downloads dont (i just get an icon in the system bar staring my file is downloading! - (I dont want that I want the progress bar!)
My Question is HOW can I have both, the download and progress, and PHP communication?
Thanks
Aidy