开发者

performSelectorOnMainThread equivalent in Java for Android

I have an iPhone application and I am porting it over to Android.

I have a service/controller that spawns new threa开发者_如何学Pythonds to perform some network tasks.

I use performSelectorOnMainThread in my iPhone app. How can I have my Java app do the same or similar thing?


Options:

  1. manual threading + Handler or runOnUiThread(..) available from Activity for posting UI changes
  2. AsyncTask
  3. Service for lengthy background operations


Assuming performSelectorOnMainThread does what I think it does, look at runOnUiThread() in Activity, or post() on Handler or any of your Views (i.e., your GUI widgets).

Though I generally agree with alex's answer -- use AsyncTask where possible, rather than forking your own threads.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜