Hi i am using LoopJ lib to get response from server in json. But the problem is that at times i get org.apache.http.conn.ConnectTimeoutException and sometimes it runs fine. I am using the GET method. But when ever i copy and paste the URl to my Browser it runs fine But on the Android device i mostly cant connect to the server what is the problem. What am i doing wrong ?
client.setTimeout(timoutVal);
client.get(
"http://somewebsiteaddress.com/users.php?task=isUserPresent&email="
+ URLEncoder.encode(username) + "&password="
+ URLEncoder.encode(password) + "&licenseKey="
+ URLEncoder.encode(licKey), null,
new AsyncHttpResponseHandler() {
public void onSuccess(String response) {
loading.cancel();
Log.v("web response ", response);
try {
json = new JSONObject(response);
if (json.getBoolean("status")) {
delegate.Validation(
json.getBoolean("isUserPresent"),
json.getBoolean("license"), username,
password, json);
} else {
delegate.invalidLogin();
}
} catch (JSONException e) {
e.printStackTrace();
}
}
@Override
public void onFailure(Throwable arg) {
Log.v("onFailure", arg + "");
loading.cancel();
delegate.InternetErrorDialog();
super.onFailure(arg);
}
});