0

I just wanted to ask how to connect to the localhost when the app is installed in mobile? I tried installing the apk of the android app in my mobile phone instead of the emulator of android studio. My app has a login and register activity. In the emulator, I'm able to register and login while I cannot register and login using my phone. Thanks in advance for the answer!

  • 2
    Possible duplicate of [Accessing webserver running within Eclipse from outside the workstation](https://stackoverflow.com/questions/1621796/accessing-webserver-running-within-eclipse-from-outside-the-workstation) – TmTron Nov 14 '17 at 13:48
  • 2
    Possible duplicate of [How do I connect to this localhost from another computer on the same network?](https://stackoverflow.com/questions/9682262/how-do-i-connect-to-this-localhost-from-another-computer-on-the-same-network) – melanzane Nov 14 '17 at 13:49
  • Edit your question and add the new changes you have attempted so far. – Sudheesh R Nov 14 '17 at 15:18

1 Answers1

1

There are a lot of answers exist, but in simple follow the steps below.

  1. First try to connect both your pc and mobile devices in the same network.

  2. Then find the ip of your pc (run ipconfig in command prompt if you are using a pc).

  3. Place this ip as your base url in your app and use register/login endpoints as per your need.

    For eg: http://your.ip.here/register.php like this > (http://192.168.0.2/register.php)

  4. Now run the app, it'll connect to the above said ip.

Community
  • 1
  • 1
Sudheesh R
  • 1,767
  • 3
  • 23
  • 43
  • 1
    No offense but sometimes I'm really baffled how many people develop network apps without knowing any networking basics like this!? – xander Nov 14 '17 at 13:58
  • 1
    I think they don't like to study the basics first. In my experience a good developer should be a good learner too. – Sudheesh R Nov 14 '17 at 14:05