2

Image the following scenario:

I've got an Android application which talks to an API across multiple activities. I'm using a self-written "Authenticator" class to ensure that I always have a valid session. But it's nevertheless possible, that the authentication fails.

Now to my question: Is there a slick way to handle an "UnauthenticatedException" my Authenticator may throw by forwarding to an LoginActivity without having to write the same try-catch in every API-talking activity and without making the Authenticator context-aware?

Phantômaxx
  • 37,901
  • 21
  • 84
  • 115
Jagmit
  • 163
  • 2
  • 8
  • Just use a `Interface` i guess you are already using one to forward the `Exception` to calling component . – ADM Mar 14 '18 at 15:39
  • This seems interesting...https://stackoverflow.com/questions/16561692/android-exception-handling-best-practice –  Mar 14 '18 at 15:48
  • This question seems nice, but what i do is to implement a class in my Aplication file that is aware of the lifecycle and nows everthing about the state of the app. I guest that is not what you want. – Jhon Fredy Trujillo Ortega Mar 14 '18 at 15:58

0 Answers0