androidandroid-serviceandroid-application-class

How can I use two android application classes for UI and Android-service?


Currently in my app, I have an Android application class & in there I'm doing some initializations that use in application UI and some features. Also, I have an Android service, that runs in backgrounds with some events that doesn't need those above initializations in my application class. That cause some delay for my Android service to start when app UI doesn't not have instance.

Therefore, I need to create a separate application class & couple my service with that. Is this solution possible? If yes, what is the better way to achieve it?

Thank you in Advance.


Solution

  • As @CommonsWare said, this is approach is not a solution for my problem. We can have only one application class mention in AndroidManifest.xml If we need to create two application classes, we should create new application class by extending the application we already have.

    As a solution for my problem, I gave up this approach and I moved all UI stuff to Activity level and kept only necessary things in application level.

    Thank you.