Toolbar onBackPressed
<p>I have a camera preview on my class. 
When I click back button, it return to mainClass. If I click on the camera preview button it go back to camera preview and works ok.</p>

<p>When I click the Toolbar back button it return to mainClass. if i click on the camera preview button it shows this error. </p>

<pre><code>FATAL EXCEPTION: main
03-16 10:33:00.271 1916-1916/org.example.ricardo.tcc2 E/AndroidRuntime:     Process: org.example.ricardo.tcc2, PID: 1916
03-16 10:33:00.271 1916-1916/org.example.ricardo.tcc2 E/AndroidRuntime: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.hardware.Camera.setPreviewDisplay(android.view.SurfaceHolder)' on a null object reference
</code></pre>

<p>MainClass -> previewClass -> backPressed -> MainClass -> previewClass = ok</p>

<p>MainClass -> previewClass -> toolbarBack -> MainClass -> previewClass = error</p>

<pre><code>Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);

    if (getSupportActionBar() != null){
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);
       // getSupportActionBar().setDisplayShowHomeEnabled(true);
        toolbar.setNavigationOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                onBackPressed();
            }
        });
    }
</code></pre>