the below code is used to get the number of datas to be entered next. when i run the rest service in browser i get result {"FetchSecondaryNumberResult":[{"Res":2}]}. when i run the app the get the toast message saying "Unexpected Error occcured! [Most common Error: Device might not be connected to Internet or remote server is not up and running]". i am connected to the net and i use async-http-1.4.4.jar for this app.
please help me to solve this.
AsyncHttpClient fetchSecond=new AsyncHttpClient();
fetchSecond.put("http://pharmamax.solutionsmax.com/PackageMax.svc/FetchSecondaryNumber", params,new AsyncHttpResponseHandler()
{
@Override
public void onSuccess(String response)
{
Toast.makeText(getApplicationContext(), response, Toast.LENGTH_SHORT).show();
try{
JSONObject obj3 = new JSONObject(response);
JSONArray jsonArray3 = obj3.getJSONArray("FetchSecondaryNumberResult");
int length = jsonArray3.length();
if(length!=0)
{
for(int i=0;i<length;i++)
{
JSONObject user = jsonArray3.getJSONObject(i);
number.setText(user.get("Res").toString());
}
}
else
{
Toast.makeText(getApplicationContext(), "no data", Toast.LENGTH_LONG).show();
}
}catch(JSONException e){
Toast.makeText(getApplicationContext(), "Exception", Toast.LENGTH_LONG).show();
}
}
@Override
public void onFailure(int statusCode, Throwable error,String content){
if(statusCode == 404){
Toast.makeText(getApplicationContext(), "Requested resource not found", Toast.LENGTH_LONG).show();
}
else if(statusCode == 500){
Toast.makeText(getApplicationContext(), "Something went wrong at server end", Toast.LENGTH_LONG).show();
}
else{
Toast.makeText(getApplicationContext(), "1", Toast.LENGTH_LONG).show();
Toast.makeText(getApplicationContext(), "Unexpected Error occcured! [Most common Error: Device might not be connected to Internet or remote server is not up and running]", Toast.LENGTH_LONG).show();
}
}
});