My android application crashes while sending Message to a list of 50 people. Anyone knows why this is happening then please do let me know.
public class SendSMS extends AsyncTask<Void, Void, Void>{
private ArrayList<SearchResults> list;
private String message;
public SendSMS(ArrayList<SearchResults> obj,String msg){
this.list=obj;
this.message=msg;
}
@Override
protected Void doInBackground(Void...params) {
// TODO Auto-generated method stub
String sms=message;
SmsManager smsManager = SmsManager.getDefault();
ArrayList<String> parts = smsManager.divideMessage(sms);
for (int i=0;i<list.size();i++){
Log.d("ListPhoneNumbers....", list.get(i).getPhoneNumber());
smsManager.sendMultipartTextMessage(list.get(i).getPhoneNumber(), null, parts, null, null);
}
Toast.makeText(getApplicationContext(), "SMS Sent!",
Toast.LENGTH_LONG).show();
return null;
}
}