Is it necessary to add an AuthStateListener in every activity of Android Firebase? I have added AuthStateListener in login activity.I want to know that is it enough?
相关问题
- How can I create this custom Bottom Navigation on
- Bottom Navigation View gets Shrink Down
- How to make that the snackbar action button be sho
- Listening to outgoing sms not working android
- How to create Circular view on android wear?
相关文章
- android开发 怎么把图片放入drawable的文件夹下
- android上如何获取/storage/emulated/下的文件列表
- androidStudio有个箭头不认识
- SQLite不能创建表
- Windows - Android SDK manager not listing any plat
- Animate Recycler View grid when number of columns
- Why is the app closing suddenly without showing an
- Android OverlayItem.setMarker(): Change the marker
I don't think it's necessary. You need to have it in the activity that have to to the sign-in environment setup, or sign out environment clenup in a way like that:
This is usually done by the activity that manage the sign-in process either through FirebaseUI or with the only SDK API.
Remember to do the user
reload()
in the signin init function so that to manage situations like the case you have deleted a user from the console, the application didn't know that because of caching:You need to have a listener in all the other Activities where you need to respond to events related to the user sign-in, sign-out or updates.
In all other activities all you have to check is only if the user is not null.
Where user is the user taken from the the FirebaseAuth instance
Usually where you use the listener you create it in the
onCreate
activity method and you add it in theonResume
and remove it in theonPause
It really depends on what you want to monitor. According to the docs you'll use this listener to listen to events on:
In the activities you need to know those things you should register the listener. But in my experience you'll need register it only in the login activity.