WEB开发网
开发学院手机开发Android 开发 Android的HTTP通信 XML解析和异步消息处理 阅读

Android的HTTP通信 XML解析和异步消息处理

 2010-02-03 19:10:00 来源:WEB开发网   
核心提示:DownloadManagerAsync.OnDownloadCompleteListener,DownloadManagerAsync.OnDownloadUpdateListener,DownloadManagerAsync.OnDownloadErrorListener {TextView txt;/** Cal

DownloadManagerAsync.OnDownloadCompleteListener,

DownloadManagerAsync.OnDownloadUpdateListener,

DownloadManagerAsync.OnDownloadErrorListener {

TextView txt;

/** Called when the activity is first created. */

@Override

public void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.main);

DownloadManagerAsync manager = new DownloadManagerAsync();

manager.setOnDownloadCompleteListener(this);

manager.setOnDownloadUpdateListener(this);

manager.download("http://files.cnblogs.com/webabcd/Android.rar", "/sdcard/Android.rar");

txt = (TextView) this.findViewById(R.id.txt);

txt.setText("开始下载");

}

public void onDownloadComplete(DownloadManagerAsync manager, Object result) {

txt.setText("下载完成");

}

public void onDownloadUpdate(DownloadManagerAsync manager, int percent) {

txt.setText("下载进度:" + String.valueOf(percent) + "%");

}

public void onDownloadError(DownloadManagerAsync manager, Exception e) {

txt.setText("下载出错");

}

}

上一页  6 7 8 9 10 11 

Tags:Android HTTP 通信

编辑录入:coldstar [复制链接] [打 印]
赞助商链接