Question

I have implemented a countdown timer in an application of mine. It runs in the background fine and dandy, but when i use advanced task killer, it stops the timer and the only way to restart it is to open the application again. Is there anyway to have the timer persist, even if I use something like advanced task killer?

Code:

    TextView tv;
    final MyCounter timer = new MyCounter(10000,1000);

    tv  = (TextView)findViewById(R.id.healthtext);
    tv.setText("10"); 
    timer.start();
}

public class MyCounter extends CountDownTimer{

    public MyCounter(long millisInFuture, long countDownInterval) {
        super(millisInFuture, countDownInterval);
    }

    @Override
    public void onFinish() {
        Toast.makeText(getApplicationContext(), "death", Toast.LENGTH_LONG).show();
    }

    @Override
    public void onTick(long millisUntilFinished) {
        tv.setText((millisUntilFinished/1000)+"");
Was it helpful?

Solution

as far as I know - nope, since task killers destroy your app's process causing any running threads to exit

OTHER TIPS

Not while the timer is part of your application. You can of course make a timer that is not part of the application.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top