How to handle process death inside singleton session manager class in android?

Viewed 17

I have a session manager singleton class. Inside it, I am storing an authentication token. When an application crashes or processes death, auth token (live data) destroy. How to handle it?

@Singleton
class SessionManager
@Inject
constructor(
    private val sessionRepository: SessionRepository,
    private val cacheManager: CacheManager
) {

    private val sessionScope = CoroutineScope(Main)

    private val _sessionState = MutableLiveData<Resource<AuthToken>>()
    val sessionState: LiveData<Resource<AuthToken>>
        get() = _sessionState

}
0 Answers
Related