Why Am I Getting This Error In Threads?
I have used the correct syntax, but it seems there is some error! 🙁
Here is the Screenshot ==> http://i.imgur.com/ccPOz.png?1
EDIT: Here’s the code:
`
package com.pc.threads;
import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.view.Menu;
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Thread music_2 = new Thread(){
try{
}catch(InterruptedException e){
e.printStackTrace();
}finally{
Intent music_i = new Intent(MainActivity.this,NewActivity.class);
}
};
}
`
In Java, code goes inside methods. When you define (inline) your thread class, you forgot to define a method “run” that wraps your code.