I am developing an app using RoboSpice library for calling REST API's. Everything works fine with the library except one thing. I don't use caching available in RoboSpice and so all the requests are made without cache. Now, when any request is going on and the user presses the home button then onStop() is called where shouldStop() of spice manager is called which unregisters all the request listeners for notification. When, the app again comes to foreground then UI update doesn't occur as the listeners have not been notified.
I don't want to use Cache that Robospice offers. Is there any other way that one can get UI update notifications without using Cache??
It's clearly not possible with RoboSpice, and indeed, there is a good reason : it would be a very bad idea.
When your activity dies (onStop), Android wants to garbage collect its instance. And to do it, it should not be referenced by anything. That's why RS imposes that all listeners are removed. Typically listeners hold a reference to the activity (as inner classes) and the finest achievement of RS is to let the activity die properly and get garbage collected.
So, doing what you want would clearly lead to a memory leak, and moreover would lead to crashes most of the time: when an activity is not displayed anymore, you would like to update its UI ? Looks a bit ackward, doesn't it ?
Maybe the simplest would be to use a very limited cache, or just execute all your requests every time your activities enter in onStart.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With