Ideally, you do not have a working service. Services should only be in memory when they do something, and the likelihood that your code will not do anything when SMS arrives.
In this case, your recipient can call startService() . It passes the Intent to the onStartCommand() service, regardless of whether it is running or not. Ideally, your service is an IntentService , one designed to work with a command template and to shut down when processing a command.
In addition, since SMS messages can appear while the device is sleeping, you will probably need to use WakeLock to ensure sufficient device downtime for the control to be transferred to the service and for the service to do whatever it is. One approach for this is to use the WakefulIntentService , which completes the IntentService + WakeLock .
source share