資源簡介
Android客戶端實現與服務器通信
代碼片段和文件信息
package?com.test;
import?java.io.BufferedReader;
import?java.io.DataOutputStream;
import?java.io.InputStreamReader;
import?java.net.HttpURLConnection;
import?java.net.URL;
import?java.net.URLDecoder;
import?java.net.URLEncoder;
import?android.app.Activity;
import?android.graphics.Color;
import?android.os.Bundle;
import?android.view.View;
import?android.widget.*;
public?class?TestActivity?extends?Activity?{
???
private?Button?mButton;
private?TextView?mText;
private?int[]mColors;
private?int?colornum;
/**?Called?when?the?activity?is?first?created.?*/
????@Override
????public?void?onCreate(Bundle?savedInstanceState)?{
????????super.onCreate(savedInstanceState);
????????setContentView(R.layout.main);
/*?本機測試?因為安卓虛擬機把自己當做了主機?所以服務器端的url寫成10.0.2.2?*/
????????String?strUrl=“http://10.0
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2012-04-26?09:06??安卓程序訪問服務器端的小例子\
?????目錄???????????0??2012-04-26?09:03??安卓程序訪問服務器端的小例子\安卓客戶端\
?????文件?????????956??2012-04-26?09:05??安卓程序訪問服務器端的小例子\安卓客戶端\AndroidManifest.xm
?????文件????????1567??2012-04-26?09:05??安卓程序訪問服務器端的小例子\安卓客戶端\TestActivity.java
?????目錄???????????0??2012-04-26?09:03??安卓程序訪問服務器端的小例子\服務器端\
?????文件????????2339??2012-04-26?08:51??安卓程序訪問服務器端的小例子\服務器端\ServletTest.java
?????文件????????1145??2012-04-25?21:43??安卓程序訪問服務器端的小例子\服務器端\web.xm
評論
共有 條評論