I want to create a service that will have no user interface and always run in the background – looking for an SMS with a particular substring, and then responding with an SMS of its own (sent programmatically, without user intervention). Does anybody know how to do this?
Share
To expand on Darth Beleg’s answer. It’s not actually possible to do what you’re describing (at least not exactly).
The only way you can detect an incoming SMS, as Darth explains, is to listen for an
Intent. The reason why it’s not possible to do exactly what you want is that it’s not possible for aServiceto listen for anIntent.I’d recommend a
BroadcastReceiverwhich listens for theIntentand then starts anIntentService(rather than aService) and respond accordingly.IntentServicesdon’t run all of the time – they’re started, do their work then shutdown. A much more efficient way of doing what you’re looking for.