57 lines
1.4 KiB
Java
57 lines
1.4 KiB
Java
package com.uiui.zyos.service;
|
|
|
|
import android.app.Service;
|
|
import android.content.Intent;
|
|
import android.os.IBinder;
|
|
import android.util.Log;
|
|
|
|
import com.arialyy.annotations.Download;
|
|
import com.arialyy.aria.core.Aria;
|
|
import com.arialyy.aria.core.task.DownloadTask;
|
|
|
|
public class DownloadService extends Service {
|
|
private static final String TAG = "DownloadService";
|
|
|
|
public DownloadService() {
|
|
}
|
|
|
|
@Override
|
|
public IBinder onBind(Intent intent) {
|
|
return null;
|
|
}
|
|
|
|
@Override
|
|
public void onCreate() {
|
|
super.onCreate();
|
|
Aria.init(this);
|
|
Aria.download(this).register();
|
|
}
|
|
|
|
@Override
|
|
public int onStartCommand(Intent intent, int flags, int startId) {
|
|
return super.onStartCommand(intent, flags, startId);
|
|
}
|
|
|
|
@Override
|
|
public void onDestroy() {
|
|
super.onDestroy();
|
|
}
|
|
|
|
//在这里处理任务执行中的状态,如进度进度条的刷新
|
|
@Download.onTaskRunning
|
|
protected void running(DownloadTask task) {
|
|
Log.e("aria", "正在下载:" + task.getPercent() + ":" + task.getExtendField());
|
|
}
|
|
|
|
@Download.onTaskComplete
|
|
void taskComplete(DownloadTask task) {
|
|
//在这里处理任务完成的状态
|
|
Log.e(TAG, "taskComplete: " + task.getFilePath());
|
|
}
|
|
|
|
@Download.onTaskFail
|
|
void taskFail(DownloadTask task, Exception e) {
|
|
|
|
}
|
|
}
|