When I run this piece of code on Android 2.3.6, it works fine. On 4.0 I get a StrictMode exception. From some questions on SO, seems like you cant do network operations on the UI thread. But I am not doing any UI operation on the UI thread.
I am calling doBackground directly and not execute, since I need to check the return value of the doBackground. I guess the below should have worked.
What am I missing here ?
handler.postDelayed(new Runnable() {
@Override
public void run() {
God.identityHash = (String) new SwitchServer((IActionBar) splashScreen,
God.mCruiseOnServer, nameText, phoneNumberText)
.doInBackground(null);
if (!mIsBackButtonPressed && God.identityHash != null) {
FlurryAgent.logEvent(God.TCACCEPTED_AND_REGISTERED);
Intent intent = new Intent(SplashScreen.this, HomeScreen.class);
SplashScreen.this.startActivity(intent);
finish();
} else {
Toast.makeText(splashScreen,
"Unable to save your details. Please try again.",
Toast.LENGTH_LONG).show();
God.setTermsAndConditions(splashScreen, false);
}
}
}, SPLASH_DURATION);
Edit : Strict mode is not enabled on the phone.