Search code examples
androidservicesms-gatewaystandbyandroid-wake-lock

SMS gateway how to program android app


I want to make a SMS gateway app, that polls my website and checks if there are messages to send in the queue, and if there is, the app will send it to the destination number.

There should also be a callback function, where I will post information about the message, what android did exactly with it.

I thought first to create a service and do the poll check over wifi to the website, but refering to website "http://www.androidguys.com/2009/09/09/diamonds-are-forever-services-are-not/" it is not possible to create a service that will run forever.

What should I take in mind by make this app possible. There a lot of tricks, like wakelocks, startforeground etc, but still the service will not run forever.

Thanks.

Shafqat


Solution

  • For sending sms messages: http://developer.android.com/reference/android/telephony/SmsManager.html

    For checking/polling for new messages, probably the best way is using push messages. Since 2.2 this can be done with Cloud To Device Messaging: http://android-developers.blogspot.com/2010/05/android-cloud-to-device-messaging.html and http://blog.boxedice.com/2010/10/07/android-push-notifications-tutorial/

    That should work in the background, in the same way that gmail checks his mail (for example)