Dead background mode on open another app - Android 10
Hi. I'm sorry for my bad english.
Dead background mode on open another app, for example. If my APP is on Background Mode this show the notification that now is on background mode, but if I open another app that isn't on background mode for example Whatsapp or Slack, my app automatically closes.
Steps:
- Pass your app to background mode.
- Check that your app is on background mode.
- Open another App that isn't on background mode. (anyone)
- Check if your App still on background mode.
Dead background mode on open another app - Android 10
Could you try: https://bitbucket.org/TheBosZ/cordova-plugin-run-in-background/src/master/
Could you try: https://bitbucket.org/TheBosZ/cordova-plugin-run-in-background/src/master/
Hi @danielehrhardt doesn't work

This is my code.
is a button method.
backgroundModeAPP(){
//if backgroundMode not active, enable it!
if (!this.backgroundMode.isActive()) {
this.backgroundMode.enable();
console.log("backgroundMode was enabled")
}
// if there is a failure on backgroundMode print an error
this.backgroundMode.on('failure').subscribe((err) => {
console.error("BackgroundMode failure: " + err);
});
//Android allows to programmatically move from foreground to background or vice versa.
this.backgroundMode.moveToBackground();
//Override the back button on Android to go to background instead of closing the app.
this.backgroundMode.overrideBackButton();
//Exclude the app from the recent task list works on Android 5.0+.
this.backgroundMode.excludeFromTaskList();
// Notification settings
this.backgroundMode.setDefaults({
title: 'Estamos en segundo plano',
text: 'Recuerda estar disponible para recibir domicilios',
icon: 'ic_launcher',
resume: true,
hidden: false,
bigText: true
})
//background logic
this.backgroundMode.on('activate').subscribe(() => {
this.backgroundMode.configure({
text: 'Recuerda estar disponible para recibir domicilios'
});
this.backgroundMode.disableWebViewOptimizations();
this.backgroundMode.disableBatteryOptimizations();
})
}
I have That Same Problem.How Can I Solve This Problem
@dogu58 bir çözüm bulabildin mi ?
@dogu58 bir çözüm bulabildin mi ?
no
Hi, I have the same problem in Android 10. When "excludeFromTaskList" is active and running in background, the application closes when the user opens any other application.
I have reviewed the code and found that the "onDestroy" event is called when the user opens another app. If I change some code on "onDestroy", the problems seem to go away.
This is my modified "BackgroundMode.java" code, adding a validation of "inBackground" on the "onDestroy" event. Clearly is not a good solution, maybe a clue.
@Override
public void onDestroy()
{
if (inBackground) return; //My fix
stopService();
android.os.Process.killProcess(android.os.Process.myPid());
}
Hi, I have the same problem in Android 10. When "excludeFromTaskList" is active and running in background, the application closes when the user opens any other application.
I have reviewed the code and found that the "onDestroy" event is called when the user opens another app. If I change some code on "onDestroy", the problems seem to go away.
This is my modified "BackgroundMode.java" code, adding a validation of "inBackground" on the "onDestroy" event. Clearly is not a good solution, maybe a clue.
@Override public void onDestroy() { if (inBackground) return; //My fix stopService(); android.os.Process.killProcess(android.os.Process.myPid()); }
Thank you but not work for me
can you share example code :(