Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if reponseCode == 304:
- body = <getDataFromCache>
- OkHttpClient client = new OkHttpClient();
- File cacheDirectory = new File(context.getCacheDir(), "responses");
- Cache cache = null;
- try {
- cache = new Cache(cacheDirectory, 10 * 1024 * 1024); // 10M
- client.setCache(cache);
- } catch (IOException e) {
- Log.e("AbstractFeedIntentService", "Could not create http cache", e);
- }
- Request.Builder requestBuilder = new Request.Builder();
- requestBuilder.url(url);
- Request request = requestBuilder.build();
- Call call = client.newCall(request);
- Response response = call.execute();
- // if code==304, does the response contain the data from the cache. If not, how to get it?
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement