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


Java Request.setTitle方法代碼示例

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


在下文中一共展示了Request.setTitle方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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: updateClientsWithMetadataUri

import android.app.DownloadManager.Request; //導入方法依賴的package包/類
/**
 * Download latest metadata from the server through DownloadManager for all relevant clients
 *
 * @param context The context for retrieving resources
 * @param metadataUri The client to update
 */
private static void updateClientsWithMetadataUri(
        final Context context, final String metadataUri) {
    Log.i(TAG, "updateClientsWithMetadataUri() : MetadataUri = " + metadataUri);
    // Adding a disambiguator to circumvent a bug in older versions of DownloadManager.
    // DownloadManager also stupidly cuts the extension to replace with its own that it
    // gets from the content-type. We need to circumvent this.
    final String disambiguator = "#" + System.currentTimeMillis()
            + ApplicationUtils.getVersionName(context) + ".json";
    final Request metadataRequest = new Request(Uri.parse(metadataUri + disambiguator));
    DebugLogUtils.l("Request =", metadataRequest);

    final Resources res = context.getResources();
    metadataRequest.setAllowedNetworkTypes(Request.NETWORK_WIFI | Request.NETWORK_MOBILE);
    metadataRequest.setTitle(res.getString(R.string.download_description));
    // Do not show the notification when downloading the metadata.
    metadataRequest.setNotificationVisibility(Request.VISIBILITY_HIDDEN);
    metadataRequest.setVisibleInDownloadsUi(
            res.getBoolean(R.bool.metadata_downloads_visible_in_download_UI));

    final DownloadManagerWrapper manager = new DownloadManagerWrapper(context);
    if (maybeCancelUpdateAndReturnIfStillRunning(context, metadataUri, manager,
            DictionaryService.NO_CANCEL_DOWNLOAD_PERIOD_MILLIS)) {
        // We already have a recent download in progress. Don't register a new download.
        return;
    }
    final long downloadId;
    synchronized (sSharedIdProtector) {
        downloadId = manager.enqueue(metadataRequest);
        DebugLogUtils.l("Metadata download requested with id", downloadId);
        // If there is still a download in progress, it's been there for a while and
        // there is probably something wrong with download manager. It's best to just
        // overwrite the id and request it again. If the old one happens to finish
        // anyway, we don't know about its ID any more, so the downloadFinished
        // method will ignore it.
        writeMetadataDownloadId(context, metadataUri, downloadId);
    }
    Log.i(TAG, "updateClientsWithMetadataUri() : DownloadId = " + downloadId);
}
 
開發者ID:sergeychilingaryan,項目名稱:AOSP-Kayboard-7.1.2,代碼行數:45,代碼來源:UpdateHandler.java

示例3: 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

示例4: getDownloadListener

import android.app.DownloadManager.Request; //導入方法依賴的package包/類
private DownloadListener getDownloadListener() {
    return new DownloadListener() {
        public void onDownloadStart(
            String url,
            String userAgent,
            String contentDisposition,
            String mimetype,
            long contentLength
        ) {
            Uri uri = Uri.parse(url);
            Request request = new Request(uri);
            request.allowScanningByMediaScanner();
            request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED);
            request.setTitle("File download from Mattermost");

            String cookie = CookieManager.getInstance().getCookie(url);
            if (cookie != null) {
                request.addRequestHeader("cookie", cookie);
            }

            DownloadManager dm = (DownloadManager) getSystemService(DOWNLOAD_SERVICE);
            dm.enqueue(request);
       }
    };
}
 
開發者ID:mattermost,項目名稱:mattermost-android-classic,代碼行數:26,代碼來源:WebViewActivity.java

示例5: 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

示例6: 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

示例7: 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

示例8: 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

示例9: 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

示例10: 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

示例11: 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

示例12: startDownload

import android.app.DownloadManager.Request; //導入方法依賴的package包/類
/**
 * Start a download from the given URL.
 * <p>
 * Starting a new download will overwrite any existing download.
 * 
 * @param url the URL to start a download for.
 */
public void startDownload(final String url) {
	LOGGER.debug("Starting download: {}", url);
	final Request request = new DownloadManager.Request(Uri.parse(url));
	request.setTitle("Juzidian Dictionary Database");
	final long downloadId = this.downloadManager.enqueue(request);
	this.downloadRegistry.setCurrentDownloadId(downloadId);
}
 
開發者ID:ncjones,項目名稱:juzidian,代碼行數:15,代碼來源:JuzidianDownloadManager.java

示例13: 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

示例14: downloadPlugin

import android.app.DownloadManager.Request; //導入方法依賴的package包/類
public static void downloadPlugin(PluginDownloadHolder dataSource) {

		Request request = new DownloadManager.Request(
				dataSource.getDownloadLink());
		request.setDestinationInExternalFilesDir(
				GeoARApplication.applicationContext, null,
				dataSource.getIdentifier() + ".apk");
		request.setTitle("GeoAR Data Souce Download");
		request.setMimeType("application/vnd.52north.datasources");
		request.setDescription(dataSource.getName());
		currentDownloads.add(mDownloadManager.enqueue(request));
	}
 
開發者ID:52North,項目名稱:geoar-app,代碼行數:13,代碼來源:PluginDownloader.java

示例15: enqueue

import android.app.DownloadManager.Request; //導入方法依賴的package包/類
public void enqueue(DownloadCallback callback) throws IOException {
    if (!isExternalStorageWritable()) {
        throw new IOException("Cannot write to external storage");
    }

    Uri source = callback.getSource();

    /* Ensure the destination directory already exists. */

    File destination = new File(Detlef.getAppContext().getExternalFilesDir(
                                    callback.getDestinationDirType()), callback.getDestinationSubPath());
    destination.getParentFile().mkdirs();

    Request request = new Request(source);
    request.setDestinationInExternalFilesDir(context, callback.getDestinationDirType(),
            callback.getDestinationSubPath());
    request.addRequestHeader("user-agent", Detlef.USER_AGENT);
    request.setTitle(callback.getTitle());
    request.setDescription(callback.getDescription());
    request.setNotificationVisibility(callback.getNotificationVisibility());

    long id = downloadManager.enqueue(request);
    activeDownloads.put(id, callback);

    callback.onStart(destination.getAbsolutePath());

    Log.v(TAG, String.format("Enqueued download with id %d", id));
}
 
開發者ID:gpodder,項目名稱:detlef,代碼行數:29,代碼來源:DetlefDownloadManager.java


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