8

I am Trying to understand RoboSpice Library in android


I saw the online Documentation here


What i tried::

  • I have previously studying on using Spring Library,also Retrofit, AsyncHttp etc
  • I understood that all above convert JSON response to POJO

What i need more information::

  • When i see the documentation on Robospice it looks like a wrapper around either of Spring or Retrofit or AsyncHttp etc
  • Is it true ?
  • So by using RoboSpice can we select the underlying layer to be Spring or Retrofit or AsyncHttp etc
  • So if that happens RoboSpice makes Spring or Retrofit or AsyncHttp etc as BoilerPlate code and makes development easier

If i am not correct, please provide a clear info w.r.t this


I am new to android, Please go easy on with answers

Devrath
  • 42,072
  • 54
  • 195
  • 297

1 Answers1

15

I'm not an expert on RoboSpice but here is my quick explanation of its function:

Often in our app we would like to do Asynchronous network operations (get image from url etc.)

A common technique is to do the network request within an AsyncTask object.

The problem is that the AsyncTask object is not handled by the activity lifecycle.

When the device configuration change occurs (e.g. rotate device) a new activity is created (See Handling runtime changes). The original activity which created the Async network request is destroyed now but the AsyncTask is still working. The AsyncTask which is doing the networking will now maybe try and update the UI with some progress information (e.g. download has completed). But the AsyncTask still refers to the original activity which has been destroyed now. We need the AsyncTask to attach itself to the new activity.

My knowledge is that RoboSpice helps solve this problem. I cannot comment on the underlying implementation of RoboSpice.

Twobard
  • 2,553
  • 1
  • 24
  • 27
  • Thanks for valuable info [+1]...... Also what other ways can i handle the runtime changes in android apart from robospice and which is the best one to use like(cursor adapter, endless adapter ... etc) for handling runtime changes – Devrath Apr 16 '14 at 09:56
  • In Android these runtime changes are known as "config changes." There are a number of ways to handle config changes. The recommended way to handle these changes is by using Fragments, because it is possible for fragments to be kept alive after a config change. There are many tutorials online which explain how Fragments can be used, a quick google search should give you all of the information you need. – Twobard Apr 16 '14 at 10:09
  • I'm also new to Robospice and I think it can do everything that Spring Android (the underlying) can do and more. Have a look here: https://github.com/stephanenicolas/robospice/wiki/Spring-Android-module – Simon Jun 03 '15 at 14:13
  • Can anyone let me know, shall I use okhttp3 instead of robospice. Or shall I need to use retrofit + okhttp3+ rxjava to acheive the robospice fuctionality? – sejn Sep 28 '20 at 08:49