Timer never stops

I'm having so many problems with the timer, now the problem is that never stops, it keeps updating even when I close the temperature activity,
)).continueWithTask(task -> {
streamRoute = task.getResult();

Log.e("boardReady", "*****************************1");

return timerModule.scheduleAsync(TEMP_SAMPLE_PERIOD, false, tempsensor::read);
}).continueWithTask(task -> {
if(task.isFaulted()) {
Log.e("boardReady", "*****************************2");
Log.e("boardReady", task.getError().getMessage());
scheduledTask = task.getResult();

return null;
protected void clean() {
I want that when the user close the activity it stops updating and i already put the scheduledtask remove


  • What code is executed when the activity closes?  When is the clean function called?
  • Ok, the clean function is never called, how do I call it? I'm new so sorry for this questions.
  • edited March 2017
    Thanks Eric, just called the clean and it works. Now is that the route executes 2 times, if you close the activity and start it again, but it also happens in the sample app that you give. If you restart the board like quitting his energy it works fine the first time and if you do the exit/enter activity again it duplicates again, in my app and in sample app, I'm not putting any code here because it also happens in the sample so may be a bug or something.

  • The sample app does not do anything when the activity is closed.  Starting and stopping the sensor stream is handled via the UI switch.
  • What happens to me in the sample is that it duplicates if you use the tempsensor, return to main activity and comeback to the tempsensor, if yours works good I don't know what could be, any idea?
  • As stated in my previous post, the MetaWear app does not do anything when the activity is destroyed.  You need to do some cleanup before the activity is closed, which is handled by the UI switch in the app, or simply remember that the board is already configured and not add another route when the activity is resumed.
This discussion has been closed.