ok I have taken out the android:process=":remote" tag in my service
tag within the androidmanifest and now it calls the Logger just
fine...

On 23 jun, 14:15, MobDev <[email protected]> wrote:
> "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."
> Done that...
>
> "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."
> Tried that, when my app is started in the DDMS it will show my app
> (myprojects.android.controlCenter) and, I guess, my service
> (myprojects.android.controlCenter:remote)... When I try to debug that
> it the DDMS will throw an error : No opened project found for
> myprojects.android.controlCenter:remote. Debug session failed !
>
> "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. "
> Well I have logging to the System.err.println within the Logger class
> method which is being called, and it doesn't print to screen, so to me
> it seems like that method is not being called or executed... That's
> why I think the service doesn't "see" the Logger class : it cannot
> call it's method otherwise I would see that in my console because of
> the System.err.println() call within the called method...
> I do know the Logger class works, it is being called by other
> Activities and it prints happily everything it needs to print :D
>
> After a lot of debugging I guess this is the answer who might help me
> out :
> "Note that you refer to it as a singleton, but that's only meaningful
> within a process. "
> It seems the Service will make it's own Logger Singleton, which makes
> creating an architecture with (for example) a static management layer
> impossible... After all that static management class would be a
> singleton as well, but having the service being in another Process it
> will create it's own management class... So is there some way to
> define the service to be created inside the same porcess ?
>
> On 22 jun, 21:38, Bob Kerns <[email protected]> wrote:
>
> > (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

Reply via email to