KousiK
KousiK

Reputation: 825

why Android Activity retain their state automatically?

I have activity where I am running a CountDownTimer,if a calls comes or I rotate the screen the timers is still working continuously in some phone but in others phone the timers is not working,and I haven't done anything to retain the state.

So I want to know is there any special feature to these phone to retain the activity state?

here is the code :

 new CountDownTimer(30000, 1000) {

     public void onTick(long millisUntilFinished) {
          mTextField.setText("seconds remaining: " + millisUntilFinished / 1000);
     }

     public void onFinish() {
         mTextField.setText("done!");
     }
}.start();

Upvotes: 1

Views: 55

Answers (1)

Md Abdul Gafur
Md Abdul Gafur

Reputation: 6201

In android is a method that return the last information.

> if (getLastNonConfigurationInstance() != null) {
>            CountDownTimer/something       }

@Override
    public Object onRetainNonConfigurationInstance() {
        return CountDownTimer/something;
    }

Upvotes: 1

Related Questions