Back to project page AndroidAsyncTaskLoaderSample.
The source code is released under:
MIT License
If you think the Android project AndroidAsyncTaskLoaderSample listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.tatuas.android.asynctaskloadersample; /* www .j a va 2s . com*/ import android.content.Context; import android.os.SystemClock; import android.support.v4.content.AsyncTaskLoader; public class MyLoader extends AsyncTaskLoader<String> { String arg; String result; public MyLoader(Context context, String arg) { super(context); this.arg = arg; } @Override public String loadInBackground() { SystemClock.sleep(15000); result = arg + "hello"; return result; } @Override public void deliverResult(String data) { if (isReset()) { return; } result = data; if (isStarted()) { super.deliverResult(data); } } @Override protected void onStartLoading() { if (result != null) { deliverResult(result); } if (takeContentChanged() || result == null) { forceLoad(); } } }