Created
July 28, 2016 16:35
-
-
Save jmsalcido/23b0580b7eecc2bf1b7dd36273326d7b to your computer and use it in GitHub Desktop.
desarrolladores-android-pregunta-login
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class TuLoginActivity extends Activity { | |
private SharedPreferencesRepository sharedPreferences; | |
@Override | |
protected void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
sharedPreferences = new SharedPreferencesRepository(this); | |
String token = sharedPreferences.getStringValue("user_token"); | |
if (token == null || token.isEmpty()) { | |
// muestras la UI de login | |
setContentView(R.layout.login_activity); | |
} else { | |
// aqui metes todo lo relacionado ó redireccionas a la actividad/fragmento/whatever que estes loggeado | |
startActivity(new Intent(this, LoggedInActivity.class); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment