Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8775797
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T18:53:42+00:00 2026-06-13T18:53:42+00:00

Android does not have main loop, but I have a ball in my arkanoid

  • 0

Android does not have main loop, but I have a ball in my arkanoid game test, and it needs to have the position changed every 100 ms.

I tried using MainThread library, but still it is not working.

If there was any possible way for me to override the function onRunning() and put it to check if the screen was touched and move the ball would be great.

But considering as I can’t change the onRunning() function what could I do to add a function that will move my ball to the main game loop?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T18:53:43+00:00Added an answer on June 13, 2026 at 6:53 pm

    You could create another thread which will run asynchronously with your Main/Gui thread

    final boolean shouldRun = true;
    
    Thread t = new Thread(){
        public void run(){
            while (shouldRun){
                //do what ever you need
                try{
                    Thread.sleep(100); //sleep for 100ms
                } catch (Exception e) {
    
                }
             }
        }
     };
    
    shouldRun = true;
    t.start();
    

    when you are done

    shouldRun = false;
    try { 
        t.join();
    } catch (Exception e) { }
    

    Note that this is not the most elegant solution, you should create a class which will handle the logic of the game on one thread and the drawing on another one.

    Moreover, you should pause the logic game as well as the drawing whenever your activity is paused .

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

It seems the java.net.NetworkInterface implementation of android does not have a byte[] getHardwareAddress() method
Does someone have the source for Android loadable kernel module for libnfc? If not,
-webkit-device-pixel-ratio query is supported by both iOS and Android but since iOS does not
I just defined a dialog as android site suggest, but it does not show
Does Android support virtual memory concept? I read it does use paging but not
I have one application for showing the map but it is not working does
Android app A has Internet access: <uses-permission android:name=android.permission.INTERNET/> App B does not have Internet
The Android Developer documentation does not mention whether the method below (and similar ones)
Android Emulator Icon in windows 7 does not show in TaskBar..see my Image... I
How to make spinner to fill empty place in left side? android:layout_width=fill_parent does not

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.