I make an application that get some data from server,on my localhost the app work fine,and when I upload server side to real host,I test the new URL (mydomain.comuv.com/get_data.php) in the browser it work,but within my app return "unable to resolve host "mydomain.comuv.com": No address associated with host name" that's the code :
protected Void doInBackground(Void...params){
InputStream is=null;
String result="";
try{
// httpclient=new DefaultHttpClient();
httpclient=Singleton_con.getInstance().getHttpclient();
// httppost= new HttpPost("http://mydomain.comuv.com/image_pull_test/get_image.php");
httppost= Singleton_con.getInstance().getHttppost();
response=httpclient.execute(httppost);
HttpEntity entity = response.getEntity();
is = entity.getContent();
}catch(Exception e){
if(pd!=null)
pd.dismiss(); //close the dialog if error occurs
Log.e("ERROR", e.toString());
}
//convert response to string
try{
BufferedReader reader = new BufferedReader(new InputStreamReader(is,"utf-8"),8);
StringBuilder sb = new StringBuilder();
String line = null;
while ((line = reader.readLine()) != null) {
sb.append(line + "\n");
}
is.close();
result=sb.toString();
}catch(Exception e){
Log.e("ERROR", "Error converting result " + e.toString());
}
//parse json data
try{
records.clear();
Toast.makeText(context,""+result,Toast.LENGTH_LONG).show();
JSONArray jArray =new JSONArray(result);
for(int i=0;i<jArray.length();i++){
JSONObject json_data = jArray.getJSONObject(i);
String record=json_data.getString("title")+"__"+json_data.getString("poster")+"__"+json_data.getDouble("rate");
records.add(record);
}
}
catch(Exception e){
Log.e("ERROR", "Error pasting data "+e.toString());
}
return null;
}
protected void onPostExecute(Void result){
if(pd!=null) pd.dismiss(); //close dialog
if(mSwipeRefreshLayout.isRefreshing())
mSwipeRefreshLayout.setRefreshing(false);
mCustom_adapter.notifyDataSetChanged(); //notify the ListView to get new records
}
}