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带参数链接请求服务器的更多相关文章

  1. nginx gunicorn 部署flask,带参数链接不可用的现象(笔记)

    微信小程序后台,开启 gunicorn之后屏幕会输出打印结果,一旦关闭shell 带参数链接不可用,只有开启shell才能使用, 一针见血 : 注释掉所有print语句,关闭shell 带参数的链接  ...

  2. Python3.x:访问带参数链接并且获取返回json串

    Python3.x:访问带参数链接并且获取返回json串 示例一: import json import xml.dom.minidom from urllib import request, par ...

  3. requests模块发送带headers的Get请求和带参数的请求

    1.在PyCharm开发工具中新建try_params.py文件: 2.try_params.py文件中编写代码: import requests#设置请求Headers头部header = {&qu ...

  4. IIS 301 重定向 带参数链接

    做QQ的单点登陆,身后后发现,填写的是www.51laugh.cn,修改生效需要3天. 直接把根域做301调整,是目前的最佳解决方案. 1.建立一个新的站点,目录指定到任何一个空文件夹就好了.主机头绑 ...

  5. DataTables手动带参数提交至服务器

    一:参数传递及接收 JavaScript: 黄背景部分为参数传递关键 <script type="text/javascript"> var table; var de ...

  6. C#发送Post请求,带参数,不带参数,指定参数

    1.不带参数发送Post请求 /// <summary> /// 指定Post地址使用Get 方式获取全部字符串 /// </summary> /// <param na ...

  7. C# 发送Post请求(带参数)

    此处内容传输都是用UTF-8编码 1.不带参数发送Post请求 /// <summary> /// 指定Post地址使用Get 方式获取全部字符串 /// </summary> ...

  8. js中ajax连接服务器open函数的另外两个默认参数get请求和默认异步(open的post方式send函数带参数)(post请求和get请求区别:get:快、简单 post:安全,量大,不缓存)(服务器同步和异步区别:同步:等待服务器响应当中浏览器不能做别的事情)(ajax和jquery一起用的)

    js中ajax连接服务器open函数的另外两个默认参数get请求和默认异步(open的post方式send函数带参数)(post请求和get请求区别:get:快.简单 post:安全,量大,不缓存)( ...

  9. Android请求服务器的两种方式--post, get的区别

    android中用get和post方式向服务器提交请求_疯狂之桥_新浪博客http://blog.sina.com.cn/s/blog_a46817ff01017yxt.html Android提交数 ...

随机推荐

  1. STM32学习笔记——USART串口(向原子哥和火哥学习)

    一.USART简介 通用同步异步收发器(USART)提供了一种灵活的方法与使用工业标准NRZ异步串行数据格式的外部设备之间进行全双工数据交换.USART利用分数波特率发生器提供宽范围的波特率选择. S ...

  2. EasyUI篇のico

    所有图标位置: /themes/icons css引用位置: /themes/icon.css 可自行添加16*16的小图片放在icons中,icon.css代码添加即可 例如: .icon-logo ...

  3. instancetype 与 id for Objective-C

    instancetype.id.NSObject的区别 - simalone   1.instancetype只能用于方法的返回类型,而id用处和NSObject *类似. 2.instancetyp ...

  4. JavaScript Application Architecture On The Road To 2015

    JavaScript Application Architecture On The Road To 2015 I once told someone I was an architect. It’s ...

  5. ASP.NET Routing

    ASP.NET Routing Other Versions   ASP.NET routing enables you to use URLs that do not have to map to ...

  6. Hadoop环境搭建-入门伪分布式配置(Mac OS,0.21.0,Eclipse 3.6)

    http://www.linuxidc.com/Linux/2012-10/71900p2.htm http://andy-ghg.iteye.com/blog/1165453 为Mac的MyEcli ...

  7. java学习面向对象之继承

    在我们编写程序的过程当中,会遇到这种情况: 比如现在有一个狗,他的功能有跑,有跳,有吃,有叫,属性有雌雄,大小,颜色等等,同时现在我们也有一个猫,上述功能她也有.这个时候我们写代码的时候,就得分别把上 ...

  8. fdisk磁盘分区

    http://www.cr173.com/html/4336_1.html http://www.51cto.com/art/200602/20328.htm

  9. 「Poetize5」Vani和Cl2捉迷藏

    描述 Description 这片树林里有N座房子,M条有向道路,组成了一张有向无环图.树林里的树非常茂密,足以遮挡视线,但是沿着道路望去,却是视野开阔.如果从房子A沿着路走下去能够到达B,那么在A和 ...

  10. JDK安装配置与升级

    一.jdk1.4卸载 Redhat Enterprise 5 中自带安装了jdk1.4,在安装jdk1.6前,把jdk1.4卸载: 1. 首先查看系统自带的JDK版本: [root@linux ~]# ...