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

I did my own fork to fix moveToBackground on Android

Open alindzon opened this issue 2 years ago • 1 comments

The way it is written it goes to the home screen. I wanted to go back to whatever the previous foreground app was. Took hours but I found it. I recommend whomever is maintaining this plugin to adopt this code instead.

private void moveToBackground() { Activity app = getApp(); app.moveTaskToBack(true); }

alindzon avatar Dec 08 '22 22:12 alindzon

I also had to fix a bug in recent Android releases. for pendingintents you need to have a FLAG_MUTABLE or the opposite. So I had to edit ForeGroundService.java adding | PendingIntet.FLAG_MUTABLE as shown below on line 225.

if (intent != null && settings.optBoolean("resume")) { intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP); PendingIntent contentIntent = PendingIntent.getActivity( context, NOTIFICATION_ID, intent, PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_MUTABLE);

alindzon avatar Dec 13 '22 18:12 alindzon