I’m making an android app which communicates alot thru HTTP / JSON for populating different views in the GUI.
I have:
- Made a login screen and the main views
- A server which trows HTTP 403 if you request a login protected resourse / mainly JSON.
I want:
- An interseptor like concept which can set the view/activity to the login screen if 403 is encountered.
The rationale for this is so I don’t have to make an explicit 403 error handling in all my AsyncTasks
Android doesn’t have anything like this.
The best solution would be to create a utility method that handles the HTTP connection, and either returns the
HttpResponse, or does the error handling on 403, and use that method everywhere in your code to connect to your server, instead of buildingHttpClientsin everyAsyncTaskby hand.