I am New to Android.I am trying to send mail to all the selected recipients(getting from JSON), selecting the recipients through checkbox.The dialog box for sending email appears again and again for each but I want to send in one time.I am posting my code.
ArrayList<Getter_Setter> user_list;
btn_send.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
for (int i = 0; i < user_list.size(); i++) {
//send mail with these selected emails
if (user_list.get(i).isSelected()) {
String[] item = {user_list.get(i).getEmail()};
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("text/plain");
intent.putExtra(Intent.EXTRA_EMAIL, new String [item.length]);
intent.putExtra(Intent.EXTRA_SUBJECT, "");
intent.putExtra(Intent.EXTRA_TEXT, "");
try {
startActivity(Intent.createChooser(intent, "Send mail..."));
} catch (android.content.ActivityNotFoundException ex) {
Toast.makeText(UserInfo.this, "There are no email clients installed.", Toast.LENGTH_SHORT).show();
}
}
}
}
});