如何在android中暂停downloadmanager

时间:2017-04-07 19:58:04

标签: android android-download-manager

我想让用户通过点击按钮暂停下载,或点击下载通知,这是我的代码

downloadbutton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
    if(Allow.equals(true)){

        Uri downloadUri = Uri.parse(DOWNLOAD_FILE);
        DownloadManager.Request request = new DownloadManager.Request(downloadUri);


        request.setAllowedNetworkTypes(DownloadManager.Request.NETWORK_WIFI);
        request.setAllowedOverRoaming(false);

        //request.setNotificationVisibility(Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED);

        id =  downloadManager.enqueue(request);

        //Save the request id
        SharedPreferences.Editor PrefEdit = preferenceManager.edit();
        PrefEdit.putLong(strPref_Download_ID, id);
        PrefEdit.commit();




}

});

0 个答案:

没有答案