App keeps crashing while calling a method from another class

  android, class, crash, java, methods

Actually i solved this problem but somehow after a few hours of coding now its doing the same thing.
cant figure what is wrong but it crashes every time at the popup_durum is executed. The code works fine when i add it to the same class but in seperate class it crashes and i need to call this function in every page any help will be appritiated thanx advance.

  This is the class i call

public class Antreman extends AppCompatActivity {
AlertDialog.Builder dialogBuilder;
Button AntremanaBasla,Cikis;
View popup_durum;
//Pop up----------------------------------------------------------------------------------------
public void AntremanSayfasi(){

    dialogBuilder = new AlertDialog.Builder(this);
    popup_durum = getLayoutInflater().inflate(R.layout.popup_durum,null);
    AntremanaBasla = popup_durum.findViewById(R.id.basla);
    Cikis = popup_durum.findViewById(R.id.cikis);

    dialogBuilder.setView(popup_durum);
    AlertDialog dialog = dialogBuilder.create();
    dialog.show();

    AntremanaBasla.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            dialog.dismiss();
        }
    });
    Cikis.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            dialog.dismiss();
        }
    });

}

and this is the call function

public class Login extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
       -----------
    Antreman antreman = new Antreman();
    logoImage = (ImageView) findViewById(R.id.logologin);
    logoImage.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {

            antreman.AntremanSayfasi();
        }
    });
}

}

edit
Application starts with this log

2021-04-05 20:09:29.151 10257-10292/gymholix.assistx D/EGL_emulation: eglCreateContext: 0xa2085120: maj 3 min 0 rcv 3
2021-04-05 20:09:29.160 10257-10292/gymholix.assistx D/EGL_emulation: eglMakeCurrent: 0xa2085120: ver 3 0 (tinfo 0xa20832d0)
2021-04-05 20:09:29.168 10257-10292/gymholix.assistx E/eglCodecCommon: glUtilsParamSize: unknow param 0x00008cdf
2021-04-05 20:09:29.169 10257-10292/gymholix.assistx E/eglCodecCommon: glUtilsParamSize: unknow param 0x00008cdf
2021-04-05 20:09:29.169 10257-10292/gymholix.assistx E/eglCodecCommon: glUtilsParamSize: unknow param 0x00008824
2021-04-05 20:09:29.169 10257-10292/gymholix.assistx E/eglCodecCommon: glUtilsParamSize: unknow param 0x00008824
2021-04-05 20:09:29.202 10257-10292/gymholix.assistx D/EGL_emulation: eglMakeCurrent: 0xa2085120: ver 3 0 (tinfo 0xa20832d0)
2021-04-05 20:09:29.240 10257-10292/gymholix.assistx D/EGL_emulation: eglMakeCurrent: 0xa2085120: ver 3 0 (tinfo 0xa20832d0)
2021-04-05 20:09:29.252 10257-10292/gymholix.assistx D/EGL_emulation: eglMakeCurrent: 0xa2085120: ver 3 0 (tinfo 0xa20832d0)
2021-04-05 20:09:29.259 10257-10292/gymholix.assistx D/EGL_emulation: eglMakeCurrent: 0xa2085120: ver 3 0 (tinfo 0xa20832d0)

then when it crashes log is like that

2021-04-05 20:09:29.259 10257-10292/gymholix.assistx D/EGL_emulation: eglMakeCurrent: 0xa2085120: ver 3 0 (tinfo 0xa20832d0)
2021-04-05 20:10:46.808 10257-10292/gymholix.assistx D/EGL_emulation: eglMakeCurrent: 0xa2085120: ver 3 0 (tinfo 0xa20832d0)
2021-04-05 20:10:52.673 10257-10257/gymholix.assistx D/AndroidRuntime: Shutting down VM
2021-04-05 20:10:52.674 10257-10257/gymholix.assistx E/AndroidRuntime: FATAL EXCEPTION: main
    Process: gymholix.assistx, PID: 10257
    java.lang.NullPointerException: Attempt to invoke virtual method 'android.content.pm.ApplicationInfo android.content.Context.getApplicationInfo()' on a null object reference
        at android.content.ContextWrapper.getApplicationInfo(ContextWrapper.java:152)
        at android.view.ContextThemeWrapper.getTheme(ContextThemeWrapper.java:157)
        at androidx.appcompat.app.AlertDialog.resolveDialogTheme(AlertDialog.java:115)
        at androidx.appcompat.app.AlertDialog$Builder.<init>(AlertDialog.java:313)
        at gymholix.assistx.Antreman.AntremanSayfasi(Antreman.java:23)
        at gymholix.assistx.Login$3.onClick(Login.java:76)
        at android.view.View.performClick(View.java:6256)
        at android.view.View$PerformClick.run(View.java:24701)
        at android.os.Handler.handleCallback(Handler.java:789)
        at android.os.Handler.dispatchMessage(Handler.java:98)
        at android.os.Looper.loop(Looper.java:164)
        at android.app.ActivityThread.main(ActivityThread.java:6541)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)

Source: Android Questions

LEAVE A COMMENT