Strange issue with Android pause resume events (on screen lock)

66 views
Skip to first unread message

Ben Atack

unread,
Jun 20, 2014, 8:32:23 AM6/20/14
to phon...@googlegroups.com

When I lock an android phone and then reopen it (with the application running) I get the pause and resume events firing multiple times. 

Is there a way to mitigate this behaviour? 

This was the example given to me by a phonegap rep:


   <script type="text/javascript" charset="utf-8">

    // Wait for device API libraries to load
    //
    document.addEventListener("deviceready", onDeviceReady, false);
    document.addEventListener("online", onOnline, false);
    document.addEventListener("offline", onOffline, false);
    document.addEventListener("pause", onPause, false);
    document.addEventListener("resume", onResume, false);
    
    
    function onPause() {
    alert("Paused");
    }
    
    function onResume() {
    alert("Resumed");
    }
    
    function onOnline(){
    alert('Device is online');
    }
    
    function onOffline(){
    alert('Device is offline');
    }

function onDeviceReady() {
         alert("device ready");
 
    }

</script>

Ben Atack

unread,
Jun 20, 2014, 9:20:45 AM6/20/14
to phon...@googlegroups.com
To clarify: This doesn't happen if you minimize and reload the app. It is only if you are inside the app and lock the screen... and when you unlock it pause and resume are called 5-10 times.

Kerri Shotts

unread,
Jun 21, 2014, 5:02:17 PM6/21/14
to phon...@googlegroups.com
On what platforms/OS versions does this occur?

Ben Atack

unread,
Jun 23, 2014, 4:18:59 AM6/23/14
to phon...@googlegroups.com
It occurs on kitkat and icecream sandwich.

Kerri Shotts

unread,
Jun 23, 2014, 3:41:38 PM6/23/14
to phon...@googlegroups.com
Anything interesting in adb logcat?
Reply all
Reply to author
Forward
0 new messages