Android OnResume not called when using TabHost and LocalActivityManager

I created a tabhost with two actions, and since I could not use TabActivity, I used the LocalActivityManager, but when I switch the tabs onResume is not called for the actions on the tabs. Here is my setup:

mlam = new LocalActivityManager(this, false); mlam.dispatchCreate(savedInstanceState); tabHost = (TabHost) findViewById(android.R.id.tabhost); tabHost.setup(mlam); 

I have dispatchResume and dispatchPause placed in the appropriate places, but they only work when the main activity of the tab gets onResume or onPause. I tried to solve my problem by firing the dispatch reception to replace the woman, but it looks like he is not shooting.

 tabHost.setOnTabChangedListener(new OnTabChangeListener(){ public void onTabChanged(String tabId) { mlam.dispatchResume(); } }); 

Does anyone know how to make sure that onResume is launched for actions so that I can update the contents on the tabs as I select them?

+4
source share
1 answer

You must initialize mlam with the second parameter true: mlam = new LocalActivityManager (this, true);

And then only one action resumes after some time in tabhost.

+2
source

Source: https://habr.com/ru/post/1388360/


All Articles