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());
}
}
相关文章
- [服务器]脚本:批处理带参数ping命令 发送邮件脚本
- http post带参数请求
- gridview超链接列带多个参数
- 解决vue在ios或android中用webview打开H5链接时#号后面的参数被忽略问题angular同样适用
- 解决Asp.net Web网站发布到服务器上运行时,某界面传参数过多,造成的“此请求的查询字符串的长度超过配置的 maxQueryStringLength 值”错误。
- Volley框架获取Cookie和带Cookie请求链接
- android - Volley框架请求获取Cookie和带Cookie请求链接和带参数Params
- 扩展jquery.pagination支持Ajax及带参数请求
- Postman(一): postman介绍和安装,发送带参数的GET请求
- 请教一个两个页面之间带超链接的参数传递的问题?