mirror of
https://bitbucket.org/TheBosZ/cordova-plugin-run-in-background
synced 2025-12-16 19:33:23 +00:00
Compare commits
4 Commits
kerr/add-e
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e11ee4f432 | ||
|
|
d1d6396c07 | ||
|
|
8bc19edeb4 | ||
|
|
df990e762f |
@@ -1,4 +1,9 @@
|
|||||||
## ChangeLog
|
## 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)
|
#### Version 0.7.3 (not yet released)
|
||||||
- Check if screen is off on Android
|
- Check if screen is off on Android
|
||||||
- Wake-up device on Android
|
- Wake-up device on Android
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "cordova-plugin-background-mode",
|
"name": "cordova-plugin-background-mode",
|
||||||
"version": "0.7.3",
|
"version": "0.8.0",
|
||||||
"description": "Prevent apps from going to sleep in background.",
|
"description": "Prevent apps from going to sleep in background.",
|
||||||
"cordova": {
|
"cordova": {
|
||||||
"id": "cordova-plugin-background-mode",
|
"id": "cordova-plugin-background-mode",
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
|
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
id="cordova-plugin-background-mode"
|
id="cordova-plugin-background-mode"
|
||||||
version="0.7.3">
|
version="0.8.0">
|
||||||
|
|
||||||
<name>BackgroundMode</name>
|
<name>BackgroundMode</name>
|
||||||
|
|
||||||
@@ -93,7 +93,8 @@
|
|||||||
src="src/android/ForegroundService.java"
|
src="src/android/ForegroundService.java"
|
||||||
target-dir="src/de/appplant/cordova/plugin/background" />
|
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/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-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" />
|
<resource-file src="src/android/res/drawable-mdpi/power.png" target="res/drawable-mdpi/power.png" />
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ import android.os.Build;
|
|||||||
import android.os.IBinder;
|
import android.os.IBinder;
|
||||||
import android.os.PowerManager;
|
import android.os.PowerManager;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
import android.support.v4.app.NotificationCompat;
|
import androidx.core.app.NotificationCompat;
|
||||||
|
|
||||||
import static android.os.PowerManager.PARTIAL_WAKE_LOCK;
|
import static android.os.PowerManager.PARTIAL_WAKE_LOCK;
|
||||||
|
|
||||||
@@ -215,7 +215,7 @@ public class ForegroundService extends Service {
|
|||||||
if (settings.optBoolean("allowClose", false)) {
|
if (settings.optBoolean("allowClose", false)) {
|
||||||
|
|
||||||
final Intent clostAppIntent = new Intent("com.backgroundmode.close" + pkgName);
|
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");
|
final String closeIconName = settings.optString("closeIcon", "power");
|
||||||
NotificationCompat.Action.Builder closeAction = new NotificationCompat.Action.Builder(getIconResId(closeIconName), settings.optString("closeTitle", "Close"), closeIntent);
|
NotificationCompat.Action.Builder closeAction = new NotificationCompat.Action.Builder(getIconResId(closeIconName), settings.optString("closeTitle", "Close"), closeIntent);
|
||||||
notification.addAction(closeAction.build());
|
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);
|
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
|
||||||
PendingIntent contentIntent = PendingIntent.getActivity(
|
PendingIntent contentIntent = PendingIntent.getActivity(
|
||||||
context, NOTIFICATION_ID, intent,
|
context, NOTIFICATION_ID, intent,
|
||||||
PendingIntent.FLAG_UPDATE_CURRENT);
|
PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_IMMUTABLE);
|
||||||
|
|
||||||
|
|
||||||
notification.setContentIntent(contentIntent);
|
notification.setContentIntent(contentIntent);
|
||||||
|
|||||||
Reference in New Issue
Block a user