user3408252
user3408252

Reputation: 55

How to reset static variables when activity is over?

I want to reset static int variable on Android, when the Activity finalize.

Without using:

public void onClick(View v) {
   var = 0;
   finish();
}

Thanks.

Upvotes: 1

Views: 1147

Answers (1)

pat
pat

Reputation: 1015

You can reset them in the activity's onDestroy() method which is called at the end of the activity lifecycle. Or just initialize them in onCreate() as Mr. Trigg said.

Upvotes: 2

Related Questions