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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T16:24:42+00:00 2026-05-17T16:24:42+00:00

I’m working on an RPG for Android, using the LunarLander API demo. I’ve already

  • 0

I’m working on an RPG for Android, using the LunarLander API demo. I’ve already made a game using this demo (Porcupine Assassin, check it out!) so I’ve got a good grasp of the Canvas class and things of that nature.

My problem is, in RPGs you need a way to access inventory, stats, etc. So I’ve set the BACK button to start the class Inventory.java. I’m running into problems when I finish() the Inventory activity and try to return to the game (the SurfaceView).

This is the SurfaceCreated() callback:

public void surfaceCreated(SurfaceHolder holder) {
    thread.setRunning(true);
    thread.start();
}

I was getting an FC caused by “IllegalThreadStateException: thread already started” so I put a try/catch in the SurfaceCreated() callback. With the try/catch, no FC happens, but I return to a black screen.

I tried taking the try/catch out and adding a check in the beginning: if(!thread.isAlive()). That way, if the thread was already started, it wouldn’t do anything. Oddly enough, I got the same FC “thread already started” so thread.isAlive() must’ve returned false.. ??

I also have the onWindowFocusChanged() method from the API:

@Override
public void onWindowFocusChanged(boolean hasWindowFocus) {
    if (!hasWindowFocus) thread.pause();
    else thread.setState(STATE_RUNNING);
}

I’m pretty keen on the gaming side of this, I’ve got most of the groundwork for my RPG laid out. But it’s all this Android/Java stuff that goes over my head. Can anyone point me in the right direction?

  • 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-17T16:24:43+00:00Added an answer on May 17, 2026 at 4:24 pm

    It is because you are trying to restart a terminated thread, thus the .IsAlive() returned false. There is a lot of documentation on this problem if you google LunarLander bug or illegal thread or something.

    One possible workaround I found one time was this:

        public void surfaceCreated(SurfaceHolder holder) {
            if (thread.getState() == Thread.State.TERMINATED) {
                thread = new CascadeThread(getHolder(), getContext(), getHandler());
                thread.setRunning(true);
                thread.start();
            }
            else {
                thread.setRunning(true);
                thread.start();
            }
    

    You can find the full documentation here

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

Sidebar

Related Questions

I'm making a simple page using Google Maps API 3. My first. One marker
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I have some data like this: 1 2 3 4 5 9 2 6
I am trying to loop through a bunch of documents I have to put
I have a bunch of posts stored in text files formatted in yaml/textile (from

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.