當前位置: 首頁>>代碼示例>>Java>>正文


Java Request.setDestinationUri方法代碼示例

本文整理匯總了Java中android.app.DownloadManager.Request.setDestinationUri方法的典型用法代碼示例。如果您正苦於以下問題:Java Request.setDestinationUri方法的具體用法?Java Request.setDestinationUri怎麽用?Java Request.setDestinationUri使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.app.DownloadManager.Request的用法示例。


在下文中一共展示了Request.setDestinationUri方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: download

import android.app.DownloadManager.Request; //導入方法依賴的package包/類
public void download(DownloadTask task) {
    //TODO better path
    DownloadManager downloadManager = (DownloadManager) UpodsApplication.getContext().getSystemService(Context.DOWNLOAD_SERVICE);
    Uri episodUri = Uri.parse(task.track.getAudeoUrl());
    String trackName = GlobalUtils.getCleanFileName(task.track.getTitle()) + ".mp3";
    String mediaItemName = GlobalUtils.getCleanFileName(task.mediaItem.getName());
    String finalPath = PODCASTS_DOWNLOAD_DIRECTORY + "/" + mediaItemName + "/" + trackName;
    finalPath = Environment.getExternalStorageDirectory() + finalPath;
    Request request = new Request(episodUri);
    request.setAllowedNetworkTypes(Request.NETWORK_MOBILE | Request.NETWORK_WIFI);
    request.setTitle(task.track.getTitle());
    request.setDescription(task.track.getSubTitle());
    request.setDestinationUri(Uri.fromFile(new File(finalPath)));
    task.downloadId = downloadManager.enqueue(request);
    task.filePath = finalPath;
    allTasks.add(task);
    Logger.printInfo(DM_LOG, "Starting download episod " + trackName + " to " + finalPath);
    runProgressUpdater();
}
 
開發者ID:KKorvin,項目名稱:uPods-android,代碼行數:20,代碼來源:DownloadMaster.java

示例2: download

import android.app.DownloadManager.Request; //導入方法依賴的package包/類
/**
 * 下載目標地址數據至SD卡默認目錄
 *
 * @param context 當前環境
 * @param url     地址
 * @return 下載編號
 */
public static final long download(Context context, String url,
                                  String fileName) {
    DownloadManager downloadManager = getDownloadManager(context);
    if (downloadManager != null) {
        Uri uri = Uri.parse(url);
        File file = new File(Environment.getExternalStorageDirectory()
                .getPath() + File.separator + fileName);
        /*
* 判斷文件是否存在,如果存在刪除源文件
*/
        if (file.exists()) {
            file.delete();
        }
        Request request = new Request(uri);
        request.setTitle("正在下載……");
        request.setDestinationUri(Uri.parse(Uri.fromFile(
                Environment.getExternalStorageDirectory()).toString()
                + File.separator + fileName)); // 設置下載後文件存放的位置
        Toast.makeText(context, "開始下載更新包,請稍後……", Toast.LENGTH_LONG).show();
        return downloadManager.enqueue(request);
    }
    return 0;
}
 
開發者ID:WangGanxin,項目名稱:Codebase,代碼行數:31,代碼來源:DownloadUtil.java

示例3: do_download

import android.app.DownloadManager.Request; //導入方法依賴的package包/類
private void do_download() { 
	DownloadManager dm = (DownloadManager) getSystemService(DOWNLOAD_SERVICE);
	for(WikiDBFile wdbf : wiki.getDBFiles()) {
		Request request = new Request(
				Uri.parse(wdbf.getUrl()));
		String destinationPath = new File(
				new File(storage,getString(R.string.DBDir)),
				wdbf.getFilename()).getAbsolutePath();
		request.setDestinationUri(Uri.parse("file://"+destinationPath));
		request.setTitle(wdbf.getFilename());
		dm.enqueue(request);
	}
	downloadbutton.setVisibility(View.GONE);
	stopdownloadbutton.setVisibility(View.VISIBLE);

}
 
開發者ID:conchyliculture,項目名稱:wikipoff,代碼行數:17,代碼來源:WikiAvailableActivity.java

示例4: tempDownloadToSdcard

import android.app.DownloadManager.Request; //導入方法依賴的package包/類
private void tempDownloadToSdcard(Request request) {
	videoUri = Uri.parse(dir_Downloads.toURI() + composedVideoFilename);
    Utils.logger("d", "** NEW ** videoUri: " + videoUri, DEBUG_TAG);
    request.setDestinationUri(videoUri);
    try {
    	enqueue = dm.enqueue(request);
    } catch (IllegalArgumentException e) {
 	Log.e(DEBUG_TAG, "tempDownloadToSdcard: " + e.getMessage());
 	BugSenseHandler.sendExceptionMessage(DEBUG_TAG + "-> tempDownloadToSdcard", e.getMessage(), e);
 } catch (NullPointerException ne) {
 	Log.e(DEBUG_TAG, "callDownloadApk: " + ne.getMessage());
 	BugSenseHandler.sendExceptionMessage(DEBUG_TAG + "-> tempDownloadToSdcard: ", ne.getMessage(), ne);
 	Toast.makeText(this, getString(R.string.error), Toast.LENGTH_LONG).show();
 }catch (SecurityException se) {
 	Log.e(DEBUG_TAG, "callDownloadApk: " + se.getMessage());
 	BugSenseHandler.sendExceptionMessage(DEBUG_TAG + "-> tempDownloadToSdcard: ", se.getMessage(), se);
 	Toast.makeText(this, getString(R.string.error), Toast.LENGTH_LONG).show();
 }
}
 
開發者ID:thatapps,項目名稱:goloader,代碼行數:20,代碼來源:ShareActivity.java

示例5: addDownload

import android.app.DownloadManager.Request; //導入方法依賴的package包/類
@Override
public synchronized long addDownload(File destFolder, String url, boolean wifiOnly, String title) {
    long dmid = -1;

    //Need to check first if the download manager service is enabled
    if(!isDownloadManagerEnabled())
        return dmid;

    // skip if URL is not valid
    if(url == null) {
        // URL is null
        return dmid;
    }
    url = url.trim();
    if (url.length() == 0) {
        // URL is empty
        return dmid;
    }

    logger.debug("Starting download: " + url);

    Uri target = Uri.fromFile(new File(destFolder, Sha1Util.SHA1(url)));
    Request request = new Request(Uri.parse(url));
    request.setDestinationUri(target);
    request.setTitle(title);

    if (wifiOnly) {
        request.setAllowedNetworkTypes(Request.NETWORK_WIFI);
    } else {
        request.setAllowedNetworkTypes(Request.NETWORK_WIFI | Request.NETWORK_MOBILE);
    }

    dmid = dm.enqueue(request);

    return dmid;
}
 
開發者ID:edx,項目名稱:edx-app-android,代碼行數:37,代碼來源:IDownloadManagerImpl.java


注:本文中的android.app.DownloadManager.Request.setDestinationUri方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。