I have a Method that makes a phone call. The number and delay comes from strings in two edit text box’s. It works fine. But, i would like to put it in a loop so that it does the same this a number of times before it ends.
My code is –
public void makeCall(View view) {
//create handler for phone call
Handler delayedCallHandler = new Handler() {
public void handleMessage(Message msg) {
String num = (String) msg.obj;
Intent intent = new Intent(Intent.ACTION_CALL);
intent.setData(Uri.parse(num));
startActivity(intent);
}
};
//Grabs milli seconds count from edit text box
EditText edit_seconds = (EditText)
findViewById(R.id.seconds);
CharSequence edit_seconds_value =
edit_seconds.getText();
int secondz = Integer.parseInt(edit_seconds_value.toString());
// Grabs TXT Char from MSISDN edit text box and converts to edit_text_value
EditText edit_text = (EditText)
findViewById(R.id.msisdn);
CharSequence edit_text_value =
edit_text.getText();
//Delay phone call
delayedCallHandler.sendMessageDelayed(
delayedCallHandler.obtainMessage(0, "tel:" + edit_text_value), // msg.obj = the number to call
secondz); // 50 seconds
// Toast Popup when call set button pressed
Toast toast=Toast.makeText(this, "You have now set the call for " + edit_seconds_value + "milliseconds" , Toast.LENGTH_LONG);
toast.show();
}
You can launch the CALL activity with
startactivityForResult(). Then in theOnActivtyResultsend a delayed message to start the next CALL.