From 24bc9460a75bda3999e5c038fd58e7a7895038b7 Mon Sep 17 00:00:00 2001 From: Joachim Fritzsch Date: Wed, 24 Jul 2013 13:49:10 +0200 Subject: [PATCH] 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. --- android/BOINC/src/edu/berkeley/boinc/BOINCActivity.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/android/BOINC/src/edu/berkeley/boinc/BOINCActivity.java b/android/BOINC/src/edu/berkeley/boinc/BOINCActivity.java index a208d8d6fe..592c5d5b07 100644 --- a/android/BOINC/src/edu/berkeley/boinc/BOINCActivity.java +++ b/android/BOINC/src/edu/berkeley/boinc/BOINCActivity.java @@ -62,6 +62,7 @@ public class BOINCActivity extends TabActivity { private Boolean mIsBound = false; private TabHost tabHost; + private Resources res; // dummy jni to trigger PlayStore filter for CPU architecture static{ @@ -109,6 +110,10 @@ public class BOINCActivity extends TabActivity { // adapt to custom title bar getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.title_bar); + + // get tab host and setup layout + res = getResources(); + tabHost = getTabHost(); 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 */ private void setupTabLayout() { - - Resources res = getResources(); - tabHost = getTabHost(); - // set tabs if(res.getBoolean(R.bool.tab_status)) setupTab(new TextView(this), getResources().getString(R.string.tab_status), R.drawable.icon_status_tab, StatusActivity.class);