我将数据发布到 php 服务器,它工作正常,然后我得到响应。当我想阅读响应时,它显示了这个错误
Activity has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView@2c2a6848 that was originally added here
从这段代码中读取响应是准确的:
int responseCode = response.getStatusLine().getStatusCode();
switch(responseCode) {
case 200:
HttpEntity entity = response.getEntity();
if(entity != null) {
String responseBody = EntityUtils.toString(entity);
Log.v("this", responseBody);
}
break;
}
这是我的全部代码:
@Override
protected Void doInBackground(Void... params) {
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost(urlpostdata);
try {
List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(1);
nameValuePairs.add(new BasicNameValuePair("message", et.getText().toString()));
httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
HttpResponse response = httpclient.execute(httppost);
int responseCode = response.getStatusLine().getStatusCode();
switch(responseCode) {
case 200:
HttpEntity entity = response.getEntity();
if(entity != null) {
String responseBody = EntityUtils.toString(entity);
Log.v("this", responseBody);
}
break;
}
} catch (IOException e) {
Log.v("this",e.getMessage().toString());
}
return null;
}
@Override
protected void onPostExecute(Void result) {
super.onPostExecute(result);
pDialog.dismiss();
}
}
你能帮我解决吗?