android: fixes bug reported through PlayStore system: NullPointerException while seting up Tab layout.

getTabHost would return null in some cases, moved it into onCreate, where application context is always present.
This commit is contained in:
Joachim Fritzsch 2013-07-24 13:49:10 +02:00
parent 91f3fa1bed
commit 24bc9460a7
1 changed files with 5 additions and 4 deletions

View File

@ -62,6 +62,7 @@ public class BOINCActivity extends TabActivity {
private Boolean mIsBound = false; private Boolean mIsBound = false;
private TabHost tabHost; private TabHost tabHost;
private Resources res;
// dummy jni to trigger PlayStore filter for CPU architecture // dummy jni to trigger PlayStore filter for CPU architecture
static{ static{
@ -109,6 +110,10 @@ public class BOINCActivity extends TabActivity {
// adapt to custom title bar // adapt to custom title bar
getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.title_bar); getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.title_bar);
// get tab host and setup layout
res = getResources();
tabHost = getTabHost();
setupTabLayout(); setupTabLayout();
} }
@ -221,10 +226,6 @@ public class BOINCActivity extends TabActivity {
* which tabs should be set up is defined in resources file: /res/values/configuration.xml * which tabs should be set up is defined in resources file: /res/values/configuration.xml
*/ */
private void setupTabLayout() { private void setupTabLayout() {
Resources res = getResources();
tabHost = getTabHost();
// set tabs // set tabs
if(res.getBoolean(R.bool.tab_status)) if(res.getBoolean(R.bool.tab_status))
setupTab(new TextView(this), getResources().getString(R.string.tab_status), R.drawable.icon_status_tab, StatusActivity.class); setupTab(new TextView(this), getResources().getString(R.string.tab_status), R.drawable.icon_status_tab, StatusActivity.class);