/*用户登陆 * 服务器检测用户的账号和密码是否一致,并返回结果 * */ public static Boolean Login(String Account ,String PassWord) { //Step One 从服务器接口中获取当前账号和密码的配对情况 Boolean actionResult=false; String httpUrl="http://221.181.127.43/gointel/UserHandler.ashx?Action=login&Account="+Account+"&PassWord="+PassWord; //httpGet 连接对象 HttpGet httpRequest =new HttpGet(httpUrl); try { //取得HttpClinet对象 HttpClient httpclient=new DefaultHttpClient(); // 请求HttpClient,取得HttpResponse HttpResponse httpResponse=httpclient.execute(httpRequest); //请求成功 if(httpResponse.getStatusLine().getStatusCode()==HttpStatus.SC_OK) { //取得返回的字符串 String strResult=EntityUtils.toString(httpResponse.getEntity()); JSONObject jsonObject = new JSONObject(strResult) ; //获取返回值,并判断是否正确 actionResult=jsonObject.getBoolean("ActionResult"); } } catch(Exception e) { return false; } return actionResult; } |