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

  • SEARCH
  • Home
  • 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 6549973
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T12:09:33+00:00 2026-05-25T12:09:33+00:00

I have created a thread for a game where I am testing if hero

  • 0

I have created a thread for a game where I am testing if hero (a bitmap) touches the edges of the screen.

Part of the Thread:

protected void updatePhysics() {
mBallX += elapsed * mBallDX;
        mBallY += elapsed * mBallDY;

        if((mBallX <= 0 & mBallDX < 0) | (mBallX >= mCanvasWidth - mBall.getWidth() & mBallDX > 0) ) {
            mBallDX = -mBallDX;
            updateScore(1);

        }
    }

This is from a tutorial. Instead of updateScore(1) I want the game to be over and open the GameOver activity.
I am using this code in other activities but here in the thread it shows an error:

Intent intent_btn_gameover = new Intent(GameThread.java, GameOver.class);   
startActivity(intent_btn_gameover);

The method startActivity(Intent) is undefined for the type GameThread and it does not like GameThread.java (The constructor Intent(GameThread, Class) is undefined). I don’t know what to set as the first parameter of the Intent.

Thanks

Edit:

private Context gContext;

and

Intent intent_btn_nextlevels = new Intent(gContext, GameOver.class);
startActivity(intent_btn_nextlevels);

Error: The method startActivity(Intent) is undefined for the type GameThread

  • 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-25T12:09:34+00:00Added an answer on May 25, 2026 at 12:09 pm

    The first parameter of Intent’s constructor is a Context. You must pass the activity where the Thread is being executed, for instance:

    Intent intent_btn_gameover = new Intent(NameOfActivity.this, GameOver.class);   
    startActivity(intent_btn_gameover);
    

    If the thread is not inside an activity, you must pass somehow a reference to the activity that executes it.

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

Sidebar

Related Questions

I have created an multi thread application on IIS (ASP.NET MVC), When the threading
I have some BitmapFrames created on a thread other than the main UI thread;
I have a method running in a seperate thread. The thread is created and
I currently have a thread that I created using CreateRemoteThread(). Everything works great. Upon
I am working on a network programming and I have created a thread pool.
Currently, I'm elaborating with game development, and have created (with help of some online
I have created a game which paints images to a JPanel. This runs with
I have a req where in i have to create a worker thread and
I have a simple program that creates a thread, loops twenty times and then
I have a parent thread (non-UI) which creates some child threads to do some

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.