2016-04-01 2 views
-1

私はアンドロイドアプリにfacebook loginでログインしています。私のアプリでは正常にログインします。しかし、ログイン後、次のようにログイン画面が再び表示される問題があります。 enter image description hereアンドロイドアプリでログインした後にログインページを非表示にする方法

左上の十字記号をクリックすると、ログイン画面が表示されずに正常にログインしています。

答えて

0

そのためにはSharedPreferencesクラスを使用してください。

Ex。 SharedPreferencesクラスを作成します。

パブリッククラスSharedPreferencesUtility {

SharedPreferences sharedpref; 

public SharedPreferencesUtility(Context context) { 

    sharedpref = context.getSharedPreferences(context.getPackageName(), Context.MODE_PRIVATE); 

} 

public void setVerifiy(boolean b) { 

    sharedpref.edit().putBoolean("isVerify", b).commit(); 
} 

public boolean getVerifiy() { 

    return sharedpref.getBoolean("isVerify", false); 
} 

}

使用方法setVerifiyあなたがFacebookからとgetVerifiyスプラッシュ/その他の活動の OnCreateのチェック方法の後にログインしたときに真方法。

private Activity activity; 
    private SharedPreferencesUtility preferencesUtility; 

    @Override 
    public void onCreate(Bundle savedInstanceState) { 

    setContentView(R.layout.activity_splash); 

    activity = SplashActivity.this; 

    preferencesUtility = new SharedPreferencesUtility(activity); 

    Handler handler = new Handler(); 

    handler.postDelayed(new Runnable() { 
     @Override 
     public void run() { 

      if (preferencesUtility.getVerifiy()) { 

       startActivity(new Intent(getApplicationContext(), HomePage.class)); 

       finish(); 

      } else { 

       startActivity(new Intent(getApplicationContext(), LoginPage.class)); 

       finish(); 

      } 

     } 
    }, 3000); 
} 
関連する問題