0

Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void com.andremion.counterfab.CounterFab.setCount(int)' on a null object reference

Code

@Override
protected void onResume() {
    super.onResume();

   fab.setCount(new Database(getBaseContext()). getCountCart());

    if (adapter!=null )
    {
        adapter.startListening();
    }
}
Jitesh Prajapati
  • 2,605
  • 4
  • 25
  • 45
MANESH K
  • 13
  • 5

1 Answers1

1

It seems that you did not initialize the fab variable. Thus you receive a NullPointerException. As this variable seems to be global, you should at any place initialize the fab variable in your code before you call functions on it. Since you use it already in the onResume() function, you'd best initialize it in your onCreate()

Chris623
  • 2,239
  • 1
  • 19
  • 28