Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>My answer is quite straight forward actually. Don't use AsyncTaskLoaders. Because a few bugs regarding AsyncTaskLoaders you knew it by now.</p> <p>A good combination would be a retainable (setRetainInstance(true) in onActivityCreated()) fragment with AsyncTask. Works the same way. Just have to restructure the code a bit. </p> <hr> <h2><em>Message from OP</em></h2> <p>Although the author doesn't provide any code example, this is the closest workable solution. I do not use the author proposed solution. Instead, I still rely on <code>AsyncTaskLoader</code> for all the necessary loading task. The workaround is that, I will rely on an additional retained fragment, to determine whether I should reconnect/create loader. The is the skeleton code on the whole idea. Works pretty well so far as long as I can tell.</p> <pre><code>@Override public void onActivityCreated(Bundle savedInstanceState) { ... dataRetainedFragment = (DataRetainedFragment)fm.findFragmentByTag(DATE_RETAINED_FRAGMENT); // dataRetainedFragment can be null still... } @Override public void onResume() { ... if (this.data == null) { if (dataRetainedFragment != null) { // Re-use! onLoadFinished(null, dataRetainedFragment); } else { // Prepare the loader. Either re-connect with an existing one, // or start a new one. getLoaderManager().initLoader(0, null, this); } } else { } } @Override public void onLoadFinished(Loader&lt;Data&gt; arg0, Data data) { this.data = data; if (this.dataRetainedFragment == null) { this.dataRetainedFragment = DataRetainedFragment.newInstance(this.data); FragmentManager fm = getFragmentManager(); fm.beginTransaction().add(this.dataRetainedFragment, DATE_RETAINED_FRAGMENT).commitAllowingStateLoss(); } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload