Re: [android-developers] Re: How to know what internal process runs an application
On Sun, Jul 24, 2011 at 10:23 PM, elDoudou the.edouard.merc...@gmail.com wrote: I'm sorry, but your answer does not answer my requirements, and as I stated, having to insert a line of code referring a static method every where I need to make sure my application is initialized is for a poor design, because I have something like 100 Activity classes in my application (yes, this is a very big application), and I cannot prevent from forgetting to insert the piece of code somewhere. Use lazy initialization, and your problem cannot happen, by definition: http://en.wikipedia.org/wiki/Lazy_initialization -- Mark Murphy (a Commons Guy) http://commonsware.com | http://github.com/commonsguy http://commonsware.com/blog | http://twitter.com/commonsguy Android Training in NYC: http://marakana.com/training/android/ -- 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
Re: [android-developers] Re: How to know what internal process runs an application
A string is useful to be able to look at the process information in the debugger, and the most common use for this is to have multiple .apks share a process to run in (not run parts of a single .apk in multiple processes), so a string provides the ability to do scoping and generally not go insane. On Mon, Jul 25, 2011 at 8:05 PM, elDoudou the.edouard.merc...@gmail.comwrote: Thank you Indicator Veritatis for your clear answer. For you, what I intend to do is impossible. I cannot figure out why the Android team declared an android:process attribute, and do not expose that value at runtime to the application, because this information is only an instruction on whether a dedicated Linux process should be allocated for a specific component type (Activity, Service, BroadcastReceiver, ContentProvider ...): the fact that this actually names the Linux process this way is an implementation detail and a coincidence. If the process should be anonymous containers and that it is not supposed to be available from the API at runtime, why not having design an android:process value with an ordinal? I now know that I need to review the Android source code for better understanding that android:process thing. BTW: my application has about 100 activities (I did not say hundreds ;), because this is a very large application, and I already put into common many activities. For information, I'm not totally a rookie: I have already been developing about 40 Android applications (see http://code.google.com/p/droid4me for some of them), and I have been developing now for 25 years (which, of course, does not involve that I'm a good developer ;). Regards, Édouard -- 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 -- Dianne Hackborn Android framework engineer hack...@android.com Note: please don't send private questions to me, as I don't have time to provide private support, and so won't reply to such e-mails. All such questions should be posted on public forums, where I and others can see and answer them. -- 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
Re: [android-developers] Re: How to know what internal process runs an application
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
Re: [android-developers] Re: How to know what internal process runs an application
Be we are still not getting to the core problem -- why do you need to have your app initialized certain different ways depending on these uses? How have you gotten to this point? It is the fundamental problem. This is just not naturally how Android works -- processes are simply containers to host specific components like activities and services. On Mon, Jul 18, 2011 at 11:19 AM, elDoudou the.edouard.merc...@gmail.comwrote: Thank you Diane. I may have a problem with my design, but if I'm wrong, I'd be delighted to be well guided. I would like my application to initialize a certain way when it is started with an Activity (for instance, I want to set up some caching stuff), whereas when launched via a Service, I do not need it to be initialized that way. The solution that I have found so far is to override the Application.onCreate() method, so as to be notified every time the application process starts, and quick-initialize some stuff. I have declared two android:processes because I thought that it might be possible to distinguish the cause of the application process start, but if you say that it is not possible to determine the android:process responsible for the start of the process, how can I solve my problem, please? Do you have in mind another design pattern which enables the application to be notified at startup, whatever Activity, BroadcastReceiver, Service causes its process to start so as to initialize some stuff, and to distinguish a specific Service where no initialization is supposed to be run, please? I would be very grateful to the person who is able to unblock me. And please, do not tell me that I have a design problem eventually ;) Regards, Édouard On 14 juil, 20:05, Dianne Hackborn hack...@android.com wrote: Sorry, there is no way to know. Processes are basically anonymous containers in which to run code. If you are needing to distinguish them, you have a problem in your design. On Tue, Jul 12, 2011 at 1:43 AM, elDoudou the.edouard.merc...@gmail.com wrote: Hello Doug and thank you. The process id does not indicate the Android declared process in the AndroidManifest.xml file, unfortunately. What I need to know is the android:process which causes the process to start. If I declare a service in the manifest with a specific process name (tag android:process), how do I know at runtime when this specific service process causes the Application::onCreate() method to be invoked, please? Thank you for your time and support. Regards, Édouard -- 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 -- Dianne Hackborn Android framework engineer hack...@android.com Note: please don't send private questions to me, as I don't have time to provide private support, and so won't reply to such e-mails. All such questions should be posted on public forums, where I and others can see and answer them. -- 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 -- Dianne Hackborn Android framework engineer hack...@android.com Note: please don't send private questions to me, as I don't have time to provide private support, and so won't reply to such e-mails. All such questions should be posted on public forums, where I and others can see and answer them. -- 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
Re: [android-developers] Re: How to know what internal process runs an application
Sorry, there is no way to know. Processes are basically anonymous containers in which to run code. If you are needing to distinguish them, you have a problem in your design. On Tue, Jul 12, 2011 at 1:43 AM, elDoudou the.edouard.merc...@gmail.comwrote: Hello Doug and thank you. The process id does not indicate the Android declared process in the AndroidManifest.xml file, unfortunately. What I need to know is the android:process which causes the process to start. If I declare a service in the manifest with a specific process name (tag android:process), how do I know at runtime when this specific service process causes the Application::onCreate() method to be invoked, please? Thank you for your time and support. Regards, Édouard -- 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 -- Dianne Hackborn Android framework engineer hack...@android.com Note: please don't send private questions to me, as I don't have time to provide private support, and so won't reply to such e-mails. All such questions should be posted on public forums, where I and others can see and answer them. -- 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