ログイン画面があり、ログインが成功すると、AppActivityが終了して表示されます。ユーザーがAppActivityを終了してアプリケーションからログアウトすると、ログイン画面が再び表示されます。ログイン画面は、ユーザのログアウト後にダイアログを表示しようとすると、以下のようにしかし、私はエラーが発生した:ログアウトダイアログエラー:トークン[email protected]が無効です。あなたのアクティビティは実行中です
Intent intent = new Intent(LoginScreen.this, AppActivity.class);
startActivity(intent);
finish();
を:ユーザログインあれば
android.view.WindowManager$BadTokenException: Unable to add window -- token [email protected] is not valid; is your activity running?
LoginScreenはAppActivityを示す、成功したアプリに仕上がっていますユーザーがクリックはLoginScreenを示す、ボタンをログアウトする場合AppActivityが終了する:
Intent intent = new Intent(AppActivity.this, LoginScreen.class);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(intent);
finish();