0

I am working on an app where user is redirected to a navigation drawer activity depending on his login type. There are total 3 login types. Now, my problem is when i fetch login type from shared preference and try to redirect user to his drawer on second time app opening, it does not skip the login screen. I shows the preference data in toast as is, but does not skip the login activity.

Can any one help?

final SessionManagement session = new SessionManagement(getApplicationContext());




    Toast.makeText(getApplicationContext(), "User Login Status: " + session.isLoggedIn(), Toast.LENGTH_SHORT).show();

    session.checkLogin();

and this is my isLoggedin function

  public boolean isLoggedIn(){
    return pref.getBoolean(IS_LOGIN, false);
}

this is checkLogin function

    public void checkLogin(){
    // Check login status
    if(!this.isLoggedIn()){
        // user is not logged in redirect him to Login Activity
        Intent i = new Intent(_context, MembersArea.class);
        // Closing all the Activities
        i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);

        // Add new Flag to start new Activity
        i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);

        // Staring Login Activity
        _context.startActivity(i);
    }

}

this all sits in SessionManagement class

I also have this function redirectAuto

  public void redirectAuto(String userType){
    // Check login status
    if(this.isLoggedIn()){

        if(userType == "type1"){
            Intent intent = new Intent(_context, Type1.class);
            _context.startActivity(intent);
        }else if(userType == "type2"){
            Intent intent = new Intent(_context, Type2.class);
            _context.startActivity(intent);
        }else if(userType == "type3"){
            Intent intent = new Intent(_context, Type3.class);

            _context.startActivity(intent);
        }else{
            Toast.makeText(_context, "Please login", Toast.LENGTH_SHORT).show();
        }

    }

}

but when i call this if isLoggedIn is false, it does not go any where... Just stays at Login screen

0 Answers0