I have an application that contains LoginActivity which makes WebService request to authorize user. If credentials are correct, I store in Auth singleton its session ID.
However during application usage, user can be signed out (server restart, etc). In this case I can throw some AuthException. It can be thrown in every application’s Activity.
How to catch AuthException in every Activity to finish current one and start LoginActivity again ?
Is this exception reachable in Application or some AuthLayerActivity that others will extend ?
I wouldn’t use Exceptions to do that. Especially if you try to propagate the Exception from one Activity to another.
But activities usually need to update their state from time to time and if you check the authentication state then you can go back to login if required. Alternatively sending a broadcast would work as notification as well.