Skip to content Skip to sidebar Skip to footer

Singleton Method Gives Error In Onresum (android)

I have a problem that I could not understand why it is happening. I have a fragment, and in the fragment I have the on resume method as below: @Override public void onResume(){

Solution 1:

    @Override
    public void onActivityCreated(@Nullable Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
        System.out.println("number 1");
        int s = ((MainApplication) this.getActivity().getApplication()).getRefreshNotificationVar();
        System.out.println("number 2");
        s = s + 1;
        System.out.println("number 3");
        ((MainApplication) this.getActivity().getApplication()).setRefreshNotificationVar(s);
        System.out.println("number 4");
        System.out.println(s);
    }

Looks Like Activity Instance is null . Instead of onresume do the same operation on onActivityCreated Method . Please refer the above code.


Post a Comment for "Singleton Method Gives Error In Onresum (android)"