(Yes, I've read the rest of the conversation, but I'm returning to your original message).
First, you debug a Service the same way you debug anything else. You set breakpoints in the appropriate lifecycle methods, or in routines called from those methods. If I recall correctly, this works even if the Service is running in a different process, but you might need to enable debugging on the specific process via DDMS. You don't quite say what makes you think your method isn't being called. On the face of it, this would seem to mean simply that the code that calls it doesn't run. But later you talk about "It just simply seems like the Service doesn't "see" the Logger class", but with nothing to indicate what that means or why it seems that way. There are four ways that this could happen. I doubt any of them actually apply to your situation, but it's worth listing: 1) The class isn't found at compile time. The code won't compile, you won't actually be running the current code. 2) The class isn't found at run time. Somehow it didn't get packaged up in the .apk. Since the classpath would be the same for both the Service and any Activities, you'd see the same ClassNotFound exception at runtime. 3) The class is found, but gets an error while loading. This would give a ClassNotFoundError. The class will be successfully loaded once per process/.apk pair, so you'd normally get the problem for both, if in the same process, unless there's some initialization that happens between that allows it to load the second time. If in separate processes, if there's a dependency on things happening before the class loads, it might load in one process and not the other. Note that you refer to it as a singleton, but that's only meaningful within a process. 4) The class is found, but loads, but the method itself is not found. This gets a MethodNotFoundException or other exception at runtime, depending on the exact behavior of the VM; I'm not sure it's fully specified. This situation only happens if code is successfully compiled against one version of the class, but finds a different version at runtime without the appropriate method. This would be similar to case #1 in origins. It is seldom found in practice, but usually doing a clean of the project and rebuilding will resolve it -- often by turning into case #1. Anyway, your main solution is to actually debug the problem. Step through a call to your logger and see what happens and what doesn't happen. You should actually know if your Service is running in another process -- you'd have to set it up that way in the manifest. Just because you're using IPC doesn't mean it's in a separate process -- it just means you could set it up that way and the communication would still work. On Jun 22, 6:42 am, MobDev <[email protected]> wrote: > Hi, > I am using a Service to play some music. In the same project I have > several Activity's but also some custom classes which are part of a > framework, so nothing graphical. > One of those (singleton) classes is a Logging class which send logs to > my server. > I noticed that even though I can call the classes methods in my > service it actually won't be logging anything... > In my specific example it's osmething like : > Logger.getInstance().log("Whatever I want to Log"); > > Obviously the getInstance is a static method so it can be accessed > from anywhere within my project right away.. > > I was wondering though why this method for example isn't getting > called ? > Also how do I debug a Service ? > Btw I am using of IPC from one of my Activities which gets bound to > the service and can start/stop the music for example... > > Any help, hints, tips, or tricks are greatly appreciated ! -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en

