SMS gateway how to program android app [closed]

倾然丶 夕夏残阳落幕 提交于 2019-12-23 05:44:06

问题


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


回答1:


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)




回答2:


Instead of polling or long running requests you should use GCM (Google Cloud Messaging) ... like what this app/lib does: http://netbizltd.com/wp/budget-sms-gateway/




回答3:


As that post recommends, you should use AlarmManager to handle periodic polling.



来源:https://stackoverflow.com/questions/4324086/sms-gateway-how-to-program-android-app

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!