What is RoboSpice Library in android

纵然是瞬间 提交于 2019-12-03 14:02:06

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!