How to create a stream when one of the screens is an input screen?

I am writing an Android application that requires the user to be logged in. I have a basic action, and I want it to go to the login screen when the application starts, if it has not already been logged in.

How do I simulate this? Is the login page another activity? I don’t think because I don’t want the user to be able to go back there using the back button. Or is there a way to replace the action with another, so that the problem with the back button does not happen?

Or, should I have only one action and load in the login view and replace it after the user logs in?

Are there any recommendations on this?

Thank!

+2
android
Feb 26 '11 at 10:37
source share
4 answers

I would look at the main or splash screen to check if the user is logged in if he did not start login activity.

After the login is completed, in the login activity, call this.finish ()

If you need to change actions, you can call .finish (), and then start any activity you like.

If you return to the splash / main screen without logging in, this is a problem, you can do the same.

+1
Feb 27 2018-11-23T00:
source share

To do this, ask: "I do not think, because I do not want the user to be able to return there using the" Back "button

The answer is to use the noHistory attribute in your account, for example, in the example:

<activity android:name="com.test.LoginActivity" android:configChanges="orientation|keyboardHidden|screenSize" android:label="@string/app_name" android:noHistory="true"... 

Hope this helps.

+2
Jun 28 '13 at 1:11
source share

Yes, the login screen is another action. The problem of the inverse problem is solved using the onKeyDown () method of this activity. More details here . The whole stream can be represented as follows:

You start your application. Basic actions check the login flag (in general preferences or elsewhere). If the user is logged in, the main action remains on the screen. If not, the activity starts the activity of the entry using the intent. Login activity logs in and sets the login flag and starts the main action again.

+1
Feb 26 2018-11-11T00:
source share

Do you consider using a dialog to enter? I believe that you can do the first activity check on onCreate () using SharedPreferences, if the user is already logged in, and if not, then it generates a dialog. After entering the dialog, the variable that will be passed to SharedPreferences will change, so the user does not have to rewrite if the screen orientation changes or the application pauses.

+1
Feb 27 '11 at 23:26
source share



All Articles