As a part of my app I would like to include a countdown timer.
I would much rather have the timer count in minutes and seconds, so if anyone knows of a good tutorial to set such a timer up I would rather they point me in that direction first (I have looked)
My problem is that I'm getting this error when I press the button to open the activity
02-27 21:07:47.776: E/AndroidRuntime(711): Uncaught handler: thread main exiting due to uncaught exception
02-27 21:07:47.786: E/AndroidRuntime(711): java.lang.RuntimeException: Unable to start activity ComponentInfo{converter.units.kitchen/converter.units.kitchen.Timer}: java.lang.NullPointerException
I currently have the following java activity
import
I would much rather have the timer count in minutes and seconds, so if anyone knows of a good tutorial to set such a timer up I would rather they point me in that direction first (I have looked)
My problem is that I'm getting this error when I press the button to open the activity
02-27 21:07:47.776: E/AndroidRuntime(711): Uncaught handler: thread main exiting due to uncaught exception
02-27 21:07:47.786: E/AndroidRuntime(711): java.lang.RuntimeException: Unable to start activity ComponentInfo{converter.units.kitchen/converter.units.kitchen.Timer}: java.lang.NullPointerException
I currently have the following java activity
import
android.app.Activity;
import
android.os.Bundle;
import
android.os.CountDownTimer;
import
android.widget.EditText;
import
android.widget.TextView;
public
class Timer extends Activity {
TextView count;
EditText start;
EditText start;
/** Called when the activity is first created. */
@Override
publicvoid onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.timer);
@Override
publicvoid onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.timer);
count
= new TextView(this);
this.setContentView(count);
start = (EditText)findViewById(R.id.timer1);
int int1 = Integer.parseInt(start.getText().toString());
int startint = int1*1000;
int int1 = Integer.parseInt(start.getText().toString());
int startint = int1*1000;
MyCount counter =
new MyCount(startint,1000);
counter.start();
}
publicclass MyCount extends CountDownTimer{
public
MyCount(long millisInFuture, long countDownInterval) {
It was working fine when I had a fixed number as the starting value, although since reverting to a fixed number it still does not work.
Thank you very much for your help
super(millisInFuture, countDownInterval);
}
}
@Override
publicvoid onFinish() {
count.setText("Finish");
}
publicvoid onFinish() {
count.setText("Finish");
}
@Override
publicvoid onTick(long millisUntilFinished) {
count.setText(millisUntilFinished/1000 + "left");
publicvoid onTick(long millisUntilFinished) {
count.setText(millisUntilFinished/1000 + "left");
}
}
}
}
It was working fine when I had a fixed number as the starting value, although since reverting to a fixed number it still does not work.
Thank you very much for your help