How do I track and process when my application is minimized?

  • I need it when the application is minimized, so that it becomes inactive and my image is displayed in it.

    Hiding let it be just a display of my picture.

    I did this:

    I did this:

    The code itself is executed:

    var global = Function('return this')();
    
    window.onblur = function() {
     c2_callFunction('onWindowLostFocus');
    }
    
    window.onfocus = function() {
     c2_callFunction('onWindowGotFocus');
    }
    

    This method works only in the browser. And I need something to work on Android devices.

    I came up with this method:

    When exporting to Cordova, there will be an Index.html file.

    There I write in Script tags

    <script> 
     document.addEventListener("deviceready", function () 
     { 
     window["c2iscordova"] = true; 
    
     // Create new runtime using the c2canvas 
     cr_createRuntime("c2canvas"); 
    
     document.addEventListener("pause", function() { 
     c2_callFunction('onWindowLostFocus'); 
     }, false); 
    
     document.addEventListener("resume", function() { 
     c2_callFunction('onWindowGotFocus'); 
     }, false); 
    
     }, false); 
     </script>
    

    This allows me to catch when this application is in focus or not. But not 100% of the time. Sometimes it just does not work out. But when the screen splits into 2, it works out in 100% of cases.

    In the project settings, I turned pause on focus on and off.

    The same events Plugin Browser.

    - on supended and on resumed checked also give 0% processing.

    Handling keys on menu button and on search button also do not give any result.

    How to do what I could handle when the application is minimized - so that the picture would change as in Google Chrome in incognito mode.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)