Android Tutorial HttpUtils - Android web services are now simple!

Status
Not open for further replies.

netchicken

Active Member
Licensed User
Longtime User
Thanks guys

I solved it with NJDudes Words example. There was an easier way afterall!

Basically get the string, cut off the beginning starting with the IndexOf and then cut off the end with the SubString2. (I skipped replacing " with ' as slowing down the program too much)

B4X:
Dim allcode As String
Dim ratingcode As String
   
allcode = Response.GetString("UTF8") 'Get the whole page
            
                     'strip the string back 
ratingcode = allcode.SubString(allcode.IndexOf("class=" & QUOTE & "meter certified numeric " & QUOTE & ">")) ' get the start of the string
            
ratingcode = ratingcode.SubString2(33, ratingcode.IndexOf("</span>")) 'get the end of the string (33 counts forward to get rid of the code from above

lblrating.Text = "Rating = " & ratingcode
Hope this helps others
 

NeoTechni

Well-Known Member
Licensed User
Longtime User
Tried to compile it in 1.80 and now it says

Error description: Unknown type: httpclient
Are you missing a library reference?
Occurred on line: 3
Dim hc As HttpClient

Ah, it unchecked some of the libraries. Weird
 
Last edited:

robh

Member
Licensed User
Longtime User
Error in sub:httputils_internalcheckifcanstart

I'm receiving the attached error when calling a webservice, this is on an existing application that has been in place for approx 2 months, the problem only seems to have surfaced after ugrading to 1.80. Any advice greatly appreciated.

Many thanks in advance.
 

Attachments

  • internalcheckifcanstart.jpg
    20.6 KB · Views: 406

serkanpolat

Member
Licensed User
Longtime User
Erel,
is it possible to get the progress of download?
i mean i want to download a file but i want to show the progress in a progressbar..
how can i do it?
 

robh

Member
Licensed User
Longtime User

Hi Erel, I have downloaded the latest httputils files and I'm now receiving a different error, still related to the internalcheckifcanstart sub, see log below.

Any help greatly appreciated.



Starting Job: Job1


httputils_internalcheckifcanstart (B4A line: 74)
SuccessfulUrls.Initialize



java.lang.NullPointerException
at gary.MeyerPortal.httputils._internalcheckifcanstart(httputils.java:227)
at gary.MeyerPortal.httputils._postbytes(httputils.java:274)
at gary.MeyerPortal.httputils._poststring(httputils.java:398)
at gary.MeyerPortal.activitycheckstock._beginsearch(activitycheckstock.java:351)
at gary.MeyerPortal.activitycheckstock._btnsearch_click(activitycheckstock.java:370)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:491)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:113)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:101)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:97)
at anywheresoftware.b4a.objects.ViewWrapper$1.onClick(ViewWrapper.java:49)
at android.view.View.performClick(View.java:3110)
at android.view.View$PerformClick.run(View.java:11934)
at android.os.Handler.handleCallback(Handler.java:587)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:132)
at android.app.ActivityThread.main(ActivityThread.java:4157)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:491)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:841)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:599)
at dalvik.system.NativeStart.main(Native Method)
java.lang.NullPointerException
 

Inman

Well-Known Member
Licensed User
Longtime User
Is it possible to abort a job (containing a number of urls to download) and start a new one?
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…