views:

511

answers:

1

Hi All,

I have a service class. I have exported this class to jar and I have embed the jar in my client app.

When needed, I call the service class. When I try to do this, I get the following error:

Unable to start service Intent {comp={com.sample.service/com.sample.service.serviceClass}} : not found

I have other class apart from the service class, which I am able to access (create object of that class) which are inside the same jar.

I feel I have missed out some thing in my configuration or manifest or so.

Please help me identifying the same. My code is below:

public void onCreate(Bundle savedInstanceState) {    
      super.onCreate(savedInstanceState);  
      Intent intent = new Intent () ;  
      intent.setClassName("com.sample.service" ,"com.sample.service.serviceClass") ;  
      this.startService(intent) ; // when I call this line I get the message...  
      // binding other process continue  here   
}

Client manifest.xml

<service android:name="com.sample.service.serviceClass"  
            android:exported="true" android:label="@string/app_name" 
            android:process=":remote">
   <intent-filter><action android:name="com.sample.service.serviceClass"></action>
   </intent-filter>
</service>

Thanks in advance,
Vinay

+1  A: 

First, you do not need android:process=":remote", so please remove it, since all it will do is take up extra RAM for no benefit.

Second, since the <service> element contains an action string, use it:

public void onCreate(Bundle savedInstanceState) {    
      super.onCreate(savedInstanceState);  
      Intent intent=new Intent("com.sample.service.serviceClass");  
      this.startService(intent);
}
CommonsWare
Dear Mr. Mark, I have added the remote because I need to access the same content from the different apps. I include this after read on the web that it is better to implement a remote service. I modified as per your suggestion and it is work fine now. Thanks once again.
Vinay
@Vinay: "I need to access the same content from the different apps. " You still do not need `android:process=":remote"`, so please remove it, since all it will do is take up extra RAM for no benefit. A remote service is one that offers an API via AIDL and has nothing to do with the `android:process` attribute. Here is a sample remote service: http://github.com/commonsguy/cw-advandroid/tree/master/AdvServices/RemoteService/ and here is a corresponding client of that service: http://github.com/commonsguy/cw-advandroid/tree/master/AdvServices/RemoteClient/
CommonsWare
Thanks for the input Mr. Mark. I will surely do it...
Vinay