編輯:關於Android編程
/**
* 采用httpclientGet請求的方式
*
* @param username
* @param password
* @return null表示求得的路徑有問題,text返回請求得到的數據
*/
public static String httpclientGet(String username, String password) {
try {
// 1.打開一個浏覽器
HttpClient client = new DefaultHttpClient();
// 2.輸入地址
String path = "http://172.22.64.156:8080/0001AndroidWebService/LoginServlet?username="
+ URLEncoder.encode(username)
+ "&password="
+ URLEncoder.encode(password);
// 指定請求方式
HttpGet get = new HttpGet(path);
// 3.敲回車
HttpResponse response = client.execute(get);
//獲取返回的碼
int code = response.getStatusLine().getStatusCode();
if (code == 200) {
//獲取返回的信息
InputStream is = response.getEntity().getContent();
String text = StreamUtil.readStream(is);
return text;
} else {
return null;
}
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
Android Service(一)--淺談Service
一.Service簡介service可以說是一個在後台運行的Activity,它不是一個單獨的進程,它只需要應用告訴它要在後台做什麼就可以了,它要實現和用戶的交互的話需要
Android實現二維碼掃描和生成的簡單方法
這裡簡單介紹一下ZXing庫。ZXing是一個開放源碼的,用Java實現的多種格式的1D/2D條碼圖像處理庫,它包含了聯系到其他語言的端口。Zxing可以實現使用手機的內
VideoView播放視頻初體驗
這幾個月一直在忙項目上的事情,所以已經有一段時間不寫博客,抽時間整理下最近的收藏夾,感覺還是有一些新的知識點可以分享的。先從最近的說起,近期項目上需要支持視頻播放功能,雖
android dialog邊框去除白色邊框實現思路及代碼
使用樣式文件,在values 目錄下新建styles.xml文件,編寫如下代碼: 復制代碼 代碼如下: Code highlighting produced by Act