I’ve created a timer that will accept a specified time value from user through edittext box and pass to the CountDownTimer(). This method expect a long value thats why i converted it into long but when i add this long convertion the android emulator shows an error unfortunately stopped.And here is my code
EditText ti=(EditText)findViewById(R.id.time);
Editable i = ti.getText();
String p=i.toString();
long x=Long.parseLong(p);
final TextView mCounter1TextField=(TextView)findViewById(R.id.counter1);
final CountDownTimer Counter1 = new CountDownTimer(x, 10) {
public void onTick(long millisUntilFinished) {
mCounter1TextField.setText(" " + (millisUntilFinished)/ 1000 + ":");
}
public void onFinish() {
mp3.start ();
Log.d ("Splash", "LauncherActivity.onCreate - created MediaPlayer");
cancel();
}
};
//Start Button1
btnstart.setOnClickListener(new OnClickListener(){
public void onClick(View v) {
Counter1.start();
}
};
Without an error to go on, the first thing I noticed is that you aren’t catching a NumberFormatException on
parseLong()