user986959
user986959

Reputation: 630

ANDROID change of API

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?

Upvotes: 0

Views: 101

Answers (2)

Vikas Rathod
Vikas Rathod

Reputation: 384

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

Upvotes: 0

Sunny
Sunny

Reputation: 14808

If you are using emulator, try this

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

Here is the explanation.

Upvotes: 2

Related Questions