向LBS中创建表 中间params问题

I-am-a-psychopath 2014-01-03 03:04:05
public void Onclick_button1(View view)
{
EditText editview1 = (EditText) findViewById(R.id.editview2);
TextView text = (TextView) findViewById(R.id.textView1);
HttpResponse httpResponse = null;
String name = editview1.getText().toString();//此时name是一个string类型
String ak = "v5EmLKE9gcVPK9pXFqar5gfX";
String geotype = "1";
String is_published = "1";
String url = "http://api.map.baidu.com/geodata/v2/geotable/create";
text.setText("1");
int liret = -1;
try
{
DefaultHttpClient localDefaultHttpClient = new DefaultHttpClient();
HttpPost localHttpPost = new HttpPost(url);
List<NameValuePair> params = new ArrayList<NameValuePair>();
params.add(new BasicNameValuePair("name",name));
params.add(new BasicNameValuePair("ak",ak));
params.add(new BasicNameValuePair("geotype",geotype));
params.add(new BasicNameValuePair("is_published",is_published));
//localHttpPost.setEntity(new UrlEncodedFormEntity(params, "UTF-8"));
UrlEncodedFormEntity entity = new UrlEncodedFormEntity(params,"UTF-8");
localHttpPost.setEntity(entity);
HttpResponse localHttpResponse = localDefaultHttpClient.execute(localHttpPost);
String resp = EntityUtils.toString(localHttpResponse.getEntity());
JSONObject jsonObject = new JSONObject(resp);
Log.v("KKHP", resp);
String statuscode = jsonObject.getString("status");
String statusmsg = jsonObject.getString("message");
liret = Integer.parseInt(statuscode);
if(0==liret)
{
return;
}
}
catch (Exception e)
{
e.printStackTrace();
text.setText(e.getMessage());
}
}

通过调试 运行到localHttpPost.setEntity(new UrlEncodedFormEntity(params, "UTF-8"));时
params已经存在数据 共有4个 如图:

但是运行完该语句时 应该params被加载到localHttpPost中 的params中。。
不过运行完之后localHttpPost中的params依然为空

然后继续调试 直接跳到ctach中 求解答
...全文
135 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
I-am-a-psychopath 2014-02-27
  • 打赏
  • 举报
回复
解决了 已经解决了

58,455

社区成员

发帖
与我相关
我的任务
社区描述
Java Eclipse
社区管理员
  • Eclipse
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧