multithreading - Chaining together AsyncTasks in Android - better to use Threads? -


i have series of network operations must done sequentially:

  1. connect specific wifi device's ap
  2. send data on tcp
  3. connect different ap
  4. send udp broadcast

i have implemented starting each asynchtask in onpostexecute of previous asynchtask. realize in different part of app reuse code asynchtask 2 (to send different data), can't because not want asynchtask 3 start when finished. realize use flag (a boolean or int) , pass asynchtask 2 , not start asynchtask 3 if flag false, seems confusing , messy.

can done in cleaner way using threads? or end using same logic i.e. using flag in run() method?

let me know if me post code, long , feel question pretty clear.

if know you're going running of these tasks in sequence, why not put them in same asynctask? can still use different classes or functions make code more compartmentalized.


Comments

Popular posts from this blog

python - TypeError: start must be a integer -

c# - DevExpress RepositoryItemComboBox BackColor property ignored -

django - Creating multiple model instances in DRF3 -