Android check user logged in before, else start login activity

Viewed 40622

I want the login activity to start when the user starts the app but has not logged in before. If a successful login has been completed before, the app will skip the login page and move to MainMenu.java. What I have now is:

    public class Login extends Activity implements OnClickListener, TaskCompleteCallback{

     first_time_check();

...
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.configure);

    ...}

private boolean first_time_check() {    
    String first = mPreferences.getString("first", null);
        if((first == null)){
            Intent i = new Intent(Login.this, MainMenu.class);
             startActivity(i);
        }
        return false;
    }

...
        SharedPreferences.Editor editor = mPreferences.edit();
        editor.putString("first", value);
    ...

        editor.commit();        

        // Close the activity
        Intent i = new Intent(Login.this, MainMenu.class);
         startActivity(i);
    }           

But I get FCs'. Is something wrong with how I implemented SharedPreferences?

4 Answers
Related