Here ,I have created a textview and I stored multiple contacts in that textview and then I have passed this textview values through intent to an another activity.Now I want to send Sms to multiple contacts which are stored in that received textview..And i have done this by using the following codes below..But the problem is that I could send only to the first number stored in that textview..So Please suggest some alternative codes to send it to all the stored contacts .
Here is my code..
Bundle bundle=intent2.getExtras();
final String getudisp=bundle.getString("InvisibleNum");
String number =getudisp;
sendSMS(number, message);
private void sendSMS(String number, String message) {
Intent sentIntent = new Intent(INTENT_ACTION_SENT);
PendingIntent pendingSentIntent = PendingIntent.getBroadcast(this,
REQUEST_CODE_ACTION_SENT, sentIntent,
PendingIntent.FLAG_UPDATE_CURRENT);
Intent deliveryIntent = new Intent(INTENT_ACTION_DELIVERY);
PendingIntent pendingDeliveryIntent = PendingIntent.getBroadcast(this,
REQUEST_CODE_ACTION_DELIVERY, deliveryIntent,
PendingIntent.FLAG_UPDATE_CURRENT);
SmsManager smsManager = SmsManager.getDefault();
// Second parameter is the service center number. Use null if you want
// to use the default number
smsManager.sendTextMessage(number, null, message, pendingSentIntent,
pendingDeliveryIntent);
}
@Override
protected void onPause() {
super.onPause();
unregisterReceiver(smsSentDeliveredReceiver);
}
@Override
protected void onResume() {
super.onResume();
IntentFilter filter = new IntentFilter(INTENT_ACTION_SENT);
filter.addAction(INTENT_ACTION_DELIVERY);
registerReceiver(smsSentDeliveredReceiver, filter);
}
private void initializeReceivers() {
smsSentDeliveredReceiver = new BroadcastReceiver() {
public void onReceive1(Context context, Intent intent) {
processBroadcasts(intent);
}
@Override
public void onReceive(Context arg0, Intent arg1) {
// TODO Auto-generated method stub
}
};
}
private void processBroadcasts(Intent intent) {
String action = intent.getAction();
Log.i(TAG, "Received: " + action);
if (action.equals(INTENT_ACTION_SENT)) {
Bundle bundle = intent.getExtras();
// Need to check for error messages
Log.i(TAG, "Message: Sent");
Toast.makeText(this, "Message sent", Toast.LENGTH_LONG).show();
} else if (action.equals(INTENT_ACTION_DELIVERY)) {
Bundle bundle = intent.getExtras();
Set<String> keys = bundle.keySet();
// Need to check for error messages
Log.i(TAG, "Message: Delivered");
Toast.makeText(this, "Message delivered", Toast.LENGTH_LONG).show();
}
}