Open gitanuj opened 6 years ago
For example it happens on the following fragment when user taps button to enable "Notification Access" which opens the Settings app. Then for some reason my app's Activity is removed from memory and user comes back to the Activity without enabling the permission.
Steps:
Looks like getActivity() is null at the moment. A simple fix could be to just ignore the call if it's null.
Exception java.lang.RuntimeException: Unable to start activity ComponentInfo{com.tanuj.nowplayinghistory/com.tanuj.nowplayinghistory.activities.IntroActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String android.support.v4.app.FragmentActivity.getString(int)' on a null object reference android.app.ActivityThread.performLaunchActivity (ActivityThread.java:2778) android.app.ActivityThread.handleLaunchActivity (ActivityThread.java:2856) android.app.ActivityThread.-wrap11 () android.app.ActivityThread$H.handleMessage (ActivityThread.java:1589) android.os.Handler.dispatchMessage (Handler.java:106) android.os.Looper.loop (Looper.java:164) android.app.ActivityThread.main (ActivityThread.java:6494) java.lang.reflect.Method.invoke (Method.java) com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:438) com.android.internal.os.ZygoteInit.main (ZygoteInit.java:807) Caused by java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String android.support.v4.app.FragmentActivity.getString(int)' on a null object reference agency.tango.materialintroscreen.listeners.MessageButtonBehaviourOnPageSelected.pageSelected (MessageButtonBehaviourOnPageSelected.java:32) agency.tango.materialintroscreen.listeners.ViewBehavioursOnPageChangeListener.onPageSelected (ViewBehavioursOnPageChangeListener.java:61) android.support.v4.view.CustomViewPager.dispatchOnPageSelected (CustomViewPager.java:1939) android.support.v4.view.CustomViewPager.setCurrentItemInternal (CustomViewPager.java:666) android.support.v4.view.CustomViewPager.setCurrentItemInternal (CustomViewPager.java:632) android.support.v4.view.CustomViewPager.onRestoreInstanceState (CustomViewPager.java:1454) android.view.View.dispatchRestoreInstanceState (View.java:17706) android.view.ViewGroup.dispatchRestoreInstanceState (ViewGroup.java:3745) android.view.ViewGroup.dispatchRestoreInstanceState (ViewGroup.java:3751) android.view.ViewGroup.dispatchRestoreInstanceState (ViewGroup.java:3751) android.view.ViewGroup.dispatchRestoreInstanceState (ViewGroup.java:3751) android.view.ViewGroup.dispatchRestoreInstanceState (ViewGroup.java:3751) android.view.ViewGroup.dispatchRestoreInstanceState (ViewGroup.java:3751) android.view.View.restoreHierarchyState (View.java:17684) com.android.internal.policy.PhoneWindow.restoreHierarchyState (PhoneWindow.java:2131) android.app.Activity.onRestoreInstanceState (Activity.java:1102) android.app.Activity.performRestoreInstanceState (Activity.java:1057) android.app.Instrumentation.callActivityOnRestoreInstanceState (Instrumentation.java:1260) android.app.ActivityThread.performLaunchActivity (ActivityThread.java:2751) android.app.ActivityThread.handleLaunchActivity (ActivityThread.java:2856) android.app.ActivityThread.-wrap11 () android.app.ActivityThread$H.handleMessage (ActivityThread.java:1589) android.os.Handler.dispatchMessage (Handler.java:106) android.os.Looper.loop (Looper.java:164) android.app.ActivityThread.main (ActivityThread.java:6494) java.lang.reflect.Method.invoke (Method.java) com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:438) com.android.internal.os.ZygoteInit.main (ZygoteInit.java:807)