編輯:高級開發
2. java接口 --------Java.Net.*
3. apache 接口---------org.apache.http.*
apache提供的HttpCIEnt,實現起來簡單方便:
A: GET方式操作
s
Java代碼
public void get() {
String url = httpUrl + "?text1=" + text1.getText().toString()
+ "&text2=" + text2.getText().toString();
// 創建HttpGet對象
HttpGet request = new HttpGet(url);
// 創建HttpClIEnt對象
HttpClient client = new DefaultHttpClIEnt();
HttpResponse httpResponse = null;
try {
httpResponse = clIEnt.execute(request);
if (httpResponse.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
text3.setText(EntityUtils.toString(httpResponse.getEntity(),
"utf-8"));
}
} catch (ClIEntProtocolException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
public void get() {
String url = httpUrl + "?text1=" + text1.getText().toString()
+ "&text2=" + text2.getText().toString();
// 創建HttpGet對象
HttpGet request = new HttpGet(url);
// 創建HttpClIEnt對象
HttpClient client = new DefaultHttpClIEnt();
HttpResponse httpResponse = null;
try {
httpResponse = clIEnt.execute(request);
if (httpResponse.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
text3.setText(EntityUtils.toString(httpResponse.getEntity(),
"utf-8"));
}
} catch (ClIEntProtocolException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
接上頁
}
}
B:POST方式操作
Java代碼
public void post() {
// 創建HttpPost對象
HttpPost httpRequest = new HttpPost(httpUrl);
// 創建傳遞參數集合
List params = new ArrayList();
params.add(new BasicNameValuePair("text1", text1.getText().toString()));
params.add(new BasicNameValuePair("text2", text2.getText().toString()));
// 設置字符集
try {
HttpEntity entity = new UrlEncodedFormEntity(params, "utf-8");
httpRequest.setEntity(entity);
// 創建連接對象
HttpClient client = new DefaultHttpClIEnt();
// 執行連接
HttpResponse response = clIEnt.execute(httpRequest);
if (response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
text3.setText(EntityUtils.toString(response.getEntity(),
"utf-8"));
}
} catch (UnsupportedEncodingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (ClIEntProtocolException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public void post() {
// 創建HttpPost對象
HttpPost httpRequest = new HttpPost(httpUrl);
// 創建傳遞參數集合
List params = new ArrayList();
params.add(new BasicNameValuePair("text1", text1.getText().toString()));
params.add(new BasicNameValuePair("text2", text2.getText().toString()));
// 設置字符集
try {
HttpEntity entity = new UrlEncodedFormEntity(params, "utf-8");
httpRequest.setEntity(entity);
// 創建連接對象
HttpClient client = new DefaultHttpClIEnt();
接上頁
// 執行連接
HttpResponse response = clIEnt.execute(httpRequest);
if (response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
text3.setText(EntityUtils.toString(response.getEntity(),
"utf-8"));
}
} catch (UnsupportedEncodingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (ClIEntProtocolException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
我們已經介紹了android用戶界面設計模板Dashboard,其實在Dashboard上Andriod用戶界面設計所制作的最初版本為OmniGraffle模板,現在已
android 是Google開發的基於Linux平台的開源手機操作系統,每一個android應用在底層都會對應一個獨立的Dalvik虛擬機實例,其代碼在虛擬機的解釋下
2001年底,沃茲加入:沃茲是蘋果的聯合創始人,他加入 Danger 董事會,是 Danger 興起的標志。當年的新聞稿中引用沃茲的話,“Danger 蘊含了創新技術帶
android開源語言采用了軟件堆層(software stack,又名軟件疊層)的架構,主要分為三部分:底層以Linux核心為基礎,由C語言開發,只提供基本功能,下文