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


Java HttpResponseCache.getInstalled方法代码示例

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


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

示例1: fetchFromHTTPUrlConnectionCache

import android.net.http.HttpResponseCache; //导入方法依赖的package包/类
/**
 * Fetches an entry value from the HttpResponseCache cache
 * @param connection connection from which we need the cache
 * @param uri uri to use to get the cache entry
 * @return cache entry value as String
 */
private String fetchFromHTTPUrlConnectionCache(HttpURLConnection connection, URI uri) {

    try {
        HttpResponseCache responseCache = HttpResponseCache.getInstalled();
        if(responseCache != null){
            CacheResponse cacheResponse = responseCache.get(uri, "GET", connection.getRequestProperties());
            Scanner scanner = new Scanner(cacheResponse.getBody(), "UTF-8");
            StringBuilder sb = new StringBuilder();
            while (scanner.hasNextLine()){
                sb.append(scanner.nextLine());
            }

            return sb.toString();
        }

    } catch (Exception ex) {
        ex.printStackTrace();
    }
    return null;

}
 
开发者ID:nico-gonzalez,项目名称:volley-it,代码行数:28,代码来源:MainActivity.java

示例2: onStop

import android.net.http.HttpResponseCache; //导入方法依赖的package包/类
protected void onStop() {

        HttpResponseCache cache = HttpResponseCache.getInstalled();
        if (cache != null) {
            cache.flush();
        }
    }
 
开发者ID:BlueYangDroid,项目名称:MvpPlus,代码行数:8,代码来源:MyIntentService.java

示例3: onStop

import android.net.http.HttpResponseCache; //导入方法依赖的package包/类
@Override
protected void onStop() {
    super.onStop();
   HttpResponseCache cache = HttpResponseCache.getInstalled();
    if(cache != null) {  //Clearing the cache
        cache.flush();
    }
}
 
开发者ID:rishabh115,项目名称:Odyssey2017,代码行数:9,代码来源:FeedActivity.java

示例4: onStop

import android.net.http.HttpResponseCache; //导入方法依赖的package包/类
protected void onStop() {
    super.onStop();
    HttpResponseCache cache = HttpResponseCache.getInstalled();
    if (cache != null) {
        cache.flush();
    }
}
 
开发者ID:PacktPublishing,项目名称:Android-High-Performance-Programming,代码行数:8,代码来源:ResponseCache.java

示例5: put

import android.net.http.HttpResponseCache; //导入方法依赖的package包/类
@Override
public void put(Request key, HttpResponse value) {
    HttpResponseCache cache = HttpResponseCache.getInstalled();
    if (cache != null) {
        cache.flush();
    }
}
 
开发者ID:witrisna,项目名称:android-restless,代码行数:8,代码来源:FileCache.java

示例6: clear

import android.net.http.HttpResponseCache; //导入方法依赖的package包/类
@Override
public void clear() throws IOException {
    HttpResponseCache cache = HttpResponseCache.getInstalled();
    if (cache != null) {
        cache.delete();
    }
    HttpResponseCache.install(file, size);
}
 
开发者ID:witrisna,项目名称:android-restless,代码行数:9,代码来源:FileCache.java

示例7: onStop

import android.net.http.HttpResponseCache; //导入方法依赖的package包/类
@Override
protected void onStop() {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
        final HttpResponseCache cache = HttpResponseCache.getInstalled();
        if (cache != null) {
            cache.flush();
        }
    }

    super.onStop();
}
 
开发者ID:crm416,项目名称:android-lite,代码行数:12,代码来源:MainActivity.java

示例8: onPause

import android.net.http.HttpResponseCache; //导入方法依赖的package包/类
@Override
protected void onPause() {
  HttpResponseCache cache = HttpResponseCache.getInstalled();
  if (cache != null) {
      cache.flush();
  }
  super.onPause();
}
 
开发者ID:sunnygoyal,项目名称:PowerToggles,代码行数:9,代码来源:ThemePicker.java

示例9: invalidateCache

import android.net.http.HttpResponseCache; //导入方法依赖的package包/类
/**
 * Invalidates both HttpResponseCache and Volley cache
 * @param view
 */
public void invalidateCache(View view) {

    mRequestQueue.getCache().clear();
    try {
        HttpResponseCache cache = HttpResponseCache.getInstalled();
        if(cache != null) cache.delete();
    } catch (IOException e) {
        e.printStackTrace();
    }
    Toast.makeText(this, "Cache is now empty", Toast.LENGTH_SHORT).show();

}
 
开发者ID:nico-gonzalez,项目名称:volley-it,代码行数:17,代码来源:MainActivity.java

示例10: onStop

import android.net.http.HttpResponseCache; //导入方法依赖的package包/类
@Override
protected void onStop() {
    super.onStop();
    HttpResponseCache cache = HttpResponseCache.getInstalled();
    if (cache != null) {
        cache.flush();
    }
}
 
开发者ID:matrix-msu,项目名称:mbira-android-template,代码行数:9,代码来源:LoadingActivity.java

示例11: onStop

import android.net.http.HttpResponseCache; //导入方法依赖的package包/类
protected void onStop() {
	HttpResponseCache cache = HttpResponseCache.getInstalled();
	if (cache != null) {
		cache.flush();
	}
	super.onStop();
}
 
开发者ID:spectralmind,项目名称:sonarflow-android,代码行数:8,代码来源:MainActivity.java

示例12: installHttpResponseCache

import android.net.http.HttpResponseCache; //导入方法依赖的package包/类
@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
private static HttpResponseCache installHttpResponseCache(final File cacheDir)
        throws IOException {
    HttpResponseCache cache = HttpResponseCache.getInstalled();
    if (cache == null) {
        final long maxSize = calculateDiskCacheSize(cacheDir);
        cache = HttpResponseCache.install(cacheDir, maxSize);
    }
    return cache;
}
 
开发者ID:satorufujiwara,项目名称:lighthttp,代码行数:11,代码来源:CacheUtil.java

示例13: install

import android.net.http.HttpResponseCache; //导入方法依赖的package包/类
static Object install(Context context) throws IOException {
  File cacheDir = Utils.createDefaultCacheDir(context);
  HttpResponseCache cache = HttpResponseCache.getInstalled();
  if (cache == null) {
    long maxSize = Utils.calculateDiskCacheSize(cacheDir);
    cache = HttpResponseCache.install(cacheDir, maxSize);
  }
  return cache;
}
 
开发者ID:jrconlin,项目名称:mc_backup,代码行数:10,代码来源:UrlConnectionDownloader.java

示例14: installedCacheIsReturned

import android.net.http.HttpResponseCache; //导入方法依赖的package包/类
@Test
public void installedCacheIsReturned() throws Exception {
  assertThat(HttpResponseCache.getInstalled()).isNull();
  HttpResponseCache cache = HttpResponseCache.install(File.createTempFile("foo", "bar"), 42);
  HttpResponseCache installed = HttpResponseCache.getInstalled();
  assertThat(installed).isSameAs(cache);
  assertThat(installed.maxSize()).isEqualTo(42);
}
 
开发者ID:qx,项目名称:FullRobolectricTestSample,代码行数:9,代码来源:HttpResponseCacheTest.java

示例15: close

import android.net.http.HttpResponseCache; //导入方法依赖的package包/类
@Override
public void close() throws IOException {
    HttpResponseCache cache = HttpResponseCache.getInstalled();
    if (cache != null) {
        cache.flush();
    }
}
 
开发者ID:aarya123,项目名称:CampusFeedv2,代码行数:8,代码来源:Api.java


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