Consider the scenario where I have received the data from the server and posted it in the UI in list view, but it There is an active activity, it never stops
taskA {// brings data to the network if fetch (updates!); // network operation} taskB {// is updated on runtime when using this data UI such as feed show (updates); // UI operation} TaskA begins after the work starts from that time, A is sleeping and vice versa goes, now I have problems I am facing:
- Both tasks have to be in the worker thread
- Both activities are running in the cycle as long as the activity is not alive.
- If the handler posts a UI operation in the main thread, it appears to be against Task B.
Can anyone recommend designing me to do this work?
async task is working for you, you can call it your Activity can be created as an internal orbit within the main category.
Example code
Private class YourTask AsyncTask extension & lt; Url, integer, string & gt; {Secure string doInBackground (URL ... urls) {// Get data (task A) return "results"; } Protected void onProgressUpdate (integer progression) {// Show progress} Secure void onPostExecute {// Show UI after completion (Task B)}}
Comments
Post a Comment