Suppose in the loadInBackground
AsyncTaskLoader'a
method I am trying to load data from the network. If the data is not loaded, I need to forcibly end the loadInBackground
method. What method can this be accomplished?
- In the header you want to complete the loader. In the description: to force the download. Please clarify. - Daniel Shatz
- @DanielShatz, thanks, corrected :)). - user189127
|
1 answer
If you want to interrupt work from outside (for example, by pressing a button):
Add a global variable boolean cancelled = false;
.
In onClick
assign true
to cancelled
.
Then, in the loadInBackground
method, in a place where it is logical to interrupt work, do if(cancelled) return;
If you want to interrupt work, when you could not load something, then at the right time, make a return
.
In general, the AsyncTaskLoader
ends when the loadInBackground
method loadInBackground
.
- Hmm ... And I did not even think about it ... Thank you :). - user189127
|