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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T21:31:45+00:00 2026-06-06T21:31:45+00:00

I have been following a tutorial on youtube for surfaceview with a thread in

  • 0

I have been following a tutorial on youtube for surfaceview with a thread in it.

i have copied exactly what the code shows in the tutorial, but when i run it it crashes when it should work..
here is surface class in my code:

it says nullpointerexpection at resume();

public class dfgfActivity extends Activity implements OnTouchListener 
{
    OurView v;
    protected void OnCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    v = new OurView(this);
    v.setOnTouchListener(this);
    setContentView(v);

}




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




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




public class OurView extends SurfaceView implements Runnable
{
    Thread t=null;
    SurfaceHolder holder;
    boolean isItOK=false;

    public OurView(Context context) {
        super(context);
        // TODO Auto-generated constructor stub
        holder = getHolder();
    }

    public void run() {
        // TODO Auto-generated method stub
        while (isItOK) {
            if (!holder.getSurface().isValid()) {
                continue;
            }

            Canvas c = holder.lockCanvas();
            c.drawARGB(255, 255, 10, 200);
            holder.unlockCanvasAndPost(c);
        }

    }

    public void pause() {
        isItOK = false;
        while (true) {
            try {
                t.join();
            }
            catch (InterruptedException e) {
                e.printStackTrace();    
            }
            break;
        }
        t = null;
    }

    public void resume() {
        isItOK = true;
        t = new Thread(this);
        t.start();

    }

}




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

}

07-02 18:55:48.585: D/AndroidRuntime(684): Shutting down VM
07-02 18:55:48.595: W/dalvikvm(684): threadid=3: thread exiting with uncaught exception (group=0x4001b188)
07-02 18:55:48.595: E/AndroidRuntime(684): Uncaught handler: thread main exiting due to uncaught exception
07-02 18:55:48.665: E/AndroidRuntime(684): java.lang.RuntimeException: Unable to resume activity {fdgfd.dfgfdg/fdgfd.dfgfdg.dfgfActivity}: java.lang.NullPointerException
07-02 18:55:48.665: E/AndroidRuntime(684):  at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2950)
07-02 18:55:48.665: E/AndroidRuntime(684):  at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:2965)
07-02 18:55:48.665: E/AndroidRuntime(684):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2516)
07-02 18:55:48.665: E/AndroidRuntime(684):  at android.app.ActivityThread.access$2200(ActivityThread.java:119)
07-02 18:55:48.665: E/AndroidRuntime(684):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1863)
07-02 18:55:48.665: E/AndroidRuntime(684):  at android.os.Handler.dispatchMessage(Handler.java:99)
07-02 18:55:48.665: E/AndroidRuntime(684):  at android.os.Looper.loop(Looper.java:123)
07-02 18:55:48.665: E/AndroidRuntime(684):  at android.app.ActivityThread.main(ActivityThread.java:4363)
07-02 18:55:48.665: E/AndroidRuntime(684):  at java.lang.reflect.Method.invokeNative(Native Method)
07-02 18:55:48.665: E/AndroidRuntime(684):  at java.lang.reflect.Method.invoke(Method.java:521)
07-02 18:55:48.665: E/AndroidRuntime(684):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
07-02 18:55:48.665: E/AndroidRuntime(684):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
07-02 18:55:48.665: E/AndroidRuntime(684):  at dalvik.system.NativeStart.main(Native Method)
07-02 18:55:48.665: E/AndroidRuntime(684): Caused by: java.lang.NullPointerException
07-02 18:55:48.665: E/AndroidRuntime(684):  at fdgfd.dfgfdg.dfgfActivity.onResume(dfgfActivity.java:42)
07-02 18:55:48.665: E/AndroidRuntime(684):  at android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1149)
07-02 18:55:48.665: E/AndroidRuntime(684):  at android.app.Activity.performResume(Activity.java:3763)
07-02 18:55:48.665: E/AndroidRuntime(684):  at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2937)
07-02 18:55:48.665: E/AndroidRuntime(684):  ... 12 more
07-02 18:55:48.716: I/dalvikvm(684): threadid=7: reacting to signal 3
07-02 18:55:48.716: E/dalvikvm(684): Unable to open stack trace file '/data/anr/traces.txt': Permission denied
  • 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-06T21:31:47+00:00Added an answer on June 6, 2026 at 9:31 pm

    In your method onCreate() the method is written using capital case: OnCreate(). Try to change it to small case.

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

Sidebar

Related Questions

I have been playing with the source code available from the following tutorial .
i have been following apps snowfall tutorial, but i am getting some issue in
http://developer.android.com/training/basics/firstapp/building-ui.html I have been following this tutorial, but I have two errors, both R
I am new to Symfony2 and I have been following the symblog tutorial But
I am new to Django & Python and have been following a tutorial, but
I have been following a tutorial on how to write a basic tile map
I have been following the tutorial on Microsofts website and they use GameTime to
I'm a newcomer to Rails, and have been following the tutorial on the rails
I have been following the affableBean tutorial from the NetBeans site located here .
I have been following a short tutorial to build a tab menu on my

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.