stephanenicolas / robospice

Repo of the Open Source Android library : RoboSpice. RoboSpice is a modular android library that makes writing asynchronous long running tasks easy. It is specialized in network requests, supports caching and offers REST requests out-of-the box using extension modules.
Apache License 2.0
2.95k stars 545 forks source link

Methods that return Future<T> get blocked in the Callable #385

Closed deionalims closed 9 years ago

deionalims commented 9 years ago

Hi,

I tried to used methods that return Future with no luck. Especially getDateOfDataInCache(Class<?> clazz, final Object cacheKey) and removeDataFromCache(final Class clazz, final Object cacheKey). Both get blocked inside the call() method of the Callable at the line spiceManager.waitForServiceToBeBound(). I have no issues when working on all the async method that need a listener but when I want to do something synchronously, I end up with an ANR on the future.get() method. I may use it the wrong way so any help would be nice. Here is how I try to retrieve the date of the data:

Future<Date> future = spiceManager.getDateOfDataInCache(Page.class, cacheKey); Date cacheDate = future.get();

Everything blocks when I call future.get().

Thanks for any upcoming help.

FX

nkeskinov commented 9 years ago

It is by design that a Future blocks when you call get() on it. You should execute that call in a non-UI thread.