not working with ICS

porkynet

Member
Licensed User
Longtime User
Hello, I have basic program with this code and it's working.
B4X:
If HttpUtils.IsSuccess(MainUrl) = False Then
   Label1.Text = ""
   MainUrl = "http://somepage.com/id/" & Rnd(1,9188563)
   HttpUtils.Download("GET Job1", MainUrl) 'start
End If
(When url is bad app starts GET Job 1 again searching till it finds correct url.)

Problem starts when i add this to manifest.
B4X:
android:targetSdkVersion="14"

The app just crash, don't know why :(
 

porkynet

Member
Licensed User
Longtime User
This is logfile, but I repeat it works normal with old Android.

B4X:
Starting Job: GET Job1
** Activity (main) Resume **
** Service (httputilsservice) Create **
** Service (httputilsservice) Start **
Error. Url=http://somepage.com/id/3277185 Message=Not Found
httputilsservice_hc_responseerror (java line: 118)
android.os.NetworkOnMainThreadException
   at android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode.java:1084)
   at libcore.io.BlockGuardOs.recvfrom(BlockGuardOs.java:151)
   at libcore.io.IoBridge.recvfrom(IoBridge.java:503)
   at java.net.PlainSocketImpl.read(PlainSocketImpl.java:488)
   at java.net.PlainSocketImpl.access$000(PlainSocketImpl.java:46)
   at java.net.PlainSocketImpl$PlainSocketInputStream.read(PlainSocketImpl.java:240)
   at org.apache.http.impl.io.AbstractSessionInputBuffer.fillBuffer(AbstractSessionInputBuffer.java:103)
   at org.apache.http.impl.io.AbstractSessionInputBuffer.read(AbstractSessionInputBuffer.java:134)
   at org.apache.http.impl.io.ChunkedInputStream.read(ChunkedInputStream.java:161)
   at org.apache.http.conn.EofSensorInputStream.read(EofSensorInputStream.java:159)
   at java.io.InputStreamReader.read(InputStreamReader.java:244)
   at java.io.Reader.read(Reader.java:145)
   at org.apache.http.util.EntityUtils.toString(EntityUtils.java:135)
   at anywheresoftware.b4a.http.HttpClientWrapper$HttpResponeWrapper.GetString(HttpClientWrapper.java:464)
   at anywheresoftware.b4a.samples.httputils.httputilsservice._hc_responseerror(httputilsservice.java:118)
   at java.lang.reflect.Method.invokeNative(Native Method)
   at java.lang.reflect.Method.invoke(Method.java:511)
   at anywheresoftware.b4a.BA.raiseEvent2(BA.java:145)
   at anywheresoftware.b4a.BA$3.run(BA.java:279)
   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:4340)
   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:784)
   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
   at dalvik.system.NativeStart.main(Native Method)
 
Upvote 0

porkynet

Member
Licensed User
Longtime User
Thanks, it's working and not crashing now! :p

But then why my android didn't show ICS style without this?
B4X:
android:targetSdkVersion="14"
 
Upvote 0

mutleyMcladd

New Member
Licensed User
Longtime User
I have the same issue trying to use

Response.GetString("UTF8") with ICS

I want to use the ICS Style as this is an internal app which will always run on the same device (ICS) so have included the following code to the maniefest to force the style.

B4X:
android:targetSdkVersion="14"


I need to parse the resultstring from the following HTTPClient call but including the above forces an error. Is this function not available in ICS ?

B4X:
sub Main_ResponseSuccess (Response As HttpResponse, TaskId As Int)
        Dim resultString As String
   Log("ID=" & TaskId & " Response = "  )
   resultString = Response.GetString("UTF8")
end sub
 
Upvote 0
Top