2

I want to execute a Runnable from a method in my application class, but it does not work. I get the message "Runnable created", but it seems that it never reaches the run()-Method.

I call the method setCountDownAfterLeavingBus() in the Callback-Method didExitRegion(Region region) which is part of the BootstrapNotifier-Interface (Android Beacon Library).

Everything works well if I call setCountDownAfterLeavingBus() from onCreate(), but it doesn't work if I call it from the Callback-Method.

public void setCountDownAfterLeavingBus()
{


    _handlerCountdownBus = new Handler();

    _runnableForHandlerCountdownBus = new CountDownAfterLavingBusRunnable();


    _handlerCountdownBus.postDelayed(_runnableForHandlerCountdownBus,1000);
}


private class CountDownAfterLavingBusRunnable implements Runnable
{
    public CountDownAfterLavingBusRunnable()
    {
        Log.e("Runnable", " created");
    }
    @Override
    public void run() {
        Log.e("Timer", " terminated");
    }
}

I hope you can help me. Best regards, Felix

Cyberlander
  • 145
  • 1
  • 1
  • 11
  • on what thread are you calling this? – njzk2 Aug 25 '16 at 14:35
  • I called it from the method didExitRegion (Callback-Method from BootstrapNotifier-Interface which I implemented in the application class, Part of the Android Beacon Library). When I called it from the application method onCreate, it worked well. – Cyberlander Aug 25 '16 at 14:39
  • are you doing anything after you call `setCountDownAfterLeavingBus`? do you wait or sleep maybe? (can you post the `didExitRegion` code, actually?) – njzk2 Aug 25 '16 at 15:03
  • No, there is nothing left in the method. I also checked it in the other Callback-Methods of Bootstrap-Notifier and it did not work either. The Handler seems not to work in the Callback-Methods. – Cyberlander Aug 25 '16 at 18:37

0 Answers0