Hi.
You code creates an error:
Caused by: java.lang.RuntimeException: java.lang.IllegalArgumentException: Illegal character in schemeSpecificPart at index 5: http:\\xxx.xxx.x.xxx\logo.png
Don't use the Window file scheme
\ for the local network URL, stick to the standard HTTP scheme
/.
This code works on an emulator but NOT on my ZTE Blade:
'Activity module
Sub Process_Globals
Dim ImageUrl, PostUrl As String
End Sub
Sub Globals
End Sub
Sub Activity_Create(FirstTime As Boolean)
If FirstTime Then
' 192.168.1.2 is my computer
' my ZTE Blade is always assigned an IP address of 192.168.1.4 on my local network
ImageUrl = "http://192.168.1.2/google.gif"
' ImageUrl = "http://www.b4x.com/android/images/logo2.png"
End If
HttpUtils.CallbackActivity = "Main"
HttpUtils.CallbackJobDoneSub = "JobDone"
HttpUtils.CallbackUrlDoneSub = "UrlDone"
HttpUtils.Download("GET Job1", ImageUrl) 'start
End Sub
Sub Activity_Resume
'Check whether a job has finished while the activity was paused.
If HttpUtils.Complete = True Then JobDone(HttpUtils.Job)
End Sub
Sub UrlDone(Url As String)
'Log(Url & " done")
End Sub
Sub JobDone (Job As String)
If Job = "GET Job1" Then
If HttpUtils.IsSuccess(ImageUrl) Then
Dim b As Bitmap
b = HttpUtils.GetBitmap(ImageUrl)
Activity.SetBackgroundImage(b)
Else
' whats the error?
End If
End If
HttpUtils.Complete = False 'Turn off the complete flag so we won't handle it again if the activity is resumed.
End Sub
When i run that on my Blade the log shows:
Error. Url=http://192.168.1.2/google.gif Message=org.apache.http.conn.ConnectTimeoutException: Connect to /192.168.1.2:80 timed out
I opened my Blade's Android browser and tried to browse to the homepage on my computer using the local IP address (Apache webserver installed on port 80 on my computer).
The Android browser says
Webpage not available
You local network must be configured differently as you said that you could access your computer webserver from the Android browser using the local IP address.
So try your code again using forward slash in URL instead of backslash and see if it works.
If wanted to make the code work on my network i'd make use of my routers built in
Dynamic DNS client.
I have an account with
Managed DNS | Outsourced DNS | Anycast DNS and i can enter that account in my router settings and my dyn.com alias is always updated (by the router) to my current dynamic IP address assigned by my ISP.
So i'd simply change the local network address to my dyn.com alias.
Martin.