From 26dee93ba17c54695360af6b38d7135e9bfb2edb Mon Sep 17 00:00:00 2001 From: Jonathan Klee Date: Mon, 16 Oct 2023 12:00:03 +0200 Subject: [PATCH] Fix Null Pointer Exception. Intent parameter can be null in the onStartCommand() callback. --- .../java/foundation/e/drive/services/InitializerService.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/foundation/e/drive/services/InitializerService.java b/app/src/main/java/foundation/e/drive/services/InitializerService.java index 74927399..cafe34ff 100644 --- a/app/src/main/java/foundation/e/drive/services/InitializerService.java +++ b/app/src/main/java/foundation/e/drive/services/InitializerService.java @@ -47,7 +47,7 @@ public class InitializerService extends Service { } @Override - public int onStartCommand(@NonNull Intent intent, int flags, int startId) { + public int onStartCommand(@Nullable Intent intent, int flags, int startId) { Timber.i("onStartCommand()"); DavClientProvider.getInstance().cleanUp(); CommonUtils.setServiceUnCaughtExceptionHandler(this); @@ -58,7 +58,7 @@ public class InitializerService extends Service { String accountName = prefs.getString(AccountManager.KEY_ACCOUNT_NAME, ""); String accountType = prefs.getString(AccountManager.KEY_ACCOUNT_TYPE, ""); - if (accountName.isEmpty() && accountType.isEmpty() && intent.getExtras() != null) { + if (accountName.isEmpty() && accountType.isEmpty() && intent != null && intent.getExtras() != null) { accountName = intent.getExtras().getString(AccountManager.KEY_ACCOUNT_NAME, ""); accountType = intent.getExtras().getString(AccountManager.KEY_ACCOUNT_TYPE, ""); -- GitLab