E
E
Eugene2019-01-23 22:14:57
Android
Eugene, 2019-01-23 22:14:57

Loading the Application class with functionality?

Good evening. There is such a question. How correct is it to contain any functionality in the Application class. For example Constant network monitoring. In order not to prescribe not to save their state during screen rotation or not to master the service. But just wrap it in a certain class and run it from the Application class when you need to turn it off there (I don’t understand correctly, I think it’s better to allocate memory for the timer 1 time and when you need to clear it, than each time you select it when creating each activity). And another question is how appropriate it is in the Application class to contain LiveData to which any error will be transferred and displayed in the observer or transfer this error from WorkManagera.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Denis Zagaevsky, 2019-01-23
@evgdev

Why do you need constant network monitoring? How long will this data live? How do you plan to save them when the application is minimized and it dies? Is it easy to get a memory leak?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question