2

アプリケーションがセルで初めて起動されたときにアプリのパスワードを作成する activity_create_password という名前のアクティビティを作成しました。次回以降は、activity_insert_password という名前のアクティビティが表示されます。どうすればこれを達成できますか 助けてください。

4

2 に答える 2

1

これを達成するには使用SharedPreferencesする必要があります。コードは次のようになります

SharedPreferences prefs = mContext.getSharedPreferences("appName", 0);
SharedPreferences.Editor editor = prefs.edit();
Intent intent;
if (prefs.getBoolean("isInitialAppLaunch", false))
{
    intent = new Intent(this, activity_insert_password.class);
    startActivity(intent);
}
else
{
    //First Time App launched, you are putting isInitialAppLaunch to false and calling create password activity.
    editor.putBoolean("isInitialAppLaunch", false);
    intent = new Intent(this, activity_create_password.class);
    startActivity(intent);
}
于 2013-10-01T05:24:00.393 に答える
0

これを実現するには、SharedPreferences クラスを使用する必要があります。

共有設定を使用するには、以下のリンクを参照してください。

共有設定の使用方法

于 2013-10-01T07:16:38.063 に答える