WEB开发网
开发学院手机开发Android 开发 Android通过AIDL实现下载进程通信 阅读

Android通过AIDL实现下载进程通信

 2012-11-08 19:04:01 来源:WEB开发网   
核心提示:android 下载服务AndroidManifest.xml该layout文件定义了进度条的样式<?xml version="1.0" encoding="utf-8"?><manifest xmlns:android="http://schemas

android 下载服务AndroidManifest.xml
该layout文件定义了进度条的样式

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.obatu.services" android:versionCode="1"
android:versionName="1.0">
<uses-sdk android:minSdkVersion="8" />

<application android:icon="@drawable/icon" android:label="@string/app_name">
<!-- 服务开始 -->
<service android:name="com.obatu.services.DownLoadService">
<intent-filter>
<!-- 这个action就是客户端绑定服务Intent的时候用到的action -->
<action android:name="com.obatu.service.download_service" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</service>
<!-- 服务结束-->
</application>
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
</manifest>
客户端实现
看一个简单的客户端实现,主要实现调用服务这一块,具体的取消下载等操作就自己去想了,反正我已经实现。

客户端和服务端交换数据用到了一个数据结构就是Queue.java和Queue.aidl,而服务通信则用到了IDownLoadService.aidl接口,所以要把这几个类连同包一起拷贝过来。

绑定服务DownLoadActivity.java
该Activity实现点击下载功能

package com.obatu.client.download;

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

Tags:Android 通过 AIDL

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