我编写了这个简单的应用程序来根据毫秒的处理程序延迟进行调用。但是由于某种原因,当我public void callme(View view)
通过按钮 onClick 事件操作时,它会使应用程序崩溃。
我相信这很简单,也许有人可以指出我的错误。谢谢
import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
import android.view.View;
import android.widget.EditText;
public class CallButtonActivity extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
public void callme(View view) {
EditText edit_seconds = (EditText)findViewById(R.id.seconds);
CharSequence edit_seconds_value = edit_seconds.getText();
int mSeconds = Integer.parseInt(edit_seconds_value.toString());
Handler myHandler = new Handler();
myHandler.postDelayed(mMyRunnable, mSeconds);
}
private Runnable mMyRunnable = new Runnable()
{
public void run()
{
EditText msisdn = (EditText)findViewById(R.id.msisdn);
Intent callIntent = new Intent(Intent.ACTION_CALL);
callIntent.setData(Uri.parse("tel:" + msisdn));
startActivity(callIntent);
}
};
}