I've an android app which has TabLayout like this :
Each tab loads a Fragment and there 6 such tabs.
It has also navigation drawer like this :
on click of the options a new Activity gets open.
There are also few buttons on the Toolbar and on click of which new Activity gets open.
The app has also the Sliding up panel like this :
The problem is that when I open the app then after few seconds it shows me :
when this comes I can see in the logcat that
The application may be doing too much work on its main thread
The solution for it is given here
(this message occurs only on some of the devices) when we click on "OK" then the app continues to run but again after few seconds the same message pops up. I've noticed one more thing that when I leave the app open for longer period of time then this message doesn't come and app runs smoothly.
I want to know does the other Activities also gets loaded to run on main UI thread when we open the android app?
I think that the Fragments used in the ViewPager will get loaded on main UI thread when we open the app.
The code to add Fragments to ViewPager is like this :
tabLayout = (TabLayout) findViewById(R.id.tabLayout);
viewPager = (ViewPager) findViewById(R.id.viewPager);
viewPagerAdapter = new ViewPagerAdapter(getSupportFragmentManager());
viewPagerAdapter.addFragments(new HomeFragment(), "Home");
viewPagerAdapter.addFragments(new TrendingFragment(), "Best Deals");
viewPagerAdapter.addFragments(new HomeServicesFragment(), "Home Services");
viewPagerAdapter.addFragments(new EntertainmentFragment(), "Entertainment");
viewPagerAdapter.addFragments(new FashionFragment(), "Fashion");
viewPagerAdapter.addFragments(new VehicleServicesFragment(), "Vehicle Services");
viewPagerAdapter.addFragments(new OthersFragment(), "Other Services");
viewPager.setAdapter(viewPagerAdapter);
tabLayout.setupWithViewPager(viewPager);
Also I want to know if I can use AsyncTask to load this TabLayout? Again I don't know which line are responsible for UI updation in above code. I'm not sure if doing this will help resolving the issue or not?