react-native-keyevent
react-native-keyevent copied to clipboard
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
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
- Hold the button up/down
- Open the app by holding the button
- 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;
}