发送短信与使用SmsManager后台服务 [英] SMS send as a background Service using SmsManager

查看:166
本文介绍了发送短信与使用SmsManager后台服务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图创造的Andr​​oid 2.2这在后台为服务使用机器人自动发送短信到6个不同的联系人相同味精的应用.telephony.SmsManager 同时支持CDMA和GSM。

我看到其中有一个code段的多个线程,但他们所使用的是德precated即进口android.telephony.gsm.SmsManager; 等等我只是用进口android.telephony.SmsManager 替换它,并写了下面的code&放;它的工作原理

  SmsManager短信= SmsManager.getDefault();
  sms.sendTextMessage(phoneNumber的,空,消息,sentPI,deliveredPI);

现在,


  

1)谁能告诉我路线图,以创建服务它发送了
  在后台短信6?


  
  

2),而且是好创建一个服务里面另一个线程
  发送短信,使其在快速结果一个单​​独的线程中运行?


我是pretty很多新的Andr​​oid服务部分,所以我很困惑的我需要使用远程服务或本地服务,请不要问,如果您对我的文章

解决方案

1)您只需要按照所描绘的本地服务的例子的这里

2)你可以使用任何Android的并发所描绘这里如果你选择。

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) 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.

这篇关于发送短信与使用SmsManager后台服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆