Only one log in per user at the time in Firebase for android
There is no way to prevent a user from authenticating on multiple devices. In fact: to know that the same user is on two devices, they'll need to authenticate on both devices.
Depending on the back-end service that you're using, it may be possible to only allow resources to be accessed from one device.
For example, if your app uses the Firebase Database, you could write the InstanceID token into the database when the user logs in. And then only allow the write if there is no token yet, or the token matches the token that last logged in. You could then even warn the user if they log in on a second device, that they're already accessing the system from another device and should log out there first.
But this is all wrought with problem cases.
For example: when do you flag that a user stopped using your app on one device (i.e. delete the InstanceID token from the database)? When they log out? That means they'll have to log in every time they want to use the app, a type of friction most users don't like much.
Or will you try to automatically detect that they stopped using the app, e.g. when it goes into the background? What happens if you miss that moment because of a bug, a crash, or a network glitch? Will the user then be unable to use the app from their other device?
For these and many more reasons I usually recommend against such a single-device policy: it's more trouble than it's worth.
Also see:
- How to handle multiple connections of the same user on Firebase?
- How to prevent simultaneous logins of the same user with Firebase?
How to only allow one user sign in fire base Authentication account at the same time?
When you use Firebase Authentication in your app there is at most one signed-in user at once. If a new user signs into the app, any previous user is automatically signed out from the app.
If this doesn't work for you, I recommend that you update your question to include the minimal code that reproduces the behavior.
Related Topics
Proxy Which Requires Authentication with Android Emulator
Include Stetho Only in the Debug Build Variant
Strange Behavior of Android Videoview - "Can't Play Video"
Data Directory Has No Read/Write Permission in Android
Rotate Zoom Drag Image in Android Imageview
Failed to Launch Emulator: Error: Emulator Didn't Connect Within 60 Seconds
Copy Database File to Sdcard in Android
How to Apply Plugin to Only One Flavor in Gradle
Setsupportactionbar Toolbar Cannot Be Applied to (Android.Widget.Toolbar) Error
How to Load Class Androidcomponentsextension After Upgrading the Android Gradle Plugin 7.1
How to Detect When the User Launches Another App? (Android)
How to Get Bluetooth Connected Devices Using Bluetoothheadset API