Win a copy of The Business Blockchain this week in the Cloud forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Accessing my web server URL fron my phone

 
james frain
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have set up a very simple app to do a GET from a http server I have running on my pc. The GET just responds with a simple hello string. Initially I was having trouble accessing the url from the emulator as I was using localhost:8080 but read on this forum to use 10.0.2.2:8080 and it works fine from my emulator.
I don't know how this works but that's for another day
Now when I connect my phone via the usb, and install the apk file the app starts up fine but it never calls into my server. (I have the internet option switched on and can pull data back from google.co.uk if I use
request.setURI(new URI("http://www.google.co.uk"));
HttpResponse response = client.execute(request); )

Question is how do I talk to my web server running on my pc from the phone. Really stuck on this one and cannot find any worked example anywhere and this would be the final peice in the jigsaw before I get into the coding.
 
Hauke Ingmar Schmidt
Rancher
Posts: 436
2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
james frain wrote:I don't know how this works but that's for another day


If I get your problem correctly then this is the solution. You need to understand how addresses are routed and how hostnames are resolved to use the networking classes correctly. Some addresses are private and can't be reached from "outside" like your phone but only from "inside" the same subnet like the emulator.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic