I have been trying to start a new activity using a button but my application crashes

The code i use :

```
Button b = ((Button) findViewById(R.id.button1)).setOnClickListener(new OnClickListener() {
    @Override
    public void onClick(View v) {
        startActivity(new Intent(MainActivity.this, Activity2.class));
    }
});

```

But my app still crashes........