I am trying to send a couple of SMS messages with SmsManager and display progress when some of the messages are sent. How can I check if message is really sent?
I have this:
private class SomeAsyncTask extends
AsyncTask<ArrayList<Person>, Integer, Void> {
private ProgressDialog dialog;
private Context context;
public SomeAsyncTask(Activity activity) {
context = activity;
dialog = new ProgressDialog(context);
dialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
}
protected void onPreExecute() {
this.dialog.setMessage("Processing!");
this.dialog.show();
}
@Override
protected Void doInBackground(ArrayList<Person>... params) {
dialog.setMax(params[0].size());
for (int i = 0; i < params[0].size(); i++) {
SmsManager.getDefault().sendTextMessage(params[0].get(i).getNum(), null, "test", null, null);
publishProgress((int) ((i / (float) params[0].size()) * 100));
}
}
@Override
protected void onProgressUpdate(Integer... values) {
super.onProgressUpdate(values);
dialog.setProgress(values[0]);
}
@Override
protected void onPostExecute(Void v) {
if (dialog.isShowing()) {
dialog.dismiss();
}
}
}
After each successfully sent message I want to update progress. What do you recommend me to do? Thank you.