cordova-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Archana Naik <naik.arch...@gmail.com>
Subject Re: onResume() of CordovaActivity
Date Thu, 18 Sep 2014 21:12:14 GMT
Thanks Joe for your response.

We have a use case where we have 2 activities with webviews. First activity
is responsible for launching the 2nd one. Now when 2nd one is launched, 1st
activity goes through onPause() which pauses timers because keepRunning
flag is set to false. This pauseTimers() actually pauses JS timers for all
webviews in the app.
Now, when 2nd activity is launched it hits onResume() function with
activity state == ACTIVITY_STARTING and this code returns immediately. As a
result, JS timers remain paused for 2nd activity/webview. Which is not a
desirable behavior in our case.

There is a check for appview being null which will take care of views not
being initialized.

if (this.appView == null) {

            return;

        }

        // Force window to have focus, so application always

        // receive user input. Workaround for some devices (Samsung Galaxy
Note 3 at least)

        this.getWindow().getDecorView().requestFocus();

So your concern about requestFocus() call is not that alarming. Am I
missing here anything?

Archana

On Thu, Sep 18, 2014 at 1:42 PM, Joe Bowser <bowserj@gmail.com> wrote:

> The purpose of this code is because when you start an app, onResume is
> called, even though you didn't pause anything.  You aren't receiving any
> results, and you're not restoring any multi-tasking state.  There is no
> state, because you just started the application.  If you were to not have
> this, it's possible that there's not a view to request focus, and of
> course, this would fail:
>
>         // Force window to have focus, so application always
>
>         // receive user input. Workaround for some devices (Samsung Galaxy
> Note 3 at least)
>
>         this.getWindow().getDecorView().requestFocus();
>
> The state tracking is directly related to starting and stopping the app.
>
> On Thu, Sep 18, 2014 at 1:08 PM, Archana Naik <naik.archana@gmail.com>
> wrote:
>
> > Hi, Joe
> >
> > I have a question about a piece of code which has always been there in
> > CordovaActivitie's onResume().
> >
> >  if (this.activityState == ACTIVITY_STARTING) {
> >
> >             this.activityState = ACTIVITY_RUNNING;
> >
> >             return;
> >
> >  }
> >
> >
> > Do you know why we have this?
> >
> > Archana
> >
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message