diff --git a/src/main/scala/com/github/shadowsocks/ShadowsocksSettings.scala b/src/main/scala/com/github/shadowsocks/ShadowsocksSettings.scala index e18db6e4..281d9802 100644 --- a/src/main/scala/com/github/shadowsocks/ShadowsocksSettings.scala +++ b/src/main/scala/com/github/shadowsocks/ShadowsocksSettings.scala @@ -207,7 +207,22 @@ class ShadowsocksSettings extends PreferenceFragment with OnSharedPreferenceChan } def refreshProfile() { - profile = app.currentProfile.get + val profile = app.currentProfile match { + case Some(profile) => profile + case None => { + app.profileManager.getFirstProfile match { + case Some(profile) => { + app.profileId(profile.id) + profile + } + case None => { + val default = app.profileManager.createDefault() + app.profileId(default.id) + default + } + } + } + } isProxyApps.setChecked(profile.proxyApps) }