AsyncTask with screen rotation - onRetainNonConfigurationInstance deprecated

后端 未结 2 980
小鲜肉
小鲜肉 2021-01-12 22:23

I am still trying to find the \"correct\" design pattern when dealing with AsyncTasks and screen rotation. I read this commonsware blog post which links to thi

2条回答
  •  一生所求
    2021-01-12 22:47

    It's only deprecated on Honeycomb and above, and it will work just fine on those too. The 'new' way is to use loaders (you can use the compatibility library to get those in pre-HC versions) or retained fragments. If you call setRetainInstance() the instance passed as is to the newly created activity (they actually use onRetainNonConfigurationInstance in the FragmentActivity of the compatibility library), so it's effectively the same as what you have now.

提交回复
热议问题