Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

some method on service which part of project used? #101

Open
pishguy opened this issue Jul 22, 2017 · 1 comment
Open

some method on service which part of project used? #101

pishguy opened this issue Jul 22, 2017 · 1 comment

Comments

@pishguy
Copy link

pishguy commented Jul 22, 2017

i see this methods on service file:

intentDownload
intentPause
intentPauseAll
destory

which part of project you are used them?

@salehmosleh
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants