So I am confused and I don't know how to fix the error crashlytics and google playstore keep saying my users are having. Here is my code:
if (event.getEventType() == AccessibilityEvent.TYPE_NOTIFICATION_STATE_CHANGED) {
Notification notification = (Notification) event.getParcelableData();
String text = "";
if (notification.extras.getString(Notification.EXTRA_TEXT) != null){
text = notification.extras.getString(Notification.EXTRA_TEXT);
}
if (text != null) {
if (text.equals("You have been idle, would you like to stay online?")
startApp();
{
But crashlytics and google playstore say that I am referencing null Fatal Exception: java.lang.NullPointerException: Attempt to read from field 'android.os.Bundle android.app.Notification.extras' on a null object reference
, how is this possible when I am checking for null first? Here is the full error code:
Fatal Exception: java.lang.NullPointerException: Attempt to read from field 'android.os.Bundle android.app.Notification.extras' on a null object reference
at com.gonow.services.AutoService.onAccessibilityEvent(Unknown Source)
at android.accessibilityservice.AccessibilityService$2.onAccessibilityEvent(AccessibilityService.java:1472)
at android.accessibilityservice.AccessibilityService$IAccessibilityServiceClientWrapper.executeMessage(AccessibilityService.java:1608)
at com.android.internal.os.HandlerCaller$MyHandler.handleMessage(HandlerCaller.java:37)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6823)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1563)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1451)
I have already looked at this: What is a NullPointerException, and how do I fix it?