I am using from AsyncLoader in my app . I want know onLoadFinished run after which method of my fragment during orientation change?
I show a dialog when loader run first time
@Override
public Loader<ArrayList<HashMap<String, Object>>> onCreateLoader(int id,Bundle bundle)
{
handler.sendEmptyMessage(SendRequestLoader.ShowDialog);
return loader;
}
I add listarray to my adapter
@Override
public void onLoadFinished(Loader<ArrayList<HashMap<String,Object>>> loader,ArrayList<HashMap<String,Object>> list)
{
Log.e("", "---onLoadFinished---");
if(list!=null)
Log.e("before","-------adapter.size()----"+adapter.getCount());
if(list!=null)
{
int count=list.size();
for(int i=0;i<count;i++)
{
adapter.add(list.get(i));
}
}
handler.sendEmptyMessage(((SendRequestLoader)loader).getMessage());
if(list!=null)
Log.e("","-------list.size()----"+list.size());
Log.e("after","-------adapter.size()----"+adapter.getCount());
}
@Override
public void onLoaderReset(Loader<ArrayList<HashMap<String, Object>>> loader)
{
}
I save dialog state for show dialog in orientation change.but i am not sure onLoadFinished method can run after onSaveInstanceState method or no and am I using a right way for manage my loader?
@Override
public void onSaveInstanceState(Bundle outState)
{
super.onSaveInstanceState(outState);
if(isshowingDialog)
outState.putBoolean("isshow",true);
else
outState.putBoolean("isshow",false);
outState.putParcelable("parcle", new Parcable(adapter.getArrayList()));
}
To not loose dialog state when screen changes the orientation you should do some staff.
First in
AndroidManifest.xml
you gonna set the config changes ofActivity
:After that you gonna override the
onConfigurationChanged
method in yourActivity
class to not handle anything when this happen:At here your
Activity
will not be restarted when user rotate the device and orientation changes, and you not will lost your async staff.