Monday, March 3, 2014

Android bulk SMS messages report problems


Now put all the numbers are saved to AllNumbersList list, send now, it can only be accepted status of each message.
Illustrate
The effect is now:
Each send a message (such as A, B, C), transmission and receipt of a status display Toast A, then B is displayed, and then C, ...... and so on. . .
The desired effect:
After all the information is sent successfully (if it can show the progress of sending the best, I was thinking of using progressBar, do not know any better way?), All displayed as text messages sent, or which of the success of the single was not sent listed. Accepting receipt report is true.
Do not know if you have any solution, brother here Xianxie!
 private OnClickListener sendonlistener = new OnClickListener () 
{
public void onClick (View v)
{
String SENT_SMS_ACTION = "SENT_SMS_ACTION";
String DELIVERED_SMS_ACTION = "DELIVERED_SMS_ACTION";

/ / Send status
Intent sentIntent = new Intent (SENT_SMS_ACTION);
PendingIntent sentPI = PendingIntent.getBroadcast (getApplicationContext (), 0, sentIntent, 0);
/ / Accepting state
Intent deliveryIntent = new Intent (DELIVERED_SMS_ACTION);
PendingIntent deliverPI = PendingIntent.getBroadcast (getApplicationContext (), 0, deliveryIntent, 0);

myDialog = ProgressDialog.show (MainActivity.this, "SMS" on, "Please wait ...", true, true);

SmsManager smsManager = SmsManager.getDefault ();
/ / Message can not be empty
if (etable.length () == 0)
{
Toast.makeText (MainActivity.this, "the message content can not be empty!", Toast.LENGTH_LONG) show ();.
myDialog.dismiss ();
} Else
/ / More than 70 words slitting send
if (etable.toString (). length ()> 70)
{
ArrayList msgs = smsManager.divideMessage (etable.toString ());
for (String message: msgs)
{
for (int i = 0; i {
smsManager.sendTextMessage (AllNumbersList.get (i), null, message, sentPI, deliverPI);
}
}
} Else
{
for (int i = 0; i {
/ / Log.d ("the selected number", 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, "message sent successfully", Toast.LENGTH_SHORT) show ();.
break;
case SmsManager.RESULT_ERROR_GENERIC_FAILURE:
myDialog.dismiss ();
Toast.makeText (MainActivity.this, "message sending failed,", Toast.LENGTH_LONG) show ();.
break;
case SmsManager.RESULT_ERROR_RADIO_OFF:
myDialog.dismiss ();
Toast.makeText (MainActivity.this, "failed to send text messages, check the mobile phone network service", Toast.LENGTH_LONG) show ();.
break;
case SmsManager.RESULT_ERROR_NULL_PDU:
myDialog.dismiss ();
. Toast.makeText (MainActivity.this, "message sending failed", 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, "message has been successfully sent to the SMS platform, thank you for your use", Toast.LENGTH_LONG) show ();.
}
}, New IntentFilter (DELIVERED_SMS_ACTION));
}
};
<-! Main posts under Banner (D4) -><-! Posts under the main text (D5) ->
Reply:
Wood was right ...... wait quite a while

Reply:
Seems no better way
Reply:
Nobody really do -!

No comments:

Post a Comment