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

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

 2010-02-03 19:10:00 来源:WEB开发网   
核心提示:public interface OnDownloadConnectListener {void onDownloadConnect(DownloadManagerAsync manager);}public void setOnDownloadConnectListener(OnDownloadConnectList

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

上一页  5 6 7 8 9 10 11  下一页

Tags:Android HTTP 通信

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