Before I used some way for call code in non ui thread (AsyncTask, Loader etc) . But now I try to use @WorkerThread annotation for method, it called some network request
@WorkerThread
public void downloadInFile(final String url, final String rootDirectory, final OnFinishLoadAudioInFile onFinishLoadAudioInFile,
final OnUpdateLoadAudio onUpdateLoadAudio) {
final String fileName = URLUtil.guessFileName(url, null, null);
downloadFile(url, rootDirectory + File.pathSeparator + fileName, onFinishLoadAudioInFile, onUpdateLoadAudio);
}
, and have android.os.NetworkOnMainThreadException
. How use @WorkerThread
annotation correctly?
WorkerThread annotation is only to add a requirement of calling thread not for automatically using a specific thread. You still have to do the threading.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With