Search code examples
androidruby-on-railsrubyandroid-permissionsandroid-internet

How to give url in android


I have created a back end in Ruby on Rails and I am using url http://192.168.1.6:3000/products/4.json where my phone is running with ip on the same gateway. http://192.168.1.somethign When I try connecting from android it gives the error unknown host exception. I also tried 10.0.2.2, which gives the same error. i tried running this url from the phone browser, and it says the webpage is not available. The phone is connected to the system using USB, both are in the same network using same wifi, I have also given the uses permission to access internet in the manifest file. How do I give the url now?

It is unable to resolve host, so I'm not mentioning the code, i shall add it if that helps.


Solution

  • After excessive searching and realizing the problem was not with the code but the reason was inability of phone and laptop to communicate properly. Still I could not fathom why? though they were in the same WiFi network. I solved my problem using this method . Putting it here for others reference,

    1) Turn on the hotspot of your android phone

    2) Connect your laptop to that network.(the hotspot).

    3) Check the ipaddress now using ipconfig

    4) Proceed using this ip address