4 Commits

Author SHA1 Message Date
Nathan Kerr
e11ee4f432 Apparently I don't know how to combine flags correctly
Closes #47
2022-08-25 14:22:50 -07:00
Nathan Kerr
d1d6396c07 Merge branch 'master' of bitbucket.org:TheBosZ/cordova-plugin-run-in-background 2022-04-22 09:06:11 -07:00
Nathan Kerr
8bc19edeb4 Fix for PendingIntent mutability and AndroidX 2022-04-22 09:01:07 -07:00
Nathan Kerr
df990e762f Merged in kerr/migrate-to-androidx (pull request #6)
Change from support library to androidx
2020-11-16 18:37:13 +00:00
4 changed files with 12 additions and 6 deletions

View File

@@ -1,4 +1,9 @@
## ChangeLog
#### Version 0.8.0
- Set PendingIntent mutability (fixes #45)
- Depend on cordova-androidx-build to automatically work with AndroidX
#### Version 0.7.3 (not yet released)
- Check if screen is off on Android
- Wake-up device on Android

View File

@@ -1,6 +1,6 @@
{
"name": "cordova-plugin-background-mode",
"version": "0.7.3",
"version": "0.8.0",
"description": "Prevent apps from going to sleep in background.",
"cordova": {
"id": "cordova-plugin-background-mode",

View File

@@ -3,7 +3,7 @@
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
xmlns:android="http://schemas.android.com/apk/res/android"
id="cordova-plugin-background-mode"
version="0.7.3">
version="0.8.0">
<name>BackgroundMode</name>
@@ -93,7 +93,8 @@
src="src/android/ForegroundService.java"
target-dir="src/de/appplant/cordova/plugin/background" />
<framework src="com.android.support:support-compat:27.1.1" />
<framework src="androidx.core:core:1.0.0" />
<dependency id="cordova-androidx-build" />
<resource-file src="src/android/res/drawable/power.xml" target="res/drawable/power.xml" />
<resource-file src="src/android/res/drawable-hdpi/power.png" target="res/drawable-hdpi/power.png" />
<resource-file src="src/android/res/drawable-mdpi/power.png" target="res/drawable-mdpi/power.png" />

View File

@@ -33,7 +33,7 @@ import android.os.Build;
import android.os.IBinder;
import android.os.PowerManager;
import org.json.JSONObject;
import android.support.v4.app.NotificationCompat;
import androidx.core.app.NotificationCompat;
import static android.os.PowerManager.PARTIAL_WAKE_LOCK;
@@ -215,7 +215,7 @@ public class ForegroundService extends Service {
if (settings.optBoolean("allowClose", false)) {
final Intent clostAppIntent = new Intent("com.backgroundmode.close" + pkgName);
final PendingIntent closeIntent = PendingIntent.getBroadcast(context, 1337, clostAppIntent, 0);
final PendingIntent closeIntent = PendingIntent.getBroadcast(context, 1337, clostAppIntent, PendingIntent.FLAG_IMMUTABLE);
final String closeIconName = settings.optString("closeIcon", "power");
NotificationCompat.Action.Builder closeAction = new NotificationCompat.Action.Builder(getIconResId(closeIconName), settings.optString("closeTitle", "Close"), closeIntent);
notification.addAction(closeAction.build());
@@ -240,7 +240,7 @@ public class ForegroundService extends Service {
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_UPDATE_CURRENT | PendingIntent.FLAG_IMMUTABLE);
notification.setContentIntent(contentIntent);