安卓:从回来登录后登录页面prevent用户 [英] Android: prevent user from coming back to login page after logging in

查看:143
本文介绍了安卓:从回来登录后登录页面prevent用户的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的Andr​​oid应用程序的登录页面。我想prevent用户登录到回到登录页面后。此外,当用户重新打开应用程序,如果他已经登录过,我想直接去主网页,而无需进入登录页面。

I have a login page in my android app. I want to prevent the user after logging in to come back to the login page. Also, when the user reopens the app, if he has logged in before, I want to go directly to the main page without having to go to the login page.

什么这样做的最好方法是什么?一个想法我认为是拯救登录参数在cookie中,然后,当应用程序是重开,如果cookie包含了一些登录信息,我膨胀的主要页面,否则,我膨胀的登录页面。这是做的最好的方法是什么?

What the best way of doing that? One idea I thought of is to save the login parameters in a cookie, and then, when the app is reopens, if the cookie contains some login information, I inflate the main page, otherwise, I inflate the login page. Is this the best way of doing it?

谢谢

推荐答案

1)在显示登录对话框/活动只是检查你的preferences特殊标志presence:

1) Before displaying login dialog/activity just check in your preferences presence of special flag:

Context context=this.getApplicationContext();
SharedPreferences settings=context.getSharedPreferences(PREFERENCES, 0);
boolean isLogged=settings.getBoolean("isLogged", false);

根据 isLogged 值,可以重定向至登录或其他页

Depending on isLogged value you can redirect either to login or other page

2)在某处登录后保存您的登录页面 isLogged 状态,如:

2) Somewhere in your login page after logging save isLogged status, like:

Context context=this.getApplicationContext();
SharedPreferences settings=context.getSharedPreferences(PREFERENCES, 0);
SharedPreferences.Editor editor = settings.edit();
editor.putBoolean("isLogged", true);
editor.commit();

这是所有乡亲!

这篇关于安卓:从回来登录后登录页面prevent用户的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆