I have this code, which calls a function every second. The function perfroms numerous tasks related to the progress of a speed test.
As you can see there is a line where the visibility is set to "gone". In Android 8.1.0 this causes the Chronometer to fail. The function onTimer()
never gets called. In 7.1.1 this code works and the test runs as expected.
I need to keep the timer mechanism but I don't want to have the timer in view.
What are my options?
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
setContentView(R.layout.test);
// 1 second timer
Timer = (Chronometer)findViewById(R.id.Chronometer01);
Timer.setVisibility(Chronometer.GONE);
Timer.setOnChronometerTickListener(new OnChronometerTickListener()
{
@Override
public void onChronometerTick(Chronometer arg0)
{
OnTimer();
};
});
Timer.start();
}