Android带参数链接请求服务器
来源:互联网 发布:土巴兔云设计软件 编辑:程序博客网 时间:2024/06/06 02:36
public void taste() {//设默认值SharedPreferences.Editor editor = this.getSharedPreferences("setting", 0).edit();editor.putString("isTaste", "1");editor.putString("customerId", "1219");editor.putString("userAccount", "admin");editor.putString("password", "123456");editor.putString("accountType", "1");editor.commit();//要访问的服务地址String url = "http://www.gpsonline.cn/mobile/CheckAccount.aspx";//POST方式 HttpPost request = new HttpPost(url);//post参数值 List<NameValuePair> params = new ArrayList<NameValuePair>(); params.add(new BasicNameValuePair("customerId", "1219")); params.add(new BasicNameValuePair("userAccount", "admin")); params.add(new BasicNameValuePair("password", "123456")); params.add(new BasicNameValuePair("accountType", "1")); try { //添加post参数值HttpEntity entity = new UrlEncodedFormEntity(params, "UTF-8"); request.setEntity(entity);//开始访问 HttpClient client = new DefaultHttpClient(); HttpResponse response = client.execute(request);//响应为成功 if (response.getStatusLine().getStatusCode() == 200) { clear(); //获得返回内容 String result = EntityUtils.toString(response.getEntity());//将返回值转为JSON JSONObject json = new JSONObject(result); JSONArray groups = json.optJSONArray("groups"); createGroupAndVehicle(groups, "0"); //打开Activity并把JSON值传过去 Intent intent = new Intent(); intent.setClass(LoginTabActivity.this, GPSMapActivity.class); intent.putExtra("groupId", "0"); startActivity(intent); } } catch (Exception e) { Log.e("e", e.getMessage()); }}
- Android带参数链接请求服务器
- android - Volley框架请求获取Cookie和带Cookie请求链接和带参数Params
- android okhttp get 请求带参数
- url 带参数请求
- 解决android http请求带中文参数乱码问题
- Android使用volley发送带参数的post请求
- Android中使用Post带参数请求的方法
- Android中的http带参数网络请求,GET和POST
- perl post 请求带参数
- post请求带公共参数
- Android 图片(文件--带参数)批量上传到服务器
- android发送http post请求函数带参数带返回数据 静态类 源码
- 向服务器发送请求参数
- 获取JS链接带的参数
- 如何取链接带的参数
- TP5 url链接(带参数)的写法
- android设置post请求服务器时参数的设置以及JSON参数的设置
- android链接服务器
- struts2.2 json配置
- iOS的日历控件 开源代码整理
- 使用hook 拦截消息
- 增加列、列改主键、递增填充空列测试-sqlserver2008201203230953
- Android Prelink实现的源码分析
- Android带参数链接请求服务器
- opencv中的矩阵操作
- 黑马程序员-SQL
- 详细注解八皇后问题
- 【编程之美】3.9已知先序和中序遍历,求后序遍历+POJ-2255
- fedora 16 配置rsh单机环境
- 调用系统的可执行文件
- 项目经理自救 四两拨千斤给领导施加压力<转载>
- 2012-03-23