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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T01:27:46+00:00 2026-06-01T01:27:46+00:00

Have been looking on some tutorials for drawing canvas using SurfaceView, but the only

  • 0

Have been looking on some tutorials for drawing canvas using SurfaceView, but the only thing that shows up is a black background.

public class FighterActivity extends Activity implements OnTouchListener {
    /** Called when the activity is first created. */
    SurfaceController surface;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        surface = new SurfaceController(this);
        surface.setOnTouchListener(this);
        setContentView(surface);
    }

    @Override
    protected void onPause() {
        // TODO Auto-generated method stub
        super.onPause();
        surface.pause();
    }

    @Override
    protected void onResume() {
        // TODO Auto-generated method stub
        super.onResume();
        surface.resume();
    }

    public class SurfaceController extends SurfaceView implements Runnable{

        Thread thread = null;
        SurfaceHolder holder;

        public SurfaceController(Context context) {
            super(context);
            // TODO Auto-generated constructor stub
            holder = getHolder();
            System.out.println("HERE");
        }

        public void run() {
            // TODO Auto-generated method stub
            System.out.println("Hello World2");
            while(true){
                if(!holder.getSurface().isValid()){
                    System.out.println("NOT VALID");
                    continue;
                }
                System.out.println("VALID!");
                Canvas can = holder.lockCanvas();
                can.drawARGB(255, 150, 150, 0);
                holder.unlockCanvasAndPost(can);
            }
        }

        public void pause(){

        }

        public void resume(){

        }

    }

    public boolean onTouch(View view, MotionEvent me) {
        // TODO Auto-generated method stub
        return false;
    }
}

It gets to the System.out.println(“HERE”); and prints out HERE, but nothing more happends, In other words the thread does not get started since “Hello World2” is not printed, what is the problem?

Thanks for any help

  • 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-01T01:27:48+00:00Added an answer on June 1, 2026 at 1:27 am

    I’m assuming you’re building off of this: http://android-coding.blogspot.ca/2011/05/drawing-on-surfaceview.html

    You’ll notice there the onResumeMySurfaceView and onPauseMySurfaceView (resume and pause in your SurfaceController, respectively) start the actual thread. You’ll need to do that in your code, too, e.g. in SurfaceController:

    protected boolean running = false;
    
    public void resume() {
        running = true;
        thread = new Thread(this);
        thread.start();
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've been looking at some server logs using tail -f recently, and have thought
I have been working with Xcode 4.2.1, but following some tutorials and videos from
I have been looking at using JOGL to create some things and have been
I have been looking at EasyMock and tutorials/examples around using it for Unit Testing
I have been looking through some code on an open source project recently and
I have been looking in to doing some test driven development for one of
I have been looking around on the web and found some articles about the
I have been looking for an answer for some time now, hope you could
I am looking for some input on something I have been thinking about for
I've been writing some jQuery functions that have JavaScript variables and looping, etc inside

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.