0

I've been given the task to modify an Android app. It uses an API which is on the main server and right now I don't have access to it. In the source code I changed the URL of the API from

private static String URL = "https://website/App_API/index.php";

to

private static String URL = "http://localhost/App_API/index.php";

in order to make a few tests but after the change the application says that "No internet connection is available". Anyone who has any suggestions how to access the local API?

user986959
  • 620
  • 2
  • 7
  • 22

2 Answers2

2

If you are using emulator, try this

private static String URL = "http://10.0.2.2/App_API/index.php";

Here is the explanation.

Community
  • 1
  • 1
Sunny
  • 14,522
  • 15
  • 84
  • 129
0

to access the localhost you have to use ip instead ie

String URL = "http://10.0.2.2/App_API/index.php";

see Network Address Space

Vikas Rathod
  • 374
  • 2
  • 14