安卓登录 - 最好的实现最好的

2023-09-05 06:25:01 作者:吟一曲、流年殇

我打算实现一个Android应用程序,需要一个登录界面。

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

如果用户打开的活动这样的事情应该发生的:

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

如果用户已登录,转到3 如果没有登录打开登录界面的用户和perfom登录 显示我的应用内容

那么,什么是实现登录的正确的方法是什么?

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

实施一个 StartActivity 的perfoms检查,如果用户登录,实施 LoginActivity 实现日志和 ApplicationActivity ,实际上实现了应用程序逻辑? 实施只是一个活动,并通过使用我根据应用程序的状态显示多个视图处理登录? 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? 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?

推荐答案

我不认为有这样做的正确的方式。你描述这两种解决方案似乎没什么问题,但我会合并 StartActivity LoginActivity 成一个单一的。

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.