GithubHelp home page GithubHelp logo

Comments (6)

rciovati avatar rciovati commented on August 27, 2024

Could you post a simple project that reproduces this?

from robospice.

papo2608 avatar papo2608 commented on August 27, 2024

You can reproduce this issue with:

  1. checkout robospice-sample-spring-android
  2. I'm using Gson instead of Jackson
  3. put following lines of code in your MainActivity class:
    @Override
    protected void onResume() {
        super.onResume();
        ListTweets tweets;
        try {
            Future<ListTweets> task = contentManager.getDataFromCache(ListTweets.class, "tweets.android");
            tweets = task.get();
        } catch (CacheLoadingException e) {
            e.printStackTrace();
        } catch (InterruptedException e) {
            e.printStackTrace();
        } catch (ExecutionException e) {
            e.printStackTrace();
        }
    }

4 search with the query "android"
5 you get an ANR error

from robospice.

stephanenicolas avatar stephanenicolas commented on August 27, 2024

Was you spiceManager started before reaching this line ?

Also, please consider the asynchronous nature of a call to
getDataFromCache. When you call this method, it will return a future as the
spiceManager must bind to the spiceService and, when bound, ask for the
cache content.

When you call the method get() of that future, it will block until the
getDataFromCache actually completes. This operation should not be called on
the main thread but inside an AsyncTask. Otherwise, get will block your UI
thread and create an ANR. There is no workaround for it.

Stéphane

2013/1/19 papo2608 [email protected]

You can reproduce this issue with:

  1. checkout robospice-sample-spring-android
  2. I'm using Gson instead of Jackson
  3. put following lines of code in your MainActivity class:
@Override
protected void onResume() {
    super.onResume();
    ListTweets tweets;
    try {
        Future<ListTweets> task = contentManager.getDataFromCache(ListTweets.class, "tweets.android");
        tweets = task.get();
    } catch (CacheLoadingException e) {
        e.printStackTrace();
    } catch (InterruptedException e) {
        e.printStackTrace();
    } catch (ExecutionException e) {
        e.printStackTrace();
    }
}

4 search with the query "android"
5 you get an ANR error


Reply to this email directly or view it on GitHubhttps://github.com//issues/30#issuecomment-12455292.

Stéphane NICOLAS,
OCTO Technology
Développeur & Consultant Android / Java
..........................................................
50, Avenue des Champs-Elysées
75008 Paris
+33 (0)6.26.32.34.09
www.octo.com - blog.octo.com
www.usievents.com
...........................................................

from robospice.

rciovati avatar rciovati commented on August 27, 2024

I was writing what @stephanenicolas said.

BTW, you can use the getFromCachemethod that is async. ;)
We use it in the same sample: http://bit.ly/WrhFNn

from robospice.

stephanenicolas avatar stephanenicolas commented on August 27, 2024

Right. Thx Ricardo. ;)

2013/1/19 Riccardo Ciovati [email protected]

I was writing what stephanenicolas said.

BTW, you can use the getFromCachemethod wich is async. ;)


Reply to this email directly or view it on GitHubhttps://github.com//issues/30#issuecomment-12455417.

Stéphane NICOLAS,
OCTO Technology
Développeur & Consultant Android / Java
..........................................................
50, Avenue des Champs-Elysées
75008 Paris
+33 (0)6.26.32.34.09
www.octo.com - blog.octo.com
www.usievents.com
...........................................................

from robospice.

papo2608 avatar papo2608 commented on August 27, 2024

OK, so there is no possibility to get cached data synchronously?

from robospice.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.