Android的HTTP通信 XML解析和异步消息处理
2010-02-03 19:10:00 来源:WEB开发网public interface OnDownloadConnectListener {
void onDownloadConnect(DownloadManagerAsync manager);
}
public void setOnDownloadConnectListener(OnDownloadConnectListener listener) {
mOnDownloadConnectListener = listener;
}
// 定义下载进度更新事件
private OnDownloadUpdateListener mOnDownloadUpdateListener;
public interface OnDownloadUpdateListener {
void onDownloadUpdate(DownloadManagerAsync manager, int percent);
}
public void setOnDownloadUpdateListener(OnDownloadUpdateListener listener) {
mOnDownloadUpdateListener = listener;
}
// 定义下载完成事件
private OnDownloadCompleteListener mOnDownloadCompleteListener;
public interface OnDownloadCompleteListener {
void onDownloadComplete(DownloadManagerAsync manager, Object result);
}
public void setOnDownloadCompleteListener(
OnDownloadCompleteListener listener) {
mOnDownloadCompleteListener = listener;
}
// 定义下载异常事件
private OnDownloadErrorListener mOnDownloadErrorListener;
public interface OnDownloadErrorListener {
void onDownloadError(DownloadManagerAsync manager, Exception e);
}
public void setOnDownloadErrorListener(OnDownloadErrorListener listener) {
mOnDownloadErrorListener = listener;
}
}
调用上面的自定义的 Android 类库
项目上点右键 -> Properties -> Java Build Path -> Projects -> Add 引用上面的类库
Main.java
代码
package com.webabcd.handler;
import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;
import webabcd.util.DownloadManagerAsync;
public class Main extends Activity implements
更多精彩
赞助商链接