Android通过AIDL实现下载进程通信
2012-11-08 19:04:01 来源:WEB开发网核心提示:public boolean onUnbind(Intent intent) {// 解绑,解绑时清理已经取消下载的notificationfor (Iterator<Entry<Integer, Queue>> it = queueList.entrySet().iterator(); it.
public boolean onUnbind(Intent intent) {
// 解绑,解绑时清理已经取消下载的notification
for (Iterator<Entry<Integer, Queue>> it = queueList.entrySet().iterator(); it.hasNext();){
Entry<Integer, Queue> entry = it.next();
Queue queue= entry.getValue();
if(!queue.isCancel()){
nManager.cancel(queue.getId());
}
}
return super.onUnbind(intent);
}
}
android 下载服务DownLoadService使用到的Notification界面:download_progress.xml
该layout文件定义了进度条的样式
// 解绑,解绑时清理已经取消下载的notification
for (Iterator<Entry<Integer, Queue>> it = queueList.entrySet().iterator(); it.hasNext();){
Entry<Integer, Queue> entry = it.next();
Queue queue= entry.getValue();
if(!queue.isCancel()){
nManager.cancel(queue.getId());
}
}
return super.onUnbind(intent);
}
}
android 下载服务DownLoadService使用到的Notification界面:download_progress.xml
该layout文件定义了进度条的样式
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@+id/layout_download"
>
<ImageView android:id="@+id/downloadImg"
android:layout_height="48px"
android:layout_width="48px"
android:src="@android:drawable/stat_sys_download"
android:layout_alignParentLeft="true"
android:layout_marginLeft = "3px"
>
</ImageView>
<ProgressBar android:id="@+id/downloadProgress"
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="fill_parent"
android:layout_marginTop="2px"
android:secondaryProgress="0"
更多精彩
赞助商链接