I have 3 classes of Basic in which I am authorized and I receive a token from the server, a fragment class and an asynctask class for a fragment. The question of the century is how to get an intent in the asynctask class, if it is not tied to a fragment. To get an intent in the fragment and then try to use it in the asynctask class, the asynctask requires that getting the intent be static, but getActivity () cannot be static. What do you do in such cases?
- It is unlikely that such an answer will help you, but in such cases we do not use AsyncTask. - saturov
- But then, if I use regular Thread, then I cannot for example change the TextView after the stream has ended, or am I confusing something? - Slava Nenashev
- oneNo, you do not understand. Thread is also not our case. All this is already very outdated options, not used by good developers. If simpler, then pay attention to the Loaders, if you want to be in trend - then RxJava. Both are sharpened for asynchronous operations, but unlike all of the above, it is convenient to use and functionally. - saturov
- oneThat's right, such cases do not arise. And when using AsyncTask and using Thread, Loader, RxJava, Robospice and so on, no one needs to send intent through the fragment. Give the code (the minimum example), it just needs to be straightened. - Yura Ivanov
|