On Sat, Feb 14, 2009 at 1:14 PM, Hans <[email protected]> wrote: > I'm not trying to be argumentative for the sake of being argumentative > Dianne, but if that was the case, how could the IPC calls to the > remote process be resolved if they are only declared in the manifest > for the service project which is in a different *.apk? This would > mean that android was accidentally (presumably) bypassing the > requirement to declare your exposed service interfaces in your > manifest.
I don't have your code here to run to tell you exactly what is going on, I can just tell you what I see posted, and what I see is that you have your service declared in a package like this: <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.android.TestService" Note the package name "com.android.TestService" And the error message you are getting is this: "02-12 14:16:23.531: WARN/ActivityManager(50): Unable to start service Intent { comp={com.android.servicemonitor/com.android.TestService.TestService} }: not found" Note the component that is trying to be started is in the package name "com.android.servicemonitor". If putting a declaration of the service in your servicemonitor package causes things to work, then the only way I can possibly see this happening is that it is now successfully finding the component "com.android.servicemonitor/com.android.TestService.TestService" which due to the package name MUST be a component in your servicemonitor client package, so it must be running the implementation there. Maybe I am missing some part of what you are doing, but that is what I see at this point. BTW, I would presume that there is an implementation of the class in > the local client's *.apk because otherwise the client would have to > use late/explicit binding to the interfaces exposed by the service... > This should be true anytime you write a client. That is not true at all, the only thing the client needs is the interface to the class. If you are using aidl then this would be the Java classes created for ITestService.aidl or whatever you call the interface definition. And if you don't use aidl (by using a Messenger to send messages to the service, or direct transact() calls on its IBinder), then you don't need any service-related code in your client at all. > Either it should be impossible to start a remote service from a class > name or some other local to the client reference, or > the operating system should handle starting a remote service from a > class name 'properly' so that the main service thread can callback > into the client instead of just the service's thread pool being able > to. Sorry I don't quite understand what you are saying here. Ultimately the Intent you use to bind to the service is either going to be abstract, and the package manager will try to find the concrete component matching that intent for you, or it will be like you are doing here where you supply a concrete ComponentName for the actual component you want. In the latter case, the ComponentName consists of the package name of the .apk holding the component plus the full name of the component inside of that .apk. And then either that component exists in that .apk, or it doesn't, and there is really nothing else to it. One thing that may be confusing is that "new Intent(this, MyClass.class)" is a short-hand for creating an Intent with an explicit ComponentName for component in your -own- package. It can not ever be used to reference component in other packages. To do that you will need to manually create a ComponentName() with the proper strings. > In either case, it would be nice if the documentation about starting > services recommended using a global service name for starting remote > services, although I would certainly know less about Android if that > were the case, lol... I am still confused. :} Ultimately it is a ComponentName that names the service to start, and that is unambigous and you can see right in the error output exactly what it is. > Is there a formal specification for the behavior of services in this > regard? It's basic Intent matching, the exact same thing as is used for activities and receivers, and should be fairly well covered in the Intent class. -- Dianne Hackborn Android framework engineer [email protected] Note: please don't send private questions to me, as I don't have time to provide private support. 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 [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 -~----------~----~----~----~------~----~------~--~---

