cordova-plugin-background-mode icon indicating copy to clipboard operation
cordova-plugin-background-mode copied to clipboard

it crashed when running on some android 9 devices

Open jerryaner opened this issue 5 years ago • 15 comments

it running well on my phone,but others can not working when switch to other app,it crashed when switch to other app,the system give tip the app is stop running

jerryaner avatar Dec 25 '19 11:12 jerryaner

Same here. It's crashing on phone using android 9, but not crashing on emulator android version 9.

JakariaAmin avatar Dec 27 '19 12:12 JakariaAmin

its not only android 9 even on android 10 its crashing when task switched , it has to be some permission issues probably

aditbharadwaj avatar Jan 01 '20 14:01 aditbharadwaj

for right now when i use this.backgroundMode.setDefaults({ silent: true }); the app wont crash atleast. but this needs fixing imo.

aditbharadwaj avatar Jan 01 '20 15:01 aditbharadwaj

same here. I use Android 10 device and I write code like

this.platform.ready().then(() => { 
    this.backgroundMode.enable();
    this.backgroundMode.overrideBackButton();
    ...
}

It crashes when I return to the foreground of the app!

tomfong avatar Jan 05 '20 07:01 tomfong

Same here.

dhandarbeit-tk avatar Jan 06 '20 16:01 dhandarbeit-tk

Do you have any ideas?

szado avatar Feb 03 '20 15:02 szado

Do you have any ideas?

I don't use this.backgroundMode.enable();

Instead, I override backButton and use this.backgroundMode.moveToBackground(); and it works.

tomfong avatar Feb 03 '20 16:02 tomfong

@jerryaner- sir are u fixed above issue, actually I got same issue?

kapilSoni101 avatar Feb 22 '20 18:02 kapilSoni101

@kapilSoni101 you can work around the problem, checking the android version and only enabling the backgroud if the version is equal to or less than 8.0. It is not the best solution!

mauriliosfc avatar Mar 05 '20 17:03 mauriliosfc

@mauriliosfc: ok bro I will check and let u know thanks sir

kapilSoni101 avatar Mar 06 '20 03:03 kapilSoni101

Has anyone found the solution?

teuassuri2 avatar Mar 30 '20 18:03 teuassuri2

Has anyone found the solution?

as i stated above u can try this, for right now when i use this.backgroundMode.setDefaults({ silent: true }); the app wont crash at least. but this needs fixing imo.

aditbharadwaj avatar Mar 30 '20 18:03 aditbharadwaj

Without the plugin, my app could stay in background for 5 to 10 seconds and could even receive push notifications...When I installed the plugin, my app is killed right after going to background. I have the following setup:

    cordova.plugins.backgroundMode.enable();

    cordova.plugins.backgroundMode.setDefaults({ silent: true }); // was set to prevent app from crashing while in background as I was experiencing that as well

    cordova.plugins.backgroundMode.on('activate', function () {
        setInterval(function () {
            cordova.plugins.notification.badge.increase();
        }, 1000);
    });

    cordova.plugins.backgroundMode.on('deactivate', function () {
        cordova.plugins.notification.badge.clear();
    });

Any help?

austyking avatar Aug 13 '20 17:08 austyking

austyking Hello

Author file

This code should be added when mentioning binding activation

cordova.plugins.backgroundMode.disableWebViewOptimizations();

example:

            cordova.plugins.backgroundMode.enable();
            cordova.plugins.backgroundMode.setDefaults({ silent: true }); 
            
            cordova.plugins.backgroundMode.overrideBackButton();
            cordova.plugins.backgroundMode.wakeUp();
            cordova.plugins.backgroundMode.unlock();

            cordova.plugins.backgroundMode.on('activate', function () {
                cordova.plugins.backgroundMode.disableWebViewOptimizations(); 

            window.setInte = setInterval(function () {
                calllog_check();
                btn_sms();
            }, 15000);
            });


            cordova.plugins.backgroundMode.on('deactivate', function () {
                clearInterval(window.setInte);
            });
    
     

After running for 24 hours on Android 10

no problem

My english is not good, please forgive me

Come to Taiwan NEO

web:3cc.cc

www3cc avatar Aug 19 '20 04:08 www3cc

@Mate20x can you help me ?

demirkolemre avatar Mar 03 '21 20:03 demirkolemre