Open pishguy opened 7 years ago
in main process :
intentDownload
intentPause
intentPauseAll
below codes are part of your background service :
public void download(FileInfo finfo) {
try {
File mDownloadDir = Tools.getDownloadDirectoryFile(finfo.savelocation);
mDownloadDir.mkdir();
final DownloadRequest request = new DownloadRequest.Builder()
.setName(finfo.name)
.setUri(finfo.Link)
.setFolder(mDownloadDir)
.build();
RequestCallBack req = new RequestCallBack(getApplicationContext(),finfo);
mDownloadManager.download(request, finfo.Tag, req);
Log.d(TAG, finfo.Tag);
}catch (Exception e){
e.printStackTrace();
}
}
public static void intentDownload(Context context , FileInfo info) {
Intent intent = new Intent(context, Downloader.class);
intent.setAction(ACTION_DOWNLOAD);
intent.putExtra(EXTRA_TAG, info.Tag);
intent.putExtra(EXTRA_APP_INFO, info);
context.startService(intent);
}
public static void intentPause(Context context, FileInfo info) {
Intent intent = new Intent(context, Downloader.class);
intent.setAction(ACTION_PAUSE);
intent.putExtra(EXTRA_TAG, info.Tag);
context.startService(intent);
}
public static void intentDelete(Context context, FileInfo info ){
Intent intent = new Intent(context, Downloader.class);
intent.setAction(ACTION_DELETE);
intent.putExtra(EXTRA_TAG, info.Tag);
intent.putExtra(EXTRA_APP_INFO, info);
context.startService(intent);
}
public static void intentPauseAll(Context context) {
Intent intent = new Intent(context, Downloader.class);
intent.setAction(ACTION_PAUSE_ALL);
context.startService(intent);
}
i see this methods on service file:
which part of project you are used them?