0

Here are my problems :

  • I know how to send SMS, but i'm using it in a loop like this, and I know that it's not good to send SMS, so I'd like to add a delay (i.e. 1000 milliseconds). But how ?

  • I'd like to use a ProgressDialog to show the progress of sending SMS. I know that I've to use a Thread or an AsyncTask for this. But I don't find working code...

For the moment, I've this code, which doesn't really work :

Button sendButton = (Button) findViewById(R.id.sendButton);
sendButton.setOnClickListener(new Button.OnClickListener() {
    @Override
    public void onClick(View v) {
        if (!studentList.isEmpty()) {
            for (int i = 0; i < studentList.size(); i++) {
                Student currentStudent = studentList.get(i);
                currentStudent.sendSMS();
            }
        } else {
            Toast.makeText(getApplicationContext(), "The list is empty.", Toast.LENGTH_SHORT).show();
        }
    }
});

If you need more information, do not hesitate.
I'd like to have something like a working sample code...
I am a beginner in Java and Android development, remember how difficult it was to start, please be indulgent !

Regards, Drarig29.

Community
  • 1
  • 1
Drarig29
  • 1,902
  • 1
  • 19
  • 42
  • Just so you know- Android has a throttle for the max number of SMS you can send per hour. Depending on device and OS version, its somewhere in the 30-100 range. – Gabe Sechan Jul 16 '15 at 22:29
  • It's not a problem, I'm sending SMS for an entire school class (~30 students). The number of SMS will never go above 40... – Drarig29 Jul 16 '15 at 22:46

0 Answers0