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 Tue, 23 Sep 2014 01:20:18 GMT
Joe,

Any thoughts on my question/scenario? I spent bit more time looking at
whole state logic and looks like it is there so onPause() doesn't get
called if Activity is going to destroy() anyway.
Which is kind of different from standard Android behavior where onPause()
gets called whether or not app is being destroy. am I correct?


Archana

On Thu, Sep 18, 2014 at 2:12 PM, Archana Naik <naik.archana@gmail.com>
wrote:

> 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