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());
}
}

更多相关文章

  1. android接收和发送短信的xml配置
  2. 一个android访问http资源的便捷工具类——HttpHelper
  3. 日拱一卒(十三)
  4. Android跳转intent简单教程
  5. Android跳转intent简单教程
  6. Android自定义对话框(Dialog)位置,大小
  7. Android参数设置父布局集体宽高
  8. mybatisplus的坑 insert标签insert into select无参数问题的解决
  9. Python技巧匿名函数、回调函数和高阶函数

随机推荐

  1. SystemServer
  2. Fedora 12安装Android SDK
  3. android 呼吸灯实现源码
  4. Android中使用 MediaExtractor 和 MediaM
  5. Android(安卓)SDK 4.0.3 开发环境配置及
  6. android am命令
  7. Android 经典示例,初学者的绝好源码资料
  8. shape的使用
  9. Android进入页面默认不弹出软键盘
  10. Android Studio 指定DEBUG和RELEASE版本