Reputation: 542
I've developed an Android service that I auto-start with the following code :
AndroidManifest.xml :
<!-- Declare Boot Completed Broadcast Receiver, For Service Auto-Start on Boot -->
<receiver android:name=".utils.os.ServiceAutoStart">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED"/>
</intent-filter>
</receiver>
ServiceAutoStart.java :
public class ServiceAutoStart extends BroadcastReceiver
{
@Override
public void onReceive(Context context, Intent intent)
{
// Start Patch Service On Boot
context.startService(new Intent(context, PatchService.class));
}
}
In addition, I have a "Viewer" that starts and binds to the service using startService() and bindService(). For the most part everything works as expected. Recently I noticed that if I immediately open my "Viewer" application as soon an my Android device boot up, I seem to create 2 instance of the service (see image below). I didn't think it was possible to create 2 instances of the same service. What is going on here? Am I misinterpreting what I'm seeing in DDMS?
Upvotes: 1
Views: 182
Reputation: 1006584
I seem to create 2 instance of the service (see image below)
If you are referring to your semi-redacted list of debuggable processes on the left, they are two separate apps. One is com.XXXX.service
and one is com.XXXX.serviceremote
.
I didn't think it was possible to create 2 instances of the same service
It's not. They are separate instances of separate services in separate apps.
Upvotes: 1