Reputation: 3850
AsyncHttpClient client = new AsyncHttpClient();
RequestParams params = new RequestParams();
params.put("username", username);
params.put("password", password);
client.post("192.168.12.4/administration/include/login.php", params, new AsyncHttpResponseHandler() {
@Override
public void onSuccess(String response) {
System.out.println("onSuccess");
Toast.makeText(getApplicationContext(), "MySQL DB has been informed about Sync activity", Toast.LENGTH_LONG).show();
}
@Override
public void onFailure(int statusCode, Throwable error, String content) {
System.out.println("onFailure");
Toast.makeText(getApplicationContext(), "Error Occured", Toast.LENGTH_LONG).show();
}
});
If i have the code above what may cause it to go to public void onFailure(int statusCode, Throwable error, String content) {}
instead of public void onSuccess(String response) {}
Where 192.168.12.4
is the IP of the computer where the localhost is running and where the project what contains login.php
is located
Upvotes: 2
Views: 589
Reputation: 7106
If this is a developer machine (your PC where the emulator is running on) to emulator test, you must change your URL value to
http://10.0.2.2/administration/include/login.php
And don't forget to add this in your manifest file
<uses-permission android:name="android.permission.INTERNET" />
Upvotes: 2
Reputation: 6828
Add a protocol like 'httpor 'https
to the URL
.
Change your URL
from,
192.168.12.4/administration/include/login.php
to
http://192.168.12.4/administration/include/login.php
Upvotes: 2