ProgressDialog
ユーザー インターフェイスに 5 秒間表示して UI をブロックし、locationClient が 5 秒後に接続できるようにしようとしています。
ダイアログ ボックスを閉じていますが、ダイアログ ボックスがまったく表示されず、モバイル画面が 3 ~ 4 秒間真っ暗になりUiThread
ます。はいの場合、私は5秒間停止してから保留中のコードを実行することができます。
スレッドの私のコードは次のとおりです。
public void startConnecting(final boolean isSearchWarnings) {
mProgressDialog = ProgressDialog.show(this, "Please wait","Long operation starts...", true);
MainActivity.this.runOnUiThread(new Runnable() {
@Override
public void run() {
for (int i = 0; i <= 5; i++) {
try {
if (mLocationClient.isConnected()) {
break;
} else {
Thread.sleep(1000);
}
} catch (InterruptedException e) {
e.printStackTrace();
}
}
mProgressDialog.dismiss();
if (isSearchWarnings) {
new getWarnings().execute(false);
} else {
new getWarnings().execute(true);
}
}
});
}