benCoding.Android.Tools icon indicating copy to clipboard operation
benCoding.Android.Tools copied to clipboard

Detecting of foreGround

Open AppWerft opened this issue 8 years ago • 0 comments

Hi Ben,

I try to build an own module for implementing of

Ti.App.addEventListener("paused",function(){});

This is my code:

mTimer.scheduleAtFixedRate(new TimerTask() {
    @Override
    public void run() {
        Boolean isInForeground = BensModule.isInForeground();
        if (isInForeground != wasInForeGround) {
            KrollDict dict = new KrollDict();
            String key = (isInForeground == true) ? "resumed" : "paused";
            app.fireAppEvent(key, dict);
            wasInForeGround = isInForeground;
        }
    }
}, 0, 1000);

I use your method in tools ;-))

If the app goes to background, this will detected, but: V8Object: (KrollRuntimeThread) [1,26193] Runtime disposed, cannot fire event 'paused'

Is it normal? Can I solve?

Code strong!

Rainer

AppWerft avatar Jul 16 '16 19:07 AppWerft