当前位置: 首页>>代码示例>>Java>>正文


Java Request.setDestinationInExternalPublicDir方法代码示例

本文整理汇总了Java中android.app.DownloadManager.Request.setDestinationInExternalPublicDir方法的典型用法代码示例。如果您正苦于以下问题:Java Request.setDestinationInExternalPublicDir方法的具体用法?Java Request.setDestinationInExternalPublicDir怎么用?Java Request.setDestinationInExternalPublicDir使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.app.DownloadManager.Request的用法示例。


在下文中一共展示了Request.setDestinationInExternalPublicDir方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: downloadIssue

import android.app.DownloadManager.Request; //导入方法依赖的package包/类
public void downloadIssue() {
    if(!this.canDisplayPdf(getActivity())) {
        Toast.makeText(getActivity(), getActivity().getString(R.string.pdf_reader_required), Toast.LENGTH_LONG).show();
        return;
    }
    
    String file = issue.getId() + ".pdf";
    File magPiFolder = new File (Environment.getExternalStorageDirectory().getAbsolutePath() + "/" + Config.ISSUE_FOLDER);
    magPiFolder.mkdirs();
    File pdf = new File (Environment.getExternalStorageDirectory().getAbsolutePath() + "/" + Config.ISSUE_FOLDER, file);
    if(pdf.exists() && !isDownloading(issue.getPdfUrl())) {
        Intent intentPdf = new Intent(Intent.ACTION_VIEW);
        intentPdf.setDataAndType(Uri.fromFile(pdf), "application/pdf");
        startActivity(intentPdf);
    } else if (!isDownloading(issue.getPdfUrl())) {
    	menu.findItem(R.id.menu_view).setVisible(false);
    	menu.findItem(R.id.menu_cancel_download).setVisible(true);
        Request request = new Request(Uri.parse(issue.getPdfUrl()));
        request.setAllowedNetworkTypes(DownloadManager.Request.NETWORK_WIFI | DownloadManager.Request.NETWORK_MOBILE);
        request.setTitle(getActivity().getString(R.string.app_name) + " n�" + issue.getId());
        request.setDescription(getActivity().getString(R.string.download_text) + " n�" + issue.getId());
        request.setDestinationInExternalPublicDir(Config.ISSUE_FOLDER, file);
        dm.enqueue(request);
    }
}
 
开发者ID:astagi,项目名称:magpi-android,代码行数:26,代码来源:IssueDetailsFragment.java

示例2: enqueue

import android.app.DownloadManager.Request; //导入方法依赖的package包/类
public long enqueue(String uri, String name, int epi, String vid){
	Request request = new Request(Uri.parse(uri));
	request.setAllowedNetworkTypes(Request.NETWORK_WIFI);
	String externd = uri.substring(uri.lastIndexOf('.'));
	String file = name;
	String dir = "NetVideo" ;
	if(epi != 0){
		file += epi;
		dir = dir + "/" + name;
	}
	request.setTitle(file);
	request.setDestinationInExternalPublicDir(dir, file + "." + externd);
	request.setMimeType("media/video");
	request.setDescription(vid);
	return mDownloadManager.enqueue(request);
}
 
开发者ID:xiaoma1219,项目名称:netkuu.player,代码行数:17,代码来源:DownloadManager.java

示例3: createDownloadRequest

import android.app.DownloadManager.Request; //导入方法依赖的package包/类
private Request createDownloadRequest(String url, String fileName,
		String downloadTitle) {

	Request request = new Request(Uri.parse(url));
	Environment.getExternalStoragePublicDirectory(
			Environment.getExternalStorageDirectory()
					+ VersionParserHelper.UPDATER_FOLDER).mkdirs();

	request.setDestinationInExternalPublicDir(
			VersionParserHelper.UPDATER_FOLDER, fileName);
	request.setAllowedNetworkTypes(DownloadManager.Request.NETWORK_WIFI);
	request.setAllowedOverRoaming(false);

	request.setTitle(downloadTitle);

	return request;
}
 
开发者ID:Kwamecorp,项目名称:Fairphone,代码行数:18,代码来源:FairphoneUpdater.java

示例4: createDownloadRequest

import android.app.DownloadManager.Request; //导入方法依赖的package包/类
private Request createDownloadRequest(String url, String fileName) {

	    
		Request request = new Request(Uri.parse(url));
		Environment.getExternalStoragePublicDirectory(
				Environment.getExternalStorageDirectory()
						+ VersionParserHelper.UPDATER_FOLDER).mkdirs();

		request.setDestinationInExternalPublicDir(
				VersionParserHelper.UPDATER_FOLDER, fileName);
		request.setAllowedNetworkTypes(DownloadManager.Request.NETWORK_WIFI);
		request.setAllowedOverRoaming(false);
		
		Resources resources = getApplicationContext().getResources();
		request.setTitle(resources.getString(R.string.downloadUpdateTitle));

		return request;
	}
 
开发者ID:Kwamecorp,项目名称:Fairphone,代码行数:19,代码来源:UpdaterService.java

示例5: createDownloadRequest

import android.app.DownloadManager.Request; //导入方法依赖的package包/类
private Request createDownloadRequest(String url, String fileName) {

		Request request = new Request(Uri.parse(url));
		Environment.getExternalStoragePublicDirectory(
				Environment.DIRECTORY_DOWNLOADS).mkdirs();

		request.setDestinationInExternalPublicDir(
				Environment.DIRECTORY_DOWNLOADS, fileName);
		request.setAllowedNetworkTypes(DownloadManager.Request.NETWORK_WIFI);
		request.setAllowedOverRoaming(false);

		String download = mContext.getResources().getString(
				R.string.google_apps_download_title);
		request.setTitle(download);

		return request;
	}
 
开发者ID:Kwamecorp,项目名称:Fairphone,代码行数:18,代码来源:GappsInstallerHelper.java

示例6: createDownloadRequest

import android.app.DownloadManager.Request; //导入方法依赖的package包/类
private Request createDownloadRequest(String url, String fileName) {

		Request request = new Request(Uri.parse(url));
		Environment.getExternalStoragePublicDirectory(
				Environment.DIRECTORY_DOWNLOADS).mkdirs();

		request.setDestinationInExternalPublicDir(
				Environment.DIRECTORY_DOWNLOADS, fileName);
		request.setAllowedNetworkTypes(DownloadManager.Request.NETWORK_WIFI );
		request.setAllowedOverRoaming(false);
		

		String download = mContext.getResources().getString(
				R.string.google_apps_download_title);
		request.setTitle(download);

		return request;
	}
 
开发者ID:kimhansen,项目名称:Fairphone---DEPRECATED,代码行数:19,代码来源:GappsInstallerHelper.java

示例7: onClick

import android.app.DownloadManager.Request; //导入方法依赖的package包/类
public void onClick(View view) {
    dm = (DownloadManager) getSystemService(DOWNLOAD_SERVICE);
    Request request = new Request(
            Uri.parse(urlET.getText().toString()));
    Log.v("MapActivity", Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS).getAbsolutePath());
    request.setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS,
            "baseline.mbtiles");
    enqueue = dm.enqueue(request);   
}
 
开发者ID:takyonxxx,项目名称:Flight-Computer-Android-Flightradar24,代码行数:10,代码来源:DownloadActivity.java

示例8: downloadFfmpeg

import android.app.DownloadManager.Request; //导入方法依赖的package包/类
private void downloadFfmpeg() {
	String link = getString(R.string.ffmpeg_download_dialog_msg_link, cpuVers);

	Utils.logger("d", "FFmpeg download link: " + link, DEBUG_TAG);
	
       Request request = new Request(Uri.parse(link));
       request.setDestinationInExternalFilesDir(nContext, null, ffmpegBinName);
       request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE);
       request.setVisibleInDownloadsUi(false);
       request.setTitle(getString(R.string.ffmpeg_download_notification));
       dm = (DownloadManager) getSystemService(DOWNLOAD_SERVICE);
       try {
       	enqueue = dm.enqueue(request);
       } catch (IllegalArgumentException e) {
    	Log.e(DEBUG_TAG, "downloadFfmpeg: " + e.getMessage());
    	Toast.makeText(this,  this.getString(R.string.no_downloads_sys_app), Toast.LENGTH_LONG).show();
    	BugSenseHandler.sendExceptionMessage(DEBUG_TAG + "-> downloadFfmpeg", e.getMessage(), e);
    } catch (SecurityException se) {
    	request.setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS, ffmpegBinName);
    	enqueue = dm.enqueue(request);
    	DIR = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS).getAbsolutePath();
    	BugSenseHandler.sendExceptionMessage(DEBUG_TAG + "-> downloadFfmpeg", se.getMessage(), se);
    } catch (NullPointerException ne) {
    	Log.e(DEBUG_TAG, "callDownloadApk: " + ne.getMessage());
    	BugSenseHandler.sendExceptionMessage(DEBUG_TAG + "-> callDownloadApk: ", ne.getMessage(), ne);
    	Toast.makeText(this, getString(R.string.error), Toast.LENGTH_LONG).show();
    }
       
	ffmpegBinObserver = new Observer.YtdFileObserver(DIR);
       ffmpegBinObserver.startWatching();
}
 
开发者ID:thatapps,项目名称:goloader,代码行数:32,代码来源:FfmpegDownloadService.java

示例9: downloadFile

import android.app.DownloadManager.Request; //导入方法依赖的package包/类
private void downloadFile() {
    // Guess file name from metadata
    fileName = URLUtil.guessFileName(downloadUrl, downloadContentDisposition, downloadMimeType);
    Request request = new Request(Uri.parse(downloadUrl));

    // Make media scanner scan this file so that other apps can use it.
    request.allowScanningByMediaScanner();

    // show notification when downloading and after download completes
    request.setNotificationVisibility(
            Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED
    );

    // Set the directory where to save the file
    Log.d("ficsaveM/filePath", Environment.DIRECTORY_DOCUMENTS + "/" + fileName);
    request.setDestinationInExternalPublicDir(
            Environment.DIRECTORY_DOCUMENTS, fileName);

    request.setMimeType(downloadMimeType);
    request.setTitle(fileName);

    // Set headers needed to download the file
    String cookies = CookieManager.getInstance().getCookie(downloadUrl);
    request.addRequestHeader("cookie", cookies);
    request.addRequestHeader("User-Agent", downloadUserAgent);

    fileDownloadId = mDownloadManager.enqueue(request);
    Log.d("ficsaveM/DownloadStartd", "fileID: " + fileDownloadId + ", fileName: " + fileName);
    Toast.makeText(mContext, R.string.downloading_file_toast_msg, //To notify the Client that the file is being downloaded
            Toast.LENGTH_LONG).show();

    mGTracker.send(new HitBuilders.EventBuilder()
            .setCategory(DOWNLOAD_LISTENER_CATEGORY)
            .setAction("Download Enqueued")
            .setLabel(FILE_LABEL + fileName)
            .setValue(1)
            .build());
    Bundle bundle = new Bundle();
    bundle.putString("File", fileName);
    mFTracker.logEvent("DownloadEnqueued", bundle);
}
 
开发者ID:xRahul,项目名称:FicsaveMiddleware,代码行数:42,代码来源:FicsaveDownloadListener.java

示例10: run

import android.app.DownloadManager.Request; //导入方法依赖的package包/类
@Override
public Void run(JobContext jc) {
	try {
		if (checkDownloadRunning())
			return null;
		if (checkApkExist()) {
			Intent installApkIntent = new Intent();
			installApkIntent.setAction(Intent.ACTION_VIEW);
			installApkIntent.setDataAndType(
					Uri.parse(Preferences.getDownloadPath(mContext)),
					"application/vnd.android.package-archive");
			installApkIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK
					| Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
			mContext.startActivity(installApkIntent);
		} else {
			String apkName = mContext.getPackageName()
					+ System.currentTimeMillis() + Constants.APK_SUFFIX;
			// 系统下载程序
			final DownloadManager downloadManager = (DownloadManager) mContext
					.getSystemService(mContext.DOWNLOAD_SERVICE);

			Long recommendedMaxBytes = DownloadManager
					.getRecommendedMaxBytesOverMobile(mContext);

			// 可以在移动网络下下载
			if (recommendedMaxBytes == null
					|| recommendedMaxBytes.longValue() > MAX_ALLOWED_DOWNLOAD_BYTES_BY_MOBILE) {
				allowMobileDownload = true;
			}

			Uri uri = Uri.parse(mUpgradeInfo.getUrl());

			final Request request = new Request(uri);

			request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED);
			request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED);

			int NETWORK_TYPE = DownloadManager.Request.NETWORK_WIFI;
			if (allowMobileDownload) {
				NETWORK_TYPE |= DownloadManager.Request.NETWORK_MOBILE;
			}
			request.setAllowedNetworkTypes(NETWORK_TYPE);
			request.allowScanningByMediaScanner();
			request.setShowRunningNotification(true);
			request.setVisibleInDownloadsUi(true);
			request.setDestinationInExternalPublicDir(
					Environment.DIRECTORY_DOWNLOADS, apkName);
			PackageManager packageManager = mContext.getPackageManager();
			ApplicationInfo applicationInfo = packageManager
					.getApplicationInfo(mContext.getPackageName(), 0);
			Log.i("liweiping",
					"appName = "
							+ packageManager
									.getApplicationLabel(applicationInfo));
			request.setTitle(packageManager
					.getApplicationLabel(applicationInfo));
			request.setMimeType("application/vnd.android.package-archive");

			// id 保存起来跟之后的广播接收器作对比
			long id = downloadManager.enqueue(request);

			long oldId = Preferences.getDownloadId(mContext);
			if (oldId != -1) {
				downloadManager.remove(oldId);
			}

			Preferences.removeAll(mContext);
			Preferences.setDownloadId(mContext, id);
			Preferences.setUpgradeInfo(mContext, mUpgradeInfo);
			Preferences.setDownloadStatus(mContext,
					Constants.DOWNLOAD_STATUS_RUNNING);
		}
	} catch (Exception e) {
		e.printStackTrace();
	}
	return null;
}
 
开发者ID:way1989,项目名称:WayHoo,代码行数:78,代码来源:DownloadNewVersionJob.java


注:本文中的android.app.DownloadManager.Request.setDestinationInExternalPublicDir方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。