Q:

java.lang.NullPointerException when a try to invoke setContentView in a class to extends MainActivity

sorry for my bad English, this is the deal, I'm traying to adapt a QR code scanner with ZXingScanner Library, but I have this issue.
    java.lang.NullPointerException: Attempt to invoke virtual method 'android.view.Window$Callback android.view.Window.getCallback()' on a null object reference

first of all, send the context to the second one which extends to Mainactivity.

Mainactivity

//cast floatingbutton

  FloatingButton = (FloatingActionButton) findViewById(R.id.A1);
    View.OnClickListener l = new Eventoqr(this);
    FloatingButton.setOnClickListener(l);

Eventoqr  class

    public class Eventoqr extends MainActivity implements View.OnClickListener, ZXingScannerView.ResultHandler

//method that implements start camera

public void QRscan(View vista)
{
    Log.e("Inicio de camara", cntx.toString());
    MyscannerView = new ZXingScannerView(cntx);
    setContentView(MyscannerView); /* Error generates here
}

I hope someone can help me whit this, thanks any way.

A:

Obviously, your android.view.Window is null, could you provide this call inside your code?

