GithubHelp home page GithubHelp logo

Comments (3)

3mph4515 avatar 3mph4515 commented on June 30, 2024

Yeah, also got the same issue:
Here is problem, just NPE
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.kmshack.newsstand/com.kmshack.newsstand.MainActivity}: java.lang.NullPointerException: Attempt to invoke interface method 'void com.kmshack.newsstand.ScrollTabHolder.adjustScroll(int)' on a null object reference
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2184)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2233)
at android.app.ActivityThread.access$800(ActivityThread.java:135)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5001)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
Caused by: java.lang.NullPointerException: Attempt to invoke interface method 'void com.kmshack.newsstand.ScrollTabHolder.adjustScroll(int)' on a null object reference
at com.kmshack.newsstand.MainActivity.onPageSelected(MainActivity.java:96)
at com.astuetz.PagerSlidingTabStrip$PageListener.onPageSelected(PagerSlidingTabStrip.java:385)
at android.support.v4.view.ViewPager.setCurrentItemInternal(ViewPager.java:543)
at android.support.v4.view.ViewPager.setCurrentItemInternal(ViewPager.java:509)
at android.support.v4.view.ViewPager.onRestoreInstanceState(ViewPager.java:1282)
at android.view.View.dispatchRestoreInstanceState(View.java:12799)
at android.view.ViewGroup.dispatchRestoreInstanceState(ViewGroup.java:2637)
at android.view.ViewGroup.dispatchRestoreInstanceState(ViewGroup.java:2643)
at android.view.ViewGroup.dispatchRestoreInstanceState(ViewGroup.java:2643)
at android.view.View.restoreHierarchyState(View.java:12777)
at com.android.internal.policy.impl.PhoneWindow.restoreHierarchyState(PhoneWindow.java:1744)
at android.app.Activity.onRestoreInstanceState(Activity.java:944)
at android.app.Activity.performRestoreInstanceState(Activity.java:916)
at android.app.Instrumentation.callActivityOnRestoreInstanceState(Instrumentation.java:1138)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2162)
            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2233)
            at android.app.ActivityThread.access$800(ActivityThread.java:135)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
            at android.os.Handler.dispatchMessage(Handler.java:102)
            at android.os.Looper.loop(Looper.java:136)
            at android.app.ActivityThread.main(ActivityThread.java:5001)
            at java.lang.reflect.Method.invoke(Native Method)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)

from android-parallaxheaderviewpager.

noxius avatar noxius commented on June 30, 2024

how did you fix it?

from android-parallaxheaderviewpager.

aman400 avatar aman400 commented on June 30, 2024

I had same problem.. The reason of the problem is that, Android system start killing activities whenever there is shortage of memory, you need to save your data in onSavedInstanceState() and restore it whenever Activity/Fragment is recreated, either in onCreate or onRestoreInstanceState()..

The reason why your application crashed is that, mScrollTabHolders contains SparseArrayCompat of fragments which is not saved in onSavedInstanceState() so after restore it turns out to be null and your application throws a null pointer exception..

In order to fix this crash Instead of using an activity for ViewPager, I used activity with a fragment and moved viewPager to that fragment.
In any case main activity gets killed, Fragment inside activity is also recreated and viewPager is regenerated so mScrollTabHolders never gets nulled...

Make sure you save your data in onSavedInstanceState() for recreating your fragment..

from android-parallaxheaderviewpager.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.