I’m making an Android game, and I’ll need a continuously running thread for basically everything.
Now, however, I’m making the main menu (I always start simple, I’m new to coding), and I want an image to float across the main screen. I know how I could code that (determining the starting location, changing it), but I don’t know how to run such a piece of code continuously (outside the UI thread).
P.S.: Please be easy on me. I know I’m probably missing something obvious, but I have virtually no Java experience at all.
1. Create a Non-UI thread, with Handler. And run it within Controlled loop using a boolean variable. Handler will be helpful in putting the output of the Non-Ui thread on the
Ui thread.
2. You can use an AsyncTask, introduced in android to synchronize the UI with Non-Ui thread.