Fix an issue of attach/deattach service when switching NAT mode
This commit is contained in:
@@ -73,10 +73,13 @@ class ShadowsocksSettings extends PreferenceFragment with OnSharedPreferenceChan
|
||||
}
|
||||
|
||||
def onSharedPreferenceChanged(sharedPreferences: SharedPreferences, key: String) = key match {
|
||||
case Key.isNAT => if (ShadowsocksApplication.isRoot) activity.handler.post(() => {
|
||||
activity.deattachService()
|
||||
activity.attachService()
|
||||
})
|
||||
case Key.isNAT => if (ShadowsocksApplication.isRoot && activity != null) {
|
||||
activity.handler.post(() => {
|
||||
val intent = activity.getIntent
|
||||
activity.finish()
|
||||
startActivity(intent)
|
||||
})
|
||||
}
|
||||
case _ =>
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user