Hi people. I have an application that acts like a clapperboard, in which I use a variable i going to i++ every millisecond (I need milliseconds to display frames per second, and the chronometer updates only once per second), then I display it in the format HH:MM:SS:FF. I also have a quit button which goes by
if (item.getTitle() == "Quit") {
Process.killProcess(id);
}
The problem is that I want the app to remember the value of i when I press quit, so the timer would start at the same point it was before quitting it if I start it again. I tried
public void onSaveInstanceState(Bundle outState) {
outState.putLong(MILLISECONDS, i);
super.onSaveInstanceState(outState);
}
then calling it by
public void onStart(Bundle savedInstanceState) {
super.onStart();
i = savedInstanceState.getLong(MILLISECONDS);
}
and
public void onRestoreInstanceState(Bundle savedInstanceState) {
super.onRestoreInstanceState(savedInstanceState);
i = savedInstanceState.getLong(MILLISECONDS);
}
but it doesn't work. Also if I go with
onCreate(Bundle savedInstanceState) {
...
i = savedInstanceState.getLong(MILLISECONDS);
...
}
the app force closes. Any idea of what I'm doing wrong, please? Thank you very much.