Null pointer exception in Android caused by a button : <p>My Activity class looks like that:</p>

<pre><code>public class FullscreenActivity extends AppCompatActivity {
    private Button btnTakePhoto = new Button(this);
    private Button btnRecordVideo = new Button(this);

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);

        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_fullscreen);

        btnTakePhoto = (Button) findViewById(R.id.btnTakePhoto);
        btnTakePhoto.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                helloWorldKamera();
            }
        });
    }

    public void helloWorldKamera() {
        System.out.println("Kamera");
    }

}
</code></pre>

<p>My <code>activity_fullscreen.xml</code> file looks like that:</p>

<pre><code>&lt;FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#ffffff"&gt;

    &lt;LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical"&gt;

        &lt;Button
            android:text="Foto"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_weight="0.5"
            android:id="@+id/btnTakePhoto" /&gt;

        &lt;Button
            android:text="Video"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_weight="0.5"
            android:id="@+id/btnRecordVideo"
            /&gt;
    &lt;/LinearLayout&gt;
&lt;/FrameLayout&gt;
</code></pre>

<p>Now I get the following error:<br>
<code>java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.Button.setOnClickListener(android.view.View$OnClickListener)' on a null object reference</code>.<br>
Do you know how to fix the null pointer exception? I don't know why my button is null.<br>
Is it right how I initialize the button or is the error caused by <code>findViewById</code>?</p>
