public void onClick(View v) { // TODO Auto-generated method stub String iGTIN=et.getText().toString(); RequestParams params=new RequestParams(); params.put("iGTIN", iGTIN); fetchSEcondary(params); } }); } public void fetchSEcondary(RequestParams params) { // TODO Auto-generated method stub AsyncHttpClient fetchSecond=new AsyncHttpClient(); fetchSecond.put("http://pharmamax.solutionsmax.com/PackageMax.svc/FetchSecondaryNumber", params,new AsyncHttpResponseHandler(){ 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); //result=user3.getString("Res").toString(); 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(); //e.printStackTrace(); } } 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(), "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(); } } });
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)