現在、認証が必要な ICS 4.0+ Android アプリを作成しています。私が抱えている問題は、次の場合のログインステータスのチェックの処理です。
- ユーザーが最初にアプリを開く
- ユーザーがアプリを閉じた後にアプリに戻る (再開)
私が探している動作は、アプリがメモリから削除されて再度開かれた場合に「読み込み中...」のスプラッシュ画面が表示され、再開時にユーザーがアプリに戻ったときにほとんど目立たないスプラッシュ画面が表示されることです (まだメモリ内にあります)。 .
これを確認するために現在持っているコードは次のとおりです。
public static void checkUserStatus(Context context, boolean isPassive) {
Log.d(TAG, "Checking user status..");
// User is logged in and has cc
if ( APIUtil.isLoggedIn() && UserAccount.getCreditCards().size() > 0 && isPassive == false) {
Intent intent = new Intent(context, OtherActivity.class);
context.startActivity(intent);
// User is logged in but has no cc
} else if (APIUtil.isLoggedIn() && UserAccount.getCreditCards().size() == 0) {
Intent intent = new Intent(context, ManageCCActivity.class);
context.startActivity(intent);
// User is not logged in
} else if(isPassive == false) {
Intent intent = new Intent(context, HomeActivity.class);
context.startActivity(intent);
}
}
checkUserStatus は、すべてのアクティビティの onResume() で呼び出されます。これをチェックしてそれに応じてリダイレクトするという考えですが、動作は奇抜で一貫性がなく、ぎこちなく感じます。
認証フローの例はありますか? アイデア?提案?