Reputation: 2819
I have a service in a library project:
package com.example.project;
class MyService extends Service;
When I add it to an app, I include the service tag in the app manifest:
<manifest package="com.example.project.myapp1"...
<application...
<service
android:name="com.example.project.MyService"
android:exported="false" >
<intent-filter>
<action android:name=".MYINTENT" />
</intent-filter>
</service>
I send commands to the service using startService, I'm not binding to the service because I need the service to keep running even after the activity is destroyed and not binding was much simpler. And it works fine.
So I create another app using the same library and service:
<manifest package="com.example.project.myapp2"...
<application...
<service
android:name="com.example.project.MyService"
android:exported="false" >
<intent-filter>
<action android:name=".MYINTENT" />
</intent-filter>
</service>
I can't change the service name, because the service class is the same, right?
The problem is that this second app tries to call the service from the first app instead of its own service.
So how can I isolate services implemented using the same class but running in different apps?
Upvotes: 2
Views: 162
Reputation: 29436
You can just change the intent filter name like .MYINTENT2
or something, Then, you start second service with this unique new intent action.
Upvotes: 1