Home > Software design >  How to send users to Home Activity who already setup their Profile details?? in android
How to send users to Home Activity who already setup their Profile details?? in android

Time:10-02

I am working on an application where I have created a user login system with a phone number. When the user login to the first time the User will go to Phone Activity then OTP Activity and then Setup Profile Activity to edit the name and other details and then to the Home Activity. So I want that when the already registered user login again. Then that user should skip the profile setup activity, User should move to the Home Activity directly after the OTP activity. I am using the firebase phone method to log in. How can I achieve that?

CodePudding user response:

When user registration completes use SharedPreferences to store that state , just a boolean flag would suffice.

Then add a check during the activity startup if the flag is true or false. If it is true then user has already logged in and you can skip the profile activity else take user to profile creation.

Note : SharedPreferences would be cleared if the app data is cleared . Meaning if the app data is cleared user would need to login again.

CodePudding user response:

The best option that you have is to store a boolean value called profileCompleted in Firestore or in the Realtime Database. Each time the user opens the app, you have to check against this value and take action accordingly. In Firestore, this field can be added inside the user object like this:

Firestore-root
  |
  --- users (collection)
       |
       --- $uid (document)
            |
            --- profileCompleted: true
            |
            --- //other fields

Local storage like SharedPreferences isn't a recommended option in this case, because it doesn't persist across application uninstalls.

  • Related