问题
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