Problems referencing an Object

1

I am calling a class that I have already used, I have instantiated it and in my Login fragment if it runs normally but in my Client_Visit fragment I get an error:

E/AndroidRuntime: FATAL EXCEPTION: main
                  Process: sie.progrsistepinsa.sie_android, PID: 13567
                  java.lang.NullPointerException: Attempt to invoke virtual method 'void sie.progrsistepinsa.sie_android.M_Menu$Time_Stop.Sen_Msg_Function(sie.progrsistepinsa.sie_android.Herramt_Cli.Clas_ArrayList)' on a null object reference
                      at sie.progrsistepinsa.sie_android.AsisTec.Frg_Client_Visit.Carg_Formulario(Frg_Client_Visit.java:87)
                      at sie.progrsistepinsa.sie_android.AsisTec.Frg_Client_Visit.onCreateView(Frg_Client_Visit.java:196)

1.- In this way, I call in my Login fragment (it appears correctly):

Through the Clas_ArrayList I call (List_Mens); what do I want and below I leave it in the code)

M_Menu.Time_Stop Tim;//asi llamo a la clase en la parte superior



 Logi.setOnClickListener ( new View.OnClickListener () {
            @Override
            public void onClick(View view) {
                if(VerificacionUsuario()){
                    // <editor-fold defaultstate="collapsed" desc="Time_Stop 3 Carg_Verificar_User">
                    Clas_ArrayList List_Mens = new Clas_ArrayList();
                    List_Mens.Set_ArrayLst_Dato("Datos");//Titulo  0
                    List_Mens.Set_ArrayLst_Dato(Cls_Let.Get_Nombre_Formulario());//Formulario  1
                    List_Mens.Set_ArrayLst_Dato("Carg_Verificar_Acceso");//Funcion  2
                    // <editor-fold defaultstate="collapsed" desc="Set_User">
                    ArrayList<Object> Set_User=new ArrayList<>();
                    Set_User.add(Cls_Let.Get_String_Null_Mayu(CodUser));
                    Set_User.add("FR0009");//Cod Formulario//para el permiso de fechas
                    // </editor-fold>
                    List_Mens.Set_ArrayLst_Dato(Set_User);//Datos  3
                    List_Mens.Set_ArrayLst_Dato(Get_List_Access("Carg_Verificar_Acceso",
                            "Logeandote para entrar al sistema"));//Acceso  4
                    List_Mens.Set_ArrayLst_Dato(CodUser);//Cod Usuario 5
                    // </editor-fold>
                    Tim.Sen_Msg_Function ( List_Mens );
                    ShowProgressBar () ;
                }
            }
        } );

2 .- And here I want to call the same class but in my fragment Client_Visit: (does not come out)

M_Menu.Time_Stop Tim;//asi llamo a la clase en la parte superior


 Clas_ArrayList List_Mens = new Clas_ArrayList();
        List_Mens.Set_ArrayLst_Dato("Datos");//Titulo  0
        List_Mens.Set_ArrayLst_Dato(Cls_Let.Get_Nombre_Formulario());//Formulario  1
        List_Mens.Set_ArrayLst_Dato("Carg_Permiso_Form");//Funcion  2
        // <editor-fold defaultstate="collapsed" desc="Per_Form">
        ArrayList<Object> Per_Form = new ArrayList<>();
        Per_Form.add(List_User.Get_Dat_StrxObj(2));//Cod User
        Per_Form.add(CodFormu);//Cod Formulario
        // </editor-fold>
        List_Mens.Set_ArrayLst_Dato(Per_Form);//Datos  3
        List_Mens.Set_ArrayLst_Dato(Get_List_Access("Carg_Permiso_Form",
                "cargando los eventos que tiene este usuario"));//Acceso  4
        List_Mens.Set_ArrayLst_Dato(List_User.Get_Dat_StrxObj(2));//Cod Usuario 5
        List_Mens.Set_ArrayLst_Dato("Cargando Permisos");//Mensaje Jprog 6
        // </editor-fold>
        Tim.Sen_Msg_Function ( List_Mens );
        Tim.Time_Stop_Init(15);

I do exactly the same, the same steps and I do not understand why the error.

    
asked by Bloom 04.08.2018 в 00:41
source

2 answers

0

Thanks for the help and yes, I found the problem, what happened was that I was trying to call a class and in part if I knew that through a Drawer I passed the method directly but the other did not I took it because I was already out ... what I'm going for is that my solution was to publish my method that I was using and make it static so that it is a global variable.

1 .- (in the Main activity-- e main where it is born) public static Time_Stop Tim;

2.- (in the class where I want to pull it)  M_Menu.Time_Stop Tim = M_Menu.Tim;

(with this I am telling you to take the method from the main menu)

    
answered by 07.08.2018 / 01:19
source
0

That error occurs when you are trying to reference an object that does not exist, that is, when you try to show a value and / or result in some TextView or ListView and it has not been created or id is incorrect, you should review the calls to the View you make and see that they are all created and they are correct.

    
answered by 06.08.2018 в 14:31