How to connect the emulator to the internet?

bcrimmins

New Member
Licensed User
Longtime User
Yep, I'm a noob. Got an app working though but can't test the web services component without being able to muster an internet connection (3g or WiFi) through the emulator. I would appreciate any suggestion on where to find documentation on how to get the emulator to connect to the internet, or a pointer to an example?

Thanks!

:sign0104:
 

bcrimmins

New Member
Licensed User
Longtime User
Thanks, Erel, for your help and for the really fast reply! I must have something wrong with the way I'm using httputils. I'm getting nothing back from a call to HttpUtils.GetString(b4a). I'm trying to stick pretty close to the simple example you provided. All I'm trying to do is dump the contents of the GetString to an EditText view by clicking a button so that I can verify that I'm getting something back... but the length of s ends up equal to zero.
B4X:
Sub Process_Globals

End Sub

Sub Globals
        Dim butTest As Button
   Dim sms_result As EditText
   Dim b4a As String
   Dim s As String

   b4a = "http://www.google.com"

End Sub

Sub Activity_Create(FirstTime As Boolean)
   activity.LoadLayout("xaffle_login")
      
   HttpUtils.CallbackActivity = "Main" 'Current activity name.
   HttpUtils.CallbackJobDoneSub = "JobDone"
   HttpUtils.Download("Job1", b4a)   
End Sub

 Sub JobDone (Job As String)
    If HttpUtils.IsSuccess(b4a) Then
        s = HttpUtils.GetString(b4a)
    End If
End Sub

Sub butTest_Click
  
      sms_result.text = s
 
      Dim y As Int
      y = s.Length
      Msgbox ("length=" & y, "string test")

End Sub
 
Last edited by a moderator:
Upvote 0

bcrimmins

New Member
Licensed User
Longtime User
Good call. IsSuccess is returning false. There is this line in the log:

Error. Url=http://www.google.com Message=java.net.UnknownHostException: Google

Thoughts?
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
This means that you have a connectivity issue.
Maybe this link will be helpful: Android - Emulator internet access - Stack Overflow

I recommend you to use a real device for development. The Android emulator is very slow.
The emulator is good for working with the WYSIWYG designer and for specific tests that require a different version of Android.
 
Upvote 0

bcrimmins

New Member
Licensed User
Longtime User
Thanks, Erel. That sounds like good advice. I'll try to figure out how to get synced with a real device. What's the best resource on the site for understanding that?

Thanks for time!

Bob
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…