mirror of
https://github.com/syncthing/syncthing-android.git
synced 2024-11-26 22:31:16 +00:00
Fixed crash when stopping service (fixes #725)
This commit is contained in:
parent
cc1cf1d870
commit
926a5a7d21
1 changed files with 4 additions and 3 deletions
|
@ -129,6 +129,7 @@ public class SyncthingService extends Service implements
|
||||||
private final HashSet<OnApiChangeListener> mOnApiChangeListeners =
|
private final HashSet<OnApiChangeListener> mOnApiChangeListeners =
|
||||||
new HashSet<>();
|
new HashSet<>();
|
||||||
|
|
||||||
|
private Object mSyncStatusHandle;
|
||||||
private final SyncStatusObserver mSyncStatusObserver = new SyncStatusObserver() {
|
private final SyncStatusObserver mSyncStatusObserver = new SyncStatusObserver() {
|
||||||
@Override
|
@Override
|
||||||
public void onStatusChanged(int i) {
|
public void onStatusChanged(int i) {
|
||||||
|
@ -339,8 +340,8 @@ public class SyncthingService extends Service implements
|
||||||
|
|
||||||
new StartupTask(sp.getString("gui_user",""), sp.getString("gui_password","")).execute();
|
new StartupTask(sp.getString("gui_user",""), sp.getString("gui_password","")).execute();
|
||||||
sp.registerOnSharedPreferenceChangeListener(this);
|
sp.registerOnSharedPreferenceChangeListener(this);
|
||||||
ContentResolver.addStatusChangeListener(ContentResolver.SYNC_OBSERVER_TYPE_SETTINGS,
|
mSyncStatusHandle = ContentResolver.addStatusChangeListener(
|
||||||
mSyncStatusObserver);
|
ContentResolver.SYNC_OBSERVER_TYPE_SETTINGS, mSyncStatusObserver);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -447,7 +448,7 @@ public class SyncthingService extends Service implements
|
||||||
|
|
||||||
SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(this);
|
SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(this);
|
||||||
sp.unregisterOnSharedPreferenceChangeListener(this);
|
sp.unregisterOnSharedPreferenceChangeListener(this);
|
||||||
ContentResolver.removeStatusChangeListener(mSyncStatusObserver);
|
ContentResolver.removeStatusChangeListener(mSyncStatusHandle);
|
||||||
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.HONEYCOMB)
|
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.HONEYCOMB)
|
||||||
unregisterReceiver(mPowerSaveModeChangedReceiver);
|
unregisterReceiver(mPowerSaveModeChangedReceiver);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue