简体   繁体   中英

Fragment doesn't initialize when Activity in background

Fragments in ViewPager doesn't initialize when parent activity in background.

My Application's Tree:

MainActivity
 >FragmentViewPager
   >Fragment1
    >FragmentViewPager
      >FragmentA, B, C
   >Fragment2
SplashActivity

In my case, MainActivity start with SplashActivity . (SplashActivity started from MainActivity's onCreate)

Fragment 1 and 2 has been initialized, But Fragment A, B and C dosen't initializing. they only going to initialize when MainActivity on the foreground.

To solve the issue, you can initiate your FragmentA,B,C from methods @Override onActivityCreated(...) In Fragment1 .

Hope this help!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM