MultiThreadDownload icon indicating copy to clipboard operation
MultiThreadDownload copied to clipboard

some method on service which part of project used?

Open pishguy opened this issue 6 years ago • 1 comments

i see this methods on service file:

intentDownload
intentPause
intentPauseAll
destory

which part of project you are used them?

pishguy avatar Jul 22 '17 10:07 pishguy

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);
    }

salehmosleh avatar Jan 25 '18 10:01 salehmosleh