このコードを Android 2.3.6 で実行すると、正常に動作します。4.0 では StrictMode 例外が発生します。SOに関するいくつかの質問から、UIスレッドでネットワーク操作を行うことができないようです。しかし、UI スレッドで UI 操作を行っていません。
doBackground の戻り値を確認する必要があるため、実行せずに直接 doBackground を呼び出しています。私は以下がうまくいったはずだと思います。
ここで何が欠けていますか?
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);
編集:電話で厳格モードが有効になっていません。