9 Android Client get 登录方式

/** client get 登录方式
	 * 采用HttpClient get 提交数据
	 * @param usename
	 * @param password
	 * @return 返回null 登录异常
	 * @throws Exception
	 */
	public static String loginByClientGet(String usename,String password)
	{
		try{
		//1. 打开一个浏览器
		HttpClient clien=new DefaultHttpClient();
		//2、 输入地址
		String path="http://192.1.100::8080/web/LoginServlet?username="
				+URLEncoder.encode(usename)
				+"&password"
				+URLEncoder.encode(password);
		HttpGet httpGet=new HttpGet(path);
		//3.敲回车
		HttpResponse response=clien.execute(httpGet);
		int code=response.getStatusLine().getStatusCode();
		if(code==200)
		{
			InputStream is=response.getEntity().getContent();
//			String text=StreamTools.readInputStrams(is);
			
			return ""+"text";
		}
		else
		{
			return null;
		}
	
	 } catch(Exception e)
	 {  e.printStackTrace();
		
	 }
	}
	
		
}

你可能感兴趣的:(9 Android Client get 登录方式)