diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml
index 442e64125..e2859c47f 100644
--- a/android/app/src/main/AndroidManifest.xml
+++ b/android/app/src/main/AndroidManifest.xml
@@ -14,6 +14,7 @@
+
+ android:exported="false"
+ android:foregroundServiceType="specialUse"
+ >
+
+
diff --git a/android/app/src/main/java/com/blixtwallet/LndMobileService.java b/android/app/src/main/java/com/blixtwallet/LndMobileService.java
index 75f1e9e0f..8892859f2 100644
--- a/android/app/src/main/java/com/blixtwallet/LndMobileService.java
+++ b/android/app/src/main/java/com/blixtwallet/LndMobileService.java
@@ -19,6 +19,7 @@
import android.os.RemoteException;
import android.util.Base64;
import android.util.Log;
+import static android.app.Notification.FOREGROUND_SERVICE_IMMEDIATE;
import lndmobile.Callback;
import lndmobile.Lndmobile;
@@ -556,6 +557,7 @@ public int onStartCommand(Intent intent, int flags, int startid) {
boolean persistentServicesEnabled = getPersistentServicesEnabled(this);
// persistent services on, start service as foreground-svc
if (persistentServicesEnabled) {
+ Notification.Builder notificationBuilder = null;
Intent notificationIntent = new Intent (this, MainActivity.class);
PendingIntent pendingIntent =
PendingIntent.getActivity(this, 0, notificationIntent, PendingIntent.FLAG_IMMUTABLE);
@@ -565,19 +567,29 @@ public int onStartCommand(Intent intent, int flags, int startid) {
notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
assert notificationManager != null;
notificationManager.createNotificationChannel(chan);
+
+ notificationBuilder = new Notification.Builder(this, BuildConfig.APPLICATION_ID);
+ } else {
+ notificationBuilder = new Notification.Builder(this);
+ }
+
+ notificationBuilder
+ .setContentTitle("LND")
+ .setContentText("LND is running in the background")
+ .setSmallIcon(R.drawable.ic_stat_ic_notification)
+ .setContentIntent(pendingIntent)
+ .setTicker("Blixt Wallet")
+ .setOngoing(true);
+
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
+ notificationBuilder.setForegroundServiceBehavior(FOREGROUND_SERVICE_IMMEDIATE);
}
- Notification notification = new Notification.Builder(this, BuildConfig.APPLICATION_ID)
- .setContentTitle("LND")
- .setContentText("LND is running in the background")
- .setSmallIcon(R.drawable.ic_stat_ic_notification)
- .setContentIntent(pendingIntent)
- .setTicker("Blixt Wallet")
- .setOngoing(true)
- .build();
+
+ Notification notification = notificationBuilder.build();
startForeground(ONGOING_NOTIFICATION_ID, notification);
}
}
-
+
// else noop, instead of calling startService, start will be handled by binding
return startid;
}
diff --git a/android/build.gradle b/android/build.gradle
index de480d4c3..49435634b 100644
--- a/android/build.gradle
+++ b/android/build.gradle
@@ -2,10 +2,10 @@
buildscript {
ext {
- buildToolsVersion = "33.0.0"
+ buildToolsVersion = "34.0.0"
minSdkVersion = 23
- compileSdkVersion = 33
- targetSdkVersion = 33
+ compileSdkVersion = 34
+ targetSdkVersion = 34
// We use NDK 23 which has both M1 support and is the side-by-side NDK version from AGP.
ndkVersion = "23.1.7779620"