Execute equivalent of SelectorOnMainThread in Java for Android

I have an iPhone app and I am porting to Android.

I have a service / controller that generates new threads to do some networking tasks.

I am using performSelectorOnMainThread

in my iPhone app. How can I get my Java application to do the same or similar?

+2


a source to share


2 answers


Parameters:



  • hand thread + Handler or runOnUiThread(..)

    available from Activity to post UI changes
  • AsyncTask
  • Service for long running background operations
+3


a source


Assuming that performSelectorOnMainThread

does what I think matters runOnUiThread()

in Activity

or post()

on Handler

or any of your Views

(i.e. GUI widgets).



Although I generally agree with alex's answer - use AsyncTask

where possible instead of deploying your own streams.

+1


a source







All Articles