HttpUtils2 Problem

Firpas

Active Member
Licensed User
Longtime User
Hi Erel,
I've a problem with HttpUtils2,
When i make a HttpJob.Download(Url) or PostString(Url, sString),
if the server (url) is down i have the follow error:
java.lang.RuntimeException: java.lang.NullPointerException
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:195)
.....
And the event "JobDone" don´t raise.
With HttpClient and HttpRequest, you have two events:
ResponseError (Response AsHttpResponse, Reason AsString, StatusCode AsInt, TaskId AsInt) and
ResponseSuccess (Response AsHttpResponse, TaskId AsInt)
What's the solution?
Thanks ins advance for your cooperation.
 

Firpas

Active Member
Licensed User
Longtime User
This is not exactly the same problem but is similar.

Regards
 

Attachments

  • HttpUtils2Problem.zip
    11.2 KB · Views: 163
Upvote 0

Firpas

Active Member
Licensed User
Longtime User
Here is the same proyect with the try - catch statement

And this is the result in the log

LogCat connected to: 3934D8D4C28100EC
--------- beginning of /dev/log/main
--------- beginning of /dev/log/system
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
startService: class anywheresoftware.b4a.samples.httputils2.httputils2service
** Service (httputils2service) Create **
** Service (httputils2service) Start **
java.lang.RuntimeException: java.lang.ClassCastException: java.lang.Integer
at anywheresoftware.b4a.keywords.Common$4.run(Common.java:933)
at android.os.Handler.handleCallback(Handler.java:587)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:123)
at android.app.ActivityThread.main(ActivityThread.java:3687)
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:842)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.ClassCastException: java.lang.Integer
at anywheresoftware.b4a.keywords.Common.getComponentBA(Common.java:958)
at anywheresoftware.b4a.keywords.Common.access$0(Common.java:948)
at anywheresoftware.b4a.keywords.Common$4.run(Common.java:880)
... 9 more
 

Attachments

  • HttpUtils2Problem.zip
    11.3 KB · Views: 142
Upvote 0

Firpas

Active Member
Licensed User
Longtime User
If your first question is if i´ve modified HttpUtils2 code
the answer is no.

And i don´t konw what other question
 
Upvote 0

Firpas

Active Member
Licensed User
Longtime User
The second parameter to HttpJob.Initialize is the module that will handle the JobDone event. You should change that line to:
B4X:
Job.Initialize("Job", Me)


Thanks for your help and sorry for my mistake,
Do not know why, but I thought that the second parameter was the id of the task

Thank you again
 
Upvote 0
Top