I'm having reasonable success with notifications and fragments in my Android App although occasionally I get an error, as shown below, in my Firebase error log
Although it rarely occurs, about 5-6 per 10,000 notifications over 3 months to the app, it is a bit annoying because the notification is lost (maybe that's an acceptable level of crashes!)
I'd love to fix it in my code if I could, but I don't quite understand what this log is telling me
Does it mean anything to you..? Any help appreciated
NullPointerException - FragmentManagerImpl.execSingleAction
Exception java.lang.NullPointerException:
android.support.v4.app.FragmentManagerImpl.execSingleAction (FragmentManager.java:1623)
android.support.v4.app.BackStackRecord.commitNowAllowingStateLoss (BackStackRecord.java:637)
android.support.v4.app.FragmentPagerAdapter.finishUpdate (FragmentPagerAdapter.java:143)
android.support.v4.view.ViewPager.setAdapter (ViewPager.java:511)
com.support.android.policeman.MainActivity.setupViewPager (MainActivity.java:156)
com.support.android.policeman.MainActivity.refreshFragments (MainActivity.java:454)
com.support.android.policeman.MainActivity$7.run (MainActivity.java:425)
android.os.Handler.handleCallback (Handler.java:730)
android.os.Handler.dispatchMessage (Handler.java:92)
android.os.Looper.loop (Looper.java:176)
android.app.ActivityThread.main (ActivityThread.java:5419)
java.lang.reflect.Method.invokeNative (Method.java)
java.lang.reflect.Method.invoke (Method.java:525)
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run (ZygoteInit.java:1046)
com.android.internal.os.ZygoteInit.main (ZygoteInit.java:862)
dalvik.system.NativeStart.main (NativeStart.java)
Ok, so I'm a bit of a novice. However, thanks @altskop for the tip on how to understand this log and below is the bit of code where it is throwing the fatal error (viewPager.setAdapter(adapter) is line 156 to be exact)
private void setupViewPager(ViewPager viewPager) {
Adapter adapter = new Adapter(getSupportFragmentManager());
adapter.addFragment(new SenderListFragment(), "Loopy");
adapter.addFragment(new MessageListFragment(), "Poopy");
adapter.addFragment(new ContactListFragment(), "Scoopy");
viewPager.setAdapter(adapter);
}
Is there a reason why the new adapter create wouldn't work, and if it returns null, what can I do..?