Note that there are some explanatory texts on larger screens.

plurals
  1. POthread causing application to crash
    text
    copied!<p>EDIT:</p> <p>just incase you read this i got the problem sorted i had gotten confused by my layouts and was editing the wrong one when i realised this all was sorted!</p> <p>END EDIT!</p> <p>every time i add a thread to my application it causes it to crash when the activity containing the thread is called below is the code piece containing the thread: </p> <pre><code>public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.cam); Toast t = Toast.makeText(this, "Just Click The Magnifying Glass To Search", 5000); //creates a new pop up message that lasts for 5 seconds t.setGravity(Gravity.CENTER|Gravity.CENTER, 0, 0); t.show(); bt = (ImageButton)findViewById(R.id.button); //creates instance of button bt.setOnClickListener(search); //starts an on click listener for button preview = (SurfaceView)findViewById(R.id.myview); //creates instance of surfaceview previewHolder = preview.getHolder(); //creates a surfaceholder previewHolder.addCallback(this); //sets surfaceholder callback as the activity previewHolder.setType(3); //sets the type to SURFACE_TYPE_PUSH_BUFFERS th = new Thread() { public void run() { handler.post(new Runnable() { public void run() { tv.setVisibility(0); } }); } }; th.start(); } </code></pre> <p>if anyone could shed some light on the situation it would be greatly appreciated</p> <p>EDIT:</p> <p>i have got the thread working and got it to call a method which creates Toast however when i try to modify a setting of the textview it throws an NullPointerException error</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload