简体   繁体   中英

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. 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.

   @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. 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).

If you're having trouble making this work, I recommend showing the minimal code that reproduces this problem .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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