I have an app that consumes an API. With every request, I send a header with the version of my app, the server checks it, and if the version is too low, it would throw an error back. I did it like this so that if in the future I introduce breaking changes then I can show a nice message on the app instead of just crashing
Now any request throughout the app can potentially return this error, so what I want to do is catch this globally on every request and close whichever activity is open and open a new one saying some nice message like "Please go to play store to update your app".
Is it possible to do such thing?
To recap, i want to do 2 things:
From any request, generate an ObsoleteAppException through OkHttp/Retrofit
Capture only this exception globally, close any activity and open a new one with the warning
If its any useful, I am using RxJava2 and retrofit