问题描述
- Android短信群发 发送报告问题
- 现在把所有的号码都保存到了AllNumbersList列表里,现在发送的话,只能是每条信息都接受状态。
举例说明
现在的效果是:
每发一条信息(比如ABC),A的发送和回执状态Toast显示一次,然后B的再显示,然后再C的……依此类推。。。
而需要的效果:
所有信息发送成功后(如果发送的时候能显示进度最好,我想的是使用progressBar,不知道还有没有更好的办法?),显示为短信全部发送完毕,或者哪条没有发送成功把单条列出来。接受回执报告也是如此。
不知道各位有没有什么解决的办法,小弟在这里先谢过了!private OnClickListener sendonlistener = new OnClickListener(){ public void onClick(View v) { String SENT_SMS_ACTION = ""SENT_SMS_ACTION""; String DELIVERED_SMS_ACTION = ""DELIVERED_SMS_ACTION""; // 发送状态 Intent sentIntent = new Intent(SENT_SMS_ACTION); PendingIntent sentPI = PendingIntent.getBroadcast(getApplicationContext() 0 sentIntent 0); // 接受状态 Intent deliveryIntent = new Intent(DELIVERED_SMS_ACTION); PendingIntent deliverPI = PendingIntent.getBroadcast(getApplicationContext() 0 deliveryIntent 0); myDialog = ProgressDialog.show(MainActivity.this短信发送中""请稍等..."" true true); SmsManager smsManager = SmsManager.getDefault(); // 短信不能为空 if (etable.length() == 0) { Toast.makeText(MainActivity.this短信内容不能为空!"" Toast.LENGTH_LONG).show(); myDialog.dismiss(); } else // 超过70字分条发送 if (etable.toString().length() > 70) { ArrayList<String> msgs = smsManager.divideMessage(etable.toString()); for (String message : msgs) { for (int i = 0; i < AllNumbersList.size(); i++) { smsManager.sendTextMessage(AllNumbersList.get(i) null message sentPI deliverPI); } } } else { for (int i = 0; i < AllNumbersList.size(); i++) { // Log.d(""选择的号码"" manyNums.get(i)); smsManager.sendTextMessage(AllNumbersList.get(i) null etable.toString() sentPI deliverPI); } } // Register the Broadcast Receivers registerReceiver(new BroadcastReceiver() { @Override public void onReceive(Context context Intent intent) { switch (getResultCode()) { case Activity.RESULT_OK: myDialog.dismiss(); Toast.makeText(MainActivity.this信息发送成功"" Toast.LENGTH_SHORT).show(); break; case SmsManager.RESULT_ERROR_GENERIC_FAILURE: myDialog.dismiss(); Toast.makeText(MainActivity.this信息发送失败,"" Toast.LENGTH_LONG).show(); break; case SmsManager.RESULT_ERROR_RADIO_OFF: myDialog.dismiss(); Toast.makeText(MainActivity.this短信发送失败,请检查手机网络服务"" Toast.LENGTH_LONG).show(); break; case SmsManager.RESULT_ERROR_NULL_PDU: myDialog.dismiss(); Toast.makeText(MainActivity.this信息发送失败"" Toast.LENGTH_LONG).show(); break; } } } new IntentFilter(SENT_SMS_ACTION)); registerReceiver(new BroadcastReceiver() { @Override public void onReceive(Context context Intent intent) { Toast.makeText(MainActivity.this短信已成功发送到短信平台,谢谢您的使用"" Toast.LENGTH_LONG).show(); } } new IntentFilter(DELIVERED_SMS_ACTION)); }};
时间: 2024-11-03 09:21:05