简体   繁体   English

始终保持登录 Android

[英]Always stay logged in Android

I have developed an Android App based on CRUD operations which is connected with Mysql database at backend using php apis and now want to add login functionality of users.我开发了一个基于 CRUD 操作的 Android 应用程序,它使用 php apis 在后端与 Mysql 数据库连接,现在想添加用户的登录功能。 My requirement is that: Users always stay logged in app until they click on logout button, how can I do this?我的要求是:用户在点击注销按钮之前始终保持登录状态,我该怎么做?

Anyone please help.?任何人请帮忙。?

once the user entered the login credentials saved into preferences or sqlite and update code in the OnResume method to fetch data back from local storage like preferences or SQLite and filled up login fields and call API function without any click event.一旦用户输入保存在首选项或 SQLite 中的登录凭据并更新 OnResume 方法中的代码以从本地存储(如首选项或 SQLite)中取回数据,并填写登录字段并调用 API 函数而无需任何单击事件。

   @Override
    protected void onResume() {
        super.onResume();
               //your code logic
    }

Firebase Authentication automatically persists the user's credentials to local storage, and restored the authentication state from there when the app is restarted. Firebase 身份验证会自动将用户的凭据保存到本地存储,并在应用重新启动时从那里恢复身份验证状态。 So you shouldn't have to do anything to get he behavior you describe.所以你不应该做任何事情来得到你描述的他的行为。

The only way the user gets signed out from Firebase is when you explicitly sign them out, or if Firebase is somehow unable to restore the authentication state (such as when you disable their account).用户从 Firebase 注销的唯一方法是您明确将其注销,或者 Firebase 以某种方式无法恢复身份验证状态(例如当您禁用他们的帐户时)。

If you're having trouble making this work, I recommend showing the minimal code that reproduces this problem .如果您在完成这项工作时遇到问题,我建议您展示重现此问题最少代码

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM