群发短信没有发送给每个人

时间:2012-06-08 13:38:54

标签: java android

我有一个程序根据我推送的按钮发送预定义的消息。它在我的旧手机(OG Evo)上运行良好,但只会发送到我的新手机(Evo LTE)上的前14个人。

我拉了一个LogCat,一遍又一遍地看到这段代码:

06-06 11:25:34.850: W/MessageQueue(28308): null sending message to a Handler on a dead thread
06-06 11:25:34.850: W/MessageQueue(28308): java.lang.RuntimeException: null sending message to a Handler on a dead thread
06-06 11:25:34.850: W/MessageQueue(28308):  at android.os.MessageQueue.enqueueMessage(MessageQueue.java:200)
06-06 11:25:34.850: W/MessageQueue(28308):  at android.os.Looper.quit(Looper.java:245)
06-06 11:25:34.850: W/MessageQueue(28308):  at android.os.HandlerThread.quit(HandlerThread.java:96)
06-06 11:25:34.850: W/MessageQueue(28308):  at com.htc.usage.service.UsageStatsService.onDestroy(UsageStatsService.java:197)
06-06 11:25:34.850: W/MessageQueue(28308):  at android.app.ActivityThread.handleStopService(ActivityThread.java:2762)
06-06 11:25:34.850: W/MessageQueue(28308):  at android.app.ActivityThread.access$2000(ActivityThread.java:139)
06-06 11:25:34.850: W/MessageQueue(28308):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1338)
06-06 11:25:34.850: W/MessageQueue(28308):  at android.os.Handler.dispatchMessage(Handler.java:99)
06-06 11:25:34.850: W/MessageQueue(28308):  at android.os.Looper.loop(Looper.java:154)
06-06 11:25:34.850: W/MessageQueue(28308):  at android.app.ActivityThread.main(ActivityThread.java:4977)
06-06 11:25:34.850: W/MessageQueue(28308):  at java.lang.reflect.Method.invokeNative(Native Method)
06-06 11:25:34.850: W/MessageQueue(28308):  at java.lang.reflect.Method.invoke(Method.java:511)
06-06 11:25:34.850: W/MessageQueue(28308):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
06-06 11:25:34.850: W/MessageQueue(28308):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
06-06 11:25:34.850: W/MessageQueue(28308):  at dalvik.system.NativeStart.main(Native Method)
06-06 11:25:35.320: D/PhoneStatusBarPolicy(611): @@ iconIndex=1
06-06 11:25:35.320: D/PhoneStatusBarPolicy(611): isCdma():true hasService:true mSimState=UNKNOWN gprsState=0 mDataState=2 dataActivity=4 mPhone.htcModemLinkOn:false hspa==true
06-06 11:25:35.330: D/PhoneStatusBarPolicy(611): hasService()=true ,mDataState=2 ,mPhone.htcModemLinkOn()=false ,mDataActivity=4
06-06 11:25:35.340: D/PhoneStatusBarPolicy(611): slotType[0]=SIM
06-06 11:25:35.451: V/UsageStatsService(28308): CMD_ID_UPDATE_MESSAGE_USAGE
06-06 11:25:35.471: V/UsageStatsService(28308): MSG_ON_MESSAGE_UPDATE
06-06 11:25:35.501: V/UsageStatsService(28308): MSG_STOP_SERVICE
06-06 11:25:35.501: V/UsageStatsService(28308): onDestroy

完成LogCat:http://pastebin.com/hZXwR5FL

由于我没有关闭它,我不知道线程在15个人之后是如何关闭的。

我的编码:http://pastebin.com/xe4U4GYZ

有人能发现这个帖子是如何关闭的吗?

1 个答案:

答案 0 :(得分:0)

可能是一堆事情,比如HTC在给定时间内发送的消息数量设置的硬限制。

你可以尝试几件事:

  1. 将每个clickListener中的循环放在方法
  2. 通过AsyncTask将循环放在一个新线程中,这样就不会挂起UI
  3. 只创建一个SmsManager并重复使用它,而不是为发送的每条消息重新创建它
  4. 尝试按照以下想法立即将消息发送给多个用户:How to send text message to more than 1 number?
  5. 祝你好运