SMS send as a background Service using SmsManager

ぐ巨炮叔叔 提交于 2020-01-14 03:51:13

问题


I am trying to create an application in Android 2.2 which sends SMS to 6 different contacts the same msg automatically in background as a Service using android.telephony.SmsManager which supports both CDMA and GSM.

I saw many threads which has a code snippet but they are using which are deprecated i.e. import android.telephony.gsm.SmsManager; so i just replaced it with import android.telephony.SmsManager and wrote the following code & it works

  SmsManager sms = SmsManager.getDefault();
  sms.sendTextMessage(phoneNumber, null, message, sentPI, deliveredPI);

now ,

1) can anyone tell me the roadmap to create a service which sends up to 6 SMS in background ?

2) moreover is it good to create another thread inside a service to send SMS to make it run in a separate thread for fast result ?

i am pretty much new to Android Services section so i am confused what i need to use Remote Service or Local Service , please do ask if you have any question regarding my post


回答1:


1) You only need to follow the LocalService example depicted here

2) You can use any for of android concurrency as depicted here if you choose to.




回答2:


1) I do not see any reason not to follow the normal way for creating a service. I mean you can just follow the documentation about Service

2) Yes it is good to start a thread to perform actions in the background in a service



来源:https://stackoverflow.com/questions/9664002/sms-send-as-a-background-service-using-smsmanager

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