[ 
https://issues.apache.org/jira/browse/CB-8383?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15230739#comment-15230739
 ] 

ASF GitHub Bot commented on CB-8383:
------------------------------------

GitHub user GitRubb opened a pull request:

    https://github.com/apache/cordova-android/pull/288

    CB-8383 Handle pause event when keeprunning=false

    I added this pull request to hopefully get some attention to this bug 
https://issues.apache.org/jira/browse/CB-8383. When keeprunning = false in 
config.xml, any pause event processing is halted until the app returns. Not 
only is the pause event missed on app backgrounding, but on return it processes 
the pause and resume events.

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/GitRubb/cordova-android master

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/cordova-android/pull/288.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #288
    
----
commit 101ac992a1bac00863177bba42735389dbef3206
Author: GitRubb <[email protected]>
Date:   2016-04-07T18:09:30Z

    CB-8383 Handle pause event when keeprunning=false 
    
    I added this pull request to hopefully get some attention to this bug 
https://issues.apache.org/jira/browse/CB-8383. When keeprunning = false in 
config.xml, any pause event processing is halted until the app returns. Not 
only is the pause event missed on app backgrounding, but on return it processes 
the pause and resume events.

----


> pause event don't fire when 'KeepRunning' is false
> --------------------------------------------------
>
>                 Key: CB-8383
>                 URL: https://issues.apache.org/jira/browse/CB-8383
>             Project: Apache Cordova
>          Issue Type: Bug
>          Components: Android
>    Affects Versions: Master, 3.5.0, 4.0.0, 4.1.3
>         Environment: Mac osx 10.9
>            Reporter: hugefactory
>              Labels: easyfix
>   Original Estimate: 1h
>  Remaining Estimate: 1h
>
> Under Android, when a project use 'KeepRunning=false' in the config.xml file, 
> the 'pause' event in javascript don't fire when application go to background. 
> Next, 'pause' event fire when 'resume' is call and when the application 
> resume.
> The problem is in 'CordovaWebView.java' in the 'handlePause' method :
> public void handlePause(boolean keepRunning) {
>         LOG.d(TAG, "Handle the pause");
>         // Send pause event to JavaScript
>         
> this.loadUrl("javascript:try{cordova.fireDocumentEvent('pause');}catch(e){console.log('exception
>  firing pause event from native');};");
>         // Forward to plugins
>         if (this.pluginManager != null) {
>             this.pluginManager.onPause(keepRunning);
>         }
>         // If app doesn't want to run in background
>         if (!keepRunning) {
>             // Pause JavaScript timers (including setInterval)
>             this.pauseTimers();
>         }
>         paused = true;
>    
>     }
> As you can see, 'pauseTimers()' is call immediatly when we choose 
> 'KeepRunning' false.
> According to the Android documentation, 'pauseTimer()' stop all javascript 
> activity....then the 'pause' javascript callback is not execute (it's execute 
> after, when the 'resumeTimers()' is call and the application resume.
> I suggest to delay the 'pauseTimers()' for 1 or 2 sec. Then the javascript 
> 'pause' can execute before the application is really stop :
> //OLD       
>      //this.pauseTimers();
> //NEW
>             final Handler handler = new Handler();
>             handler.postDelayed(new Runnable() {
>               @Override
>               public void run() {
>                 LOG.d(TAG, "Handle the pauseTimers");
>                 pauseTimers();
>               }
>             }, 1000);
>         }
> Thanks.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to