AXLL's Forum Posts

  • 5 posts
  • I dont know request permission on Android 6, it need a plugin? Please help me...

    Connect to the project these JS functions in any convenient way. (at least in INDEX.html or through plugins).

    Code:

    function PremmError() {
    	//alert('NO');
    }
    
    function PremmSuccess( status ) {
    	if( !status.hasPermission ) PremmError();
    }
    
    function Premm() {
    	var permissions = cordova.plugins.permissions;
    	permissions.hasPermission(permissions.CAMERA, function( status ){
    		if ( status.hasPermission ) {
    			//alert('YES');
    		}
    		else {
    			//alert('NO');
    			permissions.requestPermission(permissions.CAMERA, PremmSuccess, PremmError);
    		}
    	});
    }
    

    And we call this code for example through the plugin Browser -

    Browser - execute JS ("Premm").

    How to build a project

    - We export as Cordova.

    cordova create Test test.test.test

    cd Test

    // Delete old www content

    // We throw our exported files www and configs in Test

    cordova platform add android

    // Add camera right to manifest

    //C:\Users\..\Test\platforms\android\app\src\main\AndroidManifest.xml

    //<uses-permission android:name="android.permission.CAMERA" />

    cordova plugin add cordova-plugin-android-permissions

    cordova build android

    A bit of theory:

    npmjs.com/package/cordova-plugin-android-permissions

  • 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
  • AXLL this post is about NW.js

    On mobile you can try "Browser - On suspended" event.

    It did not help. I get a response from the application only after I enter it again through the command "On uspended".

    I need it when the application collapses so that it becomes inactive and my image is displayed in it. 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.

    c2community.ru/imagehosting/images/2019/Jan/26/bo9nzbtsbq.jpg

  • I know this is an old topic, but in case anyone else is looking for a solution - I managed to do this with some JS code.

    https://www.dropbox.com/s/kbxitrfg4h1xxoc/WindowFocus.capx?dl=0

    How to make it work on android?

  • How to make this plugin work on Android. And that constantly writes "The requested content can not be downloaded. Please try again later. "?

  • 5 posts