Skip to content

A fully open source & end-to-end encrypted note taking alternative to Evernote.

mobile: handle crash in background on device boot

Ammar Ahmed3770091b58ed
diff --git a/apps/mobile/native/android/app/src/main/java/com/streetwriters/notesnook/BootRecieverService.java b/apps/mobile/native/android/app/src/main/java/com/streetwriters/notesnook/BootRecieverService.java
index 519f289d0..5768ce6af 100644
--- a/apps/mobile/native/android/app/src/main/java/com/streetwriters/notesnook/BootRecieverService.java
+++ b/apps/mobile/native/android/app/src/main/java/com/streetwriters/notesnook/BootRecieverService.java
@@ -14,19 +14,21 @@ public class BootRecieverService extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
- if (!isAppOnForeground((context))) {
- /**
- We will start our service and send extra info about
- network connections
- **/
- Intent serviceIntent = new Intent(context, BootTaskService.class);
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
- context.startForegroundService(serviceIntent);
- } else {
- context.startService(serviceIntent);
- }
- HeadlessJsTaskService.acquireWakeLockNow(context);
- }
+ try {
+ if (!isAppOnForeground((context))) {
+ /**
+ We will start our service and send extra info about
+ network connections
+ **/
+ Intent serviceIntent = new Intent(context, BootTaskService.class);
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
+ context.startForegroundService(serviceIntent);
+ } else {
+ context.startService(serviceIntent);
+ }
+ HeadlessJsTaskService.acquireWakeLockNow(context);
+ }
+ } catch (Exception ignored) {}
}
private boolean isAppOnForeground(Context context) {