Android Performance Issue- TabHost - Timer - SetCurrentTab() - Google Maps Api V2

好久不见. 提交于 2020-01-07 08:12:08

问题


As i said in title i 've got a performance issue on my Android application. I've got a public static tabhost and a timer and a Google Maps. Timer scheduled to work every 3 seconds. It 's updating something according to my WebService which is related to database.

For example if my web service response equals to "1" then i'm switching tab 0 otherwise 1. In this case when i switch to google maps which is in tab 1 with this update everything is ok. When a second update came with a result of "0" i'm setting current tab to 0. In this tab, activity performance is ok. Then i entered subactivities which placed on this tab everything is ok again. But when i'm trying to go back with "Back" button it costs me for 3 or 4 seconds to go back (to tab 0)

What's wrong with that ?

                    if(response.equals("1"))
                    {
                        if(CTSMainActivity.tabHost.getCurrentTab()!=0)
                            CTSMainActivity.tabHost.setCurrentTab(0);
                    }
                    else if(response.equals("0"))
                    {
                        if(CTSMainActivity.tabHost.getCurrentTab()!=1)
                            CTSMainActivity.tabHost.setCurrentTab(1);
                    }

Any help will be appreciated.

Edit :

I just googled for it and got something. I used DDMS method profiling tool and saw android/widget/Listview.measureHeightofChildren(IIII)I process is using 3.7 seconds. What 's the solution of it ?

Edit :

I kinda find a solution please follow this link : Android - Remove Google Maps Fragment onPause and add back onResume


回答1:


I've solved this issue with removing tabHost. And using activities with new Intent(); Please refer this url : Android - Remove Google Maps Fragment onPause and add back onResume



来源:https://stackoverflow.com/questions/16262328/android-performance-issue-tabhost-timer-setcurrenttab-google-maps-api-v

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!