Android的HTTP通信 XML解析和异步消息处理
2010-02-03 19:10:00 来源:WEB开发网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("下载出错");
}
}
更多精彩
赞助商链接