Ejemplo n.º 1
0
 @Override
 public void handleMessage(Message msg) {
   // TODO Auto-generated method stub
   super.handleMessage(msg);
   try {
     pd.dismiss();
     if (msg.what == 1 && msg.obj != null) {
       JSONObject jo = (JSONObject) msg.obj;
       if (jo.getInt("state") == 1) {
         Utils.setIntConfig(LoginActivity.this, "id", jo.getInt("id"));
         Utils.ShowToast(LoginActivity.this, "认证成功");
         toMainActivity();
       } else {
         Utils.ShowToast(LoginActivity.this, jo.getString("msg"));
       }
     } else {
       Utils.ShowToast(LoginActivity.this, "请求服务器错误");
     }
   } catch (Exception e) {
     // TODO Auto-generated catch block
     e.printStackTrace();
     Utils.ShowToast(LoginActivity.this, "数据错误");
   }
 }
Ejemplo n.º 2
0
 @Override
 public void onClick(View but) {
   // TODO Auto-generated method stub
   if (but.getId() == R.id.login) {
     String n = name.getText().toString();
     String p = pass.getText().toString();
     if ("".equals(n)) {
       Utils.ShowToast(LoginActivity.this, "账号不能为空");
       return;
     }
     if ("".equals(p)) {
       Utils.ShowToast(LoginActivity.this, "密码不能为空");
       return;
     }
     pd = Utils.createProgressDialog(LoginActivity.this);
     pd.setMessage("正在登陆中");
     pd.show();
     List<NameValuePair> lvp = new ArrayList<NameValuePair>();
     lvp.add(new BasicNameValuePair("mapparam.name", n));
     lvp.add(new BasicNameValuePair("mapparam.pass", p));
     RequestThread rt = new RequestThread(loginurl, lvp, handler);
     rt.start();
   }
 }