如何将一个设计流程,其中的屏幕之一是一个登录界面?是一个、如何将、界面、屏幕

2023-09-04 13:26:42 作者:月亮不要我了

我写一个Android应用程序,需要先登录该用户。我有一个主要的活动,我想,当应用程序启动,它需要用户在登录屏幕,如果他们没有登录。

I am writing an Android app which requires the user to be logged in. I have a main Activity, and I want that when the app launches, that it takes the user to a login screen if they are not already logged in.

我应该如何模型呢?是登录页面的另一个活动?我想不会,因为我不希望用户能够回到那里使用后退按钮。或者是有没有办法替换为另一个活动,以便返回按钮的问题不会发生?

How should I model this? Is the login page another Activity? I'm thinking not because I don't want the user to be able to get back there using the back button. Or is there a way to replace an activity with another so the back button problem doesn't happen?

或者,我应该有一个登录视图只是一个活动,并加载和交换出来,一旦用户登录?

Or, should I have just one activity and load in a login view and swap it out once the user logs in?

有没有解决这个任何的最佳做法?

Are there any best practices around this?

谢谢!

推荐答案

我会检查主要还是闪屏上,以检查用户登录,如果不启动登录活动。

I would check on the main or splash screen to check if the user is logged in, if not start the login activity.

在登录完成后,在登录活动,调用的 this.finish()

Once the login completes, in the login activity, call this.finish()

如果您需要更改的活动,你可以调用.finish(),其次是启动任何活动,你想要的。

If you need to change activities, you can call .finish() followed by starting whatever activity you wanted.

如果又回到了飞溅/主屏幕,而不被记录在出了问题,你可以做同样的事情在那里。

If getting back to the splash/main screen without being logged in is a problem, you can do the same thing there.