bluemax
bluemax

Reputation: 1

Android Studio connecting to localhost in mobile

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!

Upvotes: 0

Views: 240

Answers (1)

Sudheesh R
Sudheesh R

Reputation: 1775

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.

Upvotes: 1

Related Questions