Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Login - Best implementation

Tags:

I'm planning to implement an Android application that requires a login screen.

If the user opens the activity something like this should happen:

  1. If user is logged in, goto 3
  2. If user is not logged in open the login screen and perfom login
  3. Show my application content

So, what's the "correct" way of implementing a login?

  1. Implement a StartActivity that perfoms the check if the user is logged in, implement a LoginActivity that implements the logging and an ApplicationActivity that actually implements the application logics?
  2. Implement just one Activity and handle the login by using multiple views which I show according to the application state?

Are there any examples or tutorials for this scenario?

like image 684
Christian Seifert Avatar asked Jun 02 '10 10:06

Christian Seifert


People also ask

What is the best architecture for android?

The most popular android architectures used by developers are the following: MVC (Model — View — Controller) MVP (Model — View — Presenter) MVVM (Model — View — ViewModel)

How do I keep logged in on android?

getUserName(MainActivity. this). length() == 0) { // call Login Activity } else { // Stay at the current activity. } In Login activity if user login successful then set UserName using setUserName() function.


1 Answers

I don't think that there is a "correct" way of doing this. Both solutions you describe seem fine to me, although I would merge StartActivity and LoginActivity into a single one.

like image 110
kgiannakakis Avatar answered Sep 28 '22 17:09

kgiannakakis