On Sun, Jul 24, 2011 at 1:06 PM, elDoudou <the.edouard.merc...@gmail.com> wrote: > As far as I understand, when an application process starts, its > "Application.onCreate()" method is invoked, right? Since I do not want > to check that my application process is properly initialized in all my > Activities, BroadcastReceivers, IntentServices, Services, > ContentProviders..., I decided to initialize some variables during > that "Application.onCreate()" method.
As Ms. Hackborn has pointed out on many different occasions, you can just as easily accomplish this via a static data member, either initialized on first access or initialized when the class containing said static data member is referred to. > However, one of my application component, an IntentService, needs to > run in another process (this is a constraint that I cannot bypass): > this is the exception to my rule, i.e., it does not need the > initialization to be run, and moreover it should not. Move the code out of a custom Application class and into a static data member. Do not refer to the class containing said static data members from your IntentService, and they will not be initialized. For example, you could simply make your custom Application class no longer extend Application, rig it up to follow a standard Java singleton pattern, and not refer to it from the IntentService (or anywhere else that does not need it). When one of your other components needs this stuff, they will refer to the class, causing it to be loaded and go through your 10ms initialization logic. > How can I do so > that the initialization check in my "Application.onCreate()" method be > not invoked in that special case, please? You don't, as Ms. Hackborn pointed out previously on this thread. -- Mark Murphy (a Commons Guy) http://commonsware.com | http://github.com/commonsguy http://commonsware.com/blog | http://twitter.com/commonsguy -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en