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 6016061
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T02:55:44+00:00 2026-05-23T02:55:44+00:00

I am studying the LunarLander example in the Android sample code: http://developer.android.com/resources/samples/LunarLander/index.html I am

  • 0

I am studying the LunarLander example in the Android sample code: http://developer.android.com/resources/samples/LunarLander/index.html

I am puzzled because the comments say in several places that the code uses ‘invalidate’ to trigger redrawing. But I can’t find it in the code.

More importantly I believe that drawing should always happen in a View’s onDraw and not inline elsewhere in a thread.

Has anyone studied that example and have comments about why invalidate() is not being called?

  • 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-05-23T02:55:44+00:00Added an answer on May 23, 2026 at 2:55 am

    It isn’t inlined in a Thread but it is called from a Thread.

    @Override
    public void run() {
        while (mRun) {
            Canvas c = null;
            try {
                c = mSurfaceHolder.lockCanvas(null);
                synchronized (mSurfaceHolder) {
                    if (mMode == STATE_RUNNING) updatePhysics();
                    doDraw(c);
                }
            } finally {
                // do this in a finally so that if an exception is thrown
                // during the above, we don't leave the Surface in an
                // inconsistent state
                if (c != null) {
                    mSurfaceHolder.unlockCanvasAndPost(c);
                }
            }
        }
    }
    

    The drawing itself should always be called from a Thread when you do 2D graphics…

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

Sidebar

Related Questions

studying some sample code from an iOS programming course (cs193p fall2010) i came across
I am studying to use MVVM pattern for my Silverlight application. Following code is
I was studying some code I found on the web recently, and came across
While studying for the 70-433 exam I noticed you can create a covering index
I am new to studying jquery.ajax. Through some tutorials, I tried some code by
Im studying some ruby code and I see this varx variable being used with
Studying C#, my books are showing me classes for readin files. I've found 2
Just studying the C style of Jon Bentley's Programming Pearls and was wondering if
Since I started studying object-oriented programming, I frequently read articles/blogs saying functions are better,
I've been studying the Google authentication API (AuthSub)... My question is, how do I

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.