Open santiagovasquez opened 1 year ago
I found a solution for this, and although I don't know if it is the correct one or not, but this saved my life. make the next step:
1) Add in the Manifest.xml the permission: <uses-permission android:name="android.permission.REORDER_TASKS" />
2) I am using de plugin: https://github.com/FWiner/cordova-plugin-android-background-mode
(It is almost the same but more updated)
3) Open the file platform/android/app/src/main/java/de/appplant/cordova/plugin/background/BackgroundModeExt.java
4) in this file add this code:
`
// start solution
ActivityManager am = (ActivityManager) cordova.getContext().getSystemService(Activity.ACTIVITY_SERVICE);
List<ActivityManager.RunningTaskInfo> rt = am.getRunningTasks(Integer.MAX_VALUE);
for (int i = 0; i < rt.size(); i++)
{
if (rt.get(i).baseActivity.toShortString().contains("YOUR_PACKAGE_PROJECT")) {
am.moveTaskToFront(rt.get(i).id, ActivityManager.MOVE_TASK_WITH_HOME);
}
}
// end solution`
REORDER_TASKS Allows an application to change the Z-order of tasks, in this case, prioritize your app. https://developer.android.com/reference/android/Manifest.permission#REORDER_TASKS
Hello everyone, I have this problem.
when I call cordova.plugins.backgroundMode.moveToForeground(); It always works for me the first time, then I enter another application, for example Facebook, and this message is displayed in the logcat, what is it due to or how can I solve it?
Attached video of my problem with moveToForeground(): https://drive.google.com/file/d/1SQJ-6FNQ2Nr0nZxw7JBYwhGkYt9D33R_/view
VIDEO SUMMARY: