A
A
Artem2014-02-17 15:24:33
Android
Artem, 2014-02-17 15:24:33

What should be the structure of an online application with authorization?

There is an application, chat. Consists of a main Activity with two fragments and a few more child Activities. In all activities and fragments, there is a need to send requests to the server. For requests, there is a separate class with a listener for the result. All requests must be only under authorization, and with each request, the corresponding information comes. For this, there is already a ready-made authenticator that returns a token, adds accounts to the system, and so on. The question is how to put it all together correctly?
There are options:
1. Transfer all authorization processing to the main activity and, if necessary, send the corresponding notification from other child activities (using startActivityForResult()) and fragments there. The downside is that you have to work out all possible relationships.
2. Transfer all work with requests to a separate service and try to interact with the activity from there. Then the need for authorization will always be within the same service.
3. Embed authorization handling in the request class. In principle, it is convenient, but there are difficulties.
How to do it better?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
kolesnevg, 2014-02-17
@kolesnevg

I haven’t written for android for a long time, but I would take out all the functionality for authorization, sending and receiving data in a separate class - I would expand the "Android Application class"

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question