Chredsoft's Forum Posts

  • 5 posts
  • I understand your point, but as I mentioned, accounting for and calculating the app's inactivity time will not work for my project, as I need the app to continue counting the user's training time even if it is in the background or with the screen locked. This is necessary so that at specific moments it can trigger a sound alert indicating when it is time to run or rest, and the sound alert only happens at specific moments.

    The way you explained it, it will only work if the user returns to the app, then it will calculate if the time has come to trigger the alert. But that's not what I want, nor is it what the user expects. If you download an app to manage your running time, to notify you when to run and when to stop, you at least expect it to do so with the screen locked or while you are using another app, and not to stop working in either of those cases.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Project Context/Purpose: In a part of my Android project, the user can set their training time per repetition and rest, for example: "I want to run for 1 minute, rest for 30 seconds, and I want to do 3 repetitions of this." The app counts the 1 minute, triggers a sound alert indicating the rest time, and starts counting the 30 seconds.

    However, this obviously only works if the app is open, and in this context, I need it to run in the background, as it is not possible to count the time difference from when the app is closed until it is opened again, since the user will not open the app during the run. I generated a Cordova export and added the "cordova-plugin-background-mode" plugin, configured it in the config, everything is set up, I even made this script to disable it as soon as the project opens, since I don't need it running in the background all the time, only at specific moments:

    console.log("background-mode.js loaded");

    document.addEventListener('deviceready', function () {

    console.log("Cordova is ready");

    cordova.plugins.backgroundMode.disableWebViewOptimizations();

    cordova.plugins.backgroundMode.disableBatteryOptimizations();

    cordova.plugins.backgroundMode.setDefaults({

    title: 'App in Background',

    text: 'Your app is running in the background',

    icon: 'icon', // Icon name in the res/drawable folder

    color: 'F14F4D', // Notification color

    resume: true,

    hidden: false,

    bigText: false

    });

    cordova.plugins.backgroundMode.enable();

    }, false);

    And I created two functions to enable and disable it:

    function enableBackgroundMode() {

    console.log("Enabling background mode");

    cordova.plugins.backgroundMode.enable();

    }

    function disableBackgroundMode() {

    console.log("Disabling background mode");

    cordova.plugins.backgroundMode.disable();

    }

    It is called when the user starts the run and disabled when they finish. I can see from the console log that it is running as it should, but whenever the phone locks the screen or the app goes into the background, the project pauses anyway. Is there any way to work around this?

  • first thank you very much.

    I changed some things in the last model, see the screenshot below:

    I had my sprit2 put on the drawing screen, but if I select the image through file choose or not, it doesn't stick to the drawing screen, how would I put the image on the drawing screen?

    edition:

    find out what I was doing wrong, for those who have the same doubts as me, see the image below:

  • first thank you very much.

    I changed some things in the last model, see the screenshot below:

    I had my sprit2 put on the drawing screen, but if I select the image through file choose or not, it doesn't stick to the drawing screen, how would I put the image on the drawing screen?

  • Currently the user can choose the profile image and change the sprite to the chosen image, but I can't save the image so the user doesn't have to select it again when he returns to the app, would there be any plugin or way to do this in construct 3?

    Tagged:

  • 5 posts