I have 2 applications App A and App B. App A has activities and fragments and App B has just 1 service. The requirement is that: 1. The service in App B should be running 24 * 7 to cater to App A. 2. Based on some cloud response that the service listens to, I might need to Launch App A if it is not running.
I have started the service in App B from the BootReceiver registered in App B. App A will communicate with the service by Binding to it.
How do I ensure that the service keeps running 24 * 7 and not be destroyed when App A is not running or App A unbinds to it? In onStartCommand
of the service there is nothing to do. Service needs to wait for App A to communicate with it. Following is the onStartCommand
of the service.
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
return START_STICKY;
}