From 92bf84915cf7da1a8dc54112c2fe71533ea298b0 Mon Sep 17 00:00:00 2001 From: Felix Ableitner Date: Mon, 12 Dec 2016 15:38:50 +0900 Subject: [PATCH] Dont crash when rotating screen in settings (fixes #806) --- .../syncthingandroid/activities/SettingsActivity.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/nutomic/syncthingandroid/activities/SettingsActivity.java b/src/main/java/com/nutomic/syncthingandroid/activities/SettingsActivity.java index 5b3b00a5..05ef57e3 100644 --- a/src/main/java/com/nutomic/syncthingandroid/activities/SettingsActivity.java +++ b/src/main/java/com/nutomic/syncthingandroid/activities/SettingsActivity.java @@ -160,6 +160,9 @@ public class SettingsActivity extends SyncthingActivity { @Override public void onServiceConnected() { + if (getActivity() == null) + return; + mSyncthingService = ((SyncthingActivity) getActivity()).getService(); mSyncthingService.registerOnApiChangeListener(this); if (mSyncthingService.getApi().isConfigLoaded()) { @@ -205,7 +208,8 @@ public class SettingsActivity extends SyncthingActivity { @Override public void onDestroy() { super.onDestroy(); - mSyncthingService.unregisterOnApiChangeListener(this); + if (mSyncthingService != null) + mSyncthingService.unregisterOnApiChangeListener(this); } private void setPreferenceCategoryChangeListener(