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


Java Request.setAllowedOverRoaming方法代码示例

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


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

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

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

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

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

示例5: execute

import android.app.DownloadManager.Request; //导入方法依赖的package包/类
@Override
public void execute(final Context context) {
    if (null == mWordList) { // This should never happen
        Log.e(TAG, "UpdateAction with a null parameter!");
        return;
    }
    Utils.l("Downloading word list");
    final SQLiteDatabase db = MetadataDbHelper.getDb(context, mClientId);
    final ContentValues values = MetadataDbHelper.getContentValuesByWordListId(db,
            mWordList.mId, mWordList.mVersion);
    final int status = values.getAsInteger(MetadataDbHelper.STATUS_COLUMN);
    final DownloadManager manager =
            (DownloadManager) context.getSystemService(Context.DOWNLOAD_SERVICE);
    if (MetadataDbHelper.STATUS_DOWNLOADING == status) {
        // The word list is still downloading. Cancel the download and revert the
        // word list status to "available".
        if (null != manager) {
            // DownloadManager is disabled (or not installed?). We can't cancel - there
            // is nothing we can do. We still need to mark the entry as available.
            manager.remove(values.getAsLong(MetadataDbHelper.PENDINGID_COLUMN));
        }
        MetadataDbHelper.markEntryAsAvailable(db, mWordList.mId, mWordList.mVersion);
    } else if (MetadataDbHelper.STATUS_AVAILABLE != status) {
        // Should never happen
        Log.e(TAG, "Unexpected state of the word list '" + mWordList.mId + "' : " + status
                + " for an upgrade action. Fall back to download.");
    }
    // Download it.
    Utils.l("Upgrade word list, downloading", mWordList.mRemoteFilename);

    // TODO: if DownloadManager is disabled or not installed, download by ourselves
    if (null == manager) return;

    // This is an upgraded word list: we should download it.
    // 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()
            + com.android.inputmethod.latin.Utils.getVersionName(context) + ".dict";
    final Uri uri = Uri.parse(mWordList.mRemoteFilename + disambiguator);
    final Request request = new Request(uri);

    final Resources res = context.getResources();
    if (!mForceStartNow) {
        if (DownloadManagerCompatUtils.hasSetAllowedOverMetered()) {
            final boolean allowOverMetered;
            switch (UpdateHandler.getDownloadOverMeteredSetting(context)) {
            case UpdateHandler.DOWNLOAD_OVER_METERED_DISALLOWED:
                // User said no: don't allow.
                allowOverMetered = false;
                break;
            case UpdateHandler.DOWNLOAD_OVER_METERED_ALLOWED:
                // User said yes: allow.
                allowOverMetered = true;
                break;
            default: // UpdateHandler.DOWNLOAD_OVER_METERED_SETTING_UNKNOWN
                // Don't know: use the default value from configuration.
                allowOverMetered = res.getBoolean(R.bool.allow_over_metered);
            }
            DownloadManagerCompatUtils.setAllowedOverMetered(request, allowOverMetered);
        } else {
            request.setAllowedNetworkTypes(Request.NETWORK_WIFI);
        }
        request.setAllowedOverRoaming(res.getBoolean(R.bool.allow_over_roaming));
    } // if mForceStartNow, then allow all network types and roaming, which is the default.
    request.setTitle(mWordList.mDescription);
    request.setNotificationVisibility(
            res.getBoolean(R.bool.display_notification_for_auto_update)
                    ? Request.VISIBILITY_VISIBLE : Request.VISIBILITY_HIDDEN);
    request.setVisibleInDownloadsUi(
            res.getBoolean(R.bool.dict_downloads_visible_in_download_UI));

    final long downloadId = UpdateHandler.registerDownloadRequest(manager, request, db,
            mWordList.mId, mWordList.mVersion);
    Utils.l("Starting download of", uri, "with id", downloadId);
    PrivateLog.log("Starting download of " + uri + ", id : " + downloadId);
}
 
开发者ID:slightfoot,项目名称:android-kioskime,代码行数:78,代码来源:ActionBatch.java

示例6: 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 updateNow Whether we should update NOW, or respect bandwidth policies
 * @param metadataUri The client to update
 */
private static void updateClientsWithMetadataUri(final Context context,
        final boolean updateNow, final String metadataUri) {
    PrivateLog.log("Update for metadata URI " + Utils.s(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()
            + com.android.inputmethod.latin.Utils.getVersionName(context) + ".json";
    final Request metadataRequest = new Request(Uri.parse(metadataUri + disambiguator));
    Utils.l("Request =", metadataRequest);

    final Resources res = context.getResources();
    // By default, download over roaming is allowed and all network types are allowed too.
    if (!updateNow) {
        final boolean allowedOverMetered = res.getBoolean(R.bool.allow_over_metered);
        // If we don't have to update NOW, then only do it over non-metered connections.
        if (DownloadManagerCompatUtils.hasSetAllowedOverMetered()) {
            DownloadManagerCompatUtils.setAllowedOverMetered(metadataRequest,
                    allowedOverMetered);
        } else if (!allowedOverMetered) {
            metadataRequest.setAllowedNetworkTypes(Request.NETWORK_WIFI);
        }
        metadataRequest.setAllowedOverRoaming(res.getBoolean(R.bool.allow_over_roaming));
    }
    final boolean notificationVisible = updateNow
            ? res.getBoolean(R.bool.display_notification_for_user_requested_update)
            : res.getBoolean(R.bool.display_notification_for_auto_update);

    metadataRequest.setTitle(res.getString(R.string.download_description));
    metadataRequest.setNotificationVisibility(notificationVisible
            ? Request.VISIBILITY_VISIBLE : Request.VISIBILITY_HIDDEN);
    metadataRequest.setVisibleInDownloadsUi(
            res.getBoolean(R.bool.metadata_downloads_visible_in_download_UI));

    final DownloadManager manager =
            (DownloadManager) context.getSystemService(Context.DOWNLOAD_SERVICE);
    if (null == manager) {
        // Download manager is not installed or disabled.
        // TODO: fall back to self-managed download?
        return;
    }
    cancelUpdateWithDownloadManager(context, metadataUri, manager);
    final long downloadId;
    synchronized (sSharedIdProtector) {
        downloadId = manager.enqueue(metadataRequest);
        Utils.l("Metadata download requested with id", downloadId);
        // If there is already 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);
    }
    PrivateLog.log("Requested download with id " + downloadId);
}
 
开发者ID:slightfoot,项目名称:android-kioskime,代码行数:63,代码来源:UpdateHandler.java


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