Skip to content

Fatal Exception: java.lang.NullPointerException: Attempt to invoke virtual method 'void com.github.kevinejohn.keyevent.KeyEventModule.onKeyDownEvent(int, android.view.KeyEvent)' on a null object reference #86

Description

@ismaelsousa

Crashlytics - Stack trace

Fatal Exception: java.lang.NullPointerException: Attempt to invoke virtual method 'void com.github.kevinejohn.keyevent.KeyEventModule.onKeyDownEvent(int, android.view.KeyEvent)' on a null object reference

How to reproduce it

  1. Hold the button up/down
  2. Open the app by holding the button
  3. The app will crash

How to fix it

check if the instance has been initiated already

@Override
public boolean onKeyUp(int keyCode, KeyEvent event) {
    if(KeyEventModule.getInstance() != null) {
        KeyEventModule.getInstance().onKeyUpEvent(keyCode, event);
    }
    
    super.onKeyUp(keyCode, event);
    
    return true;
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions