我有一个打电话的方法。数字和延迟来自两个编辑文本框中的字符串。它工作正常。但是,我想把它放在一个循环中,以便它在结束之前多次执行相同的操作。
我的代码是 -
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();
}