What is the correct way of creating a login screen/activity in Android?

What I ended up doing was to make my Home activity handle the intent android.intent.action.MAIN. Home activity, when launched, checks if the user is signed in or not (using shared preferences), if its not then it starts LoginActivity and calls finish() on its self.

LoginActivity on successful login starts the Main activity and this time because the user is logged on, the Main activity will continue its normal course. LoginActivity is declared as following in the manifest file:

<activity android:name="LoginScreen" android:label="@string/app_name"
    android:noHistory="true" android:excludeFromRecents="true">
</activity>

Setting noHistory and excludeFromRecents to true for LoginActivity means that the user cant return to this activity using back button.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)