Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I´m starting in Android development and I would like to know what is recommended when creating a game. Should I use Thread with Handler or a AsyncTask to perform the game calculations, update graphics, etc, separated from UI Thread?

share

migration rejected from programmers.stackexchange.com Dec 15 '13 at 7:05

This question came from our site for professional programmers interested in conceptual questions about software development. Votes, comments, and answers are locked due to the question being closed here, but it may be eligible for editing and reopening on the site where it originated.

closed as primarily opinion-based by Byte56 Dec 15 '13 at 7:05

Many good questions generate some degree of opinion based on expert experience, but answers to this question will tend to be almost entirely based on opinions, rather than facts, references, or specific expertise.If this question can be reworded to fit the rules in the help center, please edit the question.

    
Which to use depends on your project. Compare the requirements of your project to each method and decide the best approach for you. –  Byte56 Dec 15 '13 at 7:06

1 Answer 1

up vote 0 down vote accepted

I'd pick AsyncTask - Everything can of course be done with Threads and Handlers, but it's already been done on AsyncTasks, so why bother?

They're nice and neat objects which are easy to enqueue and stash for network disconnects, and they're readily extended - for example: you can have a custom base AsyncTask which pops/hides a Spinner and GETs from an API endpoint, and extend that further into parsing the GET data as XML or JSON into objects,images,hashmaps, etc, as needed.

Also, it should be noted that an AsyncTask isn't strictly on a separate thread, it's callback methods do run in the main UI thread.

share

Not the answer you're looking for? Browse other questions tagged or ask your own question.