How to save Object while orientation change, since onRetainNonConfigurationInstance and getLastNonConfigurationInstance are deprecated. And which cannot me used with compatibility package
android-support-v4.jar
FragmentActivity
, where it shows Cannot override the final method from FragmentActivity
developer site say
Use the new Fragment API setRetainInstance(boolean) instead;
But I don't know how to save a custom object using setRetainInstance
My scenario :
In my activity I have a AsyncTask with progress dialog. Here I need to handle orientation change.
For that I got a very good answer from Mark Murphy, CommonsWare
background-task-progress-dialog-orientation-change-is-there-any-100-working,
with sample project
Since I'm using compatibility package android-support-v4.jar, FragmentActivity
, I can't override onRetainNonConfigurationInstance
Cannot override the final method from FragmentActivity
Is there any alternative method for saving my custom object?
EDIT:
I cannot make my AsyncTask task Parcelable (If I'm not wrong) since it use interface, context etc.
My AsyncTask
public class CommonAsyncTask extends AsyncTask<Object, Object, Object> {
Context context;
AsyncTaskServices callerObject;
ProgressDialog progressDialog;
String dialogMessag ;
................
I'm looking, is there any alternatives for onRetainNonConfigurationInstance method, which save an object completely while orientation change and later can be retrieve using getLastNonConfigurationInstance