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. LI 导航

    HTML: <div class="my_nav"> <ul> <li class="tiao cur" id="ord ...

  2. linux下Rtree的安装

    1. 首先安装依赖libspatialindexhttp://libspatialindex.github.io/ sudo ./configure sudo make sudo make insta ...

  3. Python的subprocess模块

    尝试在Python中运行可执行文件,网上给出的解决方案是: import os os.system("此处填程序路径") 我要运行的程序文件名中有空格,因此果断失败了,查看了一下帮 ...

  4. GNU 网络程序

    ______________________________________________________________________________ | 版权声明 | | 1.本文可以转载.修 ...

  5. 开源java

    http://code.google.com/p/nullpomino/source/checkout http://www.open-open.com/open254058.htm http://w ...

  6. Web NFC API

    W3C Editor's Draft 29 December 2014 This version: http://www.w3.org/2012/nfc/web-api/ Latest publish ...

  7. Journey of Android for Mac

    下了决心要学Java,几个同事都建议我去学Android,自己觉得能做点应用放手机上玩玩也比较有动力. 沈逸有篇文章里面写道: 搞C的看不起搞C++的. 搞C++的看不起搞java的. 搞java的看 ...

  8. 在SystemOut.log中发现HMGR0152W: 检测到CPU 饥饿的消息 <转载>

    今天系统报警了!!!!!顿时人又不好了!!!查看系统日志, 报错如下: Did not receive adequate CPU time slice. Last known CPU usage ti ...

  9. sql server 发布时提示'dbo.sysmergepublications'无效的解决办法

    对数据库进行数据库复制.订阅时经常会出现各种奇怪的问题 如果你对数据库进行多次发布.删除发布操作时可能会提示“dbo.sysmergepublications”无效的问题, 可以使用以下方法解决: U ...

  10. C# DataGridView 导出 Excel(根据Excel版本显示选择不同后缀格式xls或xlsx)

    /// <summary> /// DataGridView导出至Excel,解决问题:打开Excel文件格式与扩展名指定格式不一致 /// </summary> /// &l ...