2

I am using FragmentStatePagerAdapter, in that i have 7 pages. If i open any activity from one of these fragments then it gets opened instantly. But if i try to click on back press. Then opened activity takes few seconds to kill that activity and reload the fragment. I have done nothing in on resume or in on back press. On debug i found that setPrimaryItem() and getCount() of adapter is called for 2-3 times and after that it finished my activity.

Can any one provide me work around for this. Activity should be killed instantly without any delay.

Harneet Kaur
  • 4,487
  • 1
  • 16
  • 16
  • Please provide some code – Lampione Dec 23 '16 at 07:16
  • Its in my project so cannot. It is simple FragmentStatePagerAdapter, and from added fragment open activity and click on back press. – Harneet Kaur Dec 23 '16 at 07:18
  • 1
    Do you realize that it's impossible to find a solution to this problem without code snipped as @Matteo asked? There are numerous reasons why it can be slow and it's up to your implementation, not by android design. However, ViewPager is recreated adapter is restoring each fragment and each fragment goes through the initialization process. I guess that you have some heavy actions on the UI thread in each fragment which blocks it. – bajicdusko Dec 23 '16 at 08:04

0 Answers0