Skip to content

Commit 5734cdc

Browse files
committed
Avoid losing the proxy config during rotation changes
This isn't a true fix to the problem in general (there's other cases where the activity could be disposed while the VPN is connected, I think), but it solves the immediate problem neatly.
1 parent ad7078b commit 5734cdc

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

app/src/main/AndroidManifest.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
<activity
3939
android:name=".MainActivity"
4040
android:label="@string/app_name"
41+
android:configChanges="orientation|screenSize|screenLayout|keyboardHidden"
4142
android:launchMode="singleTask">
4243
<intent-filter>
4344
<action android:name="android.intent.action.MAIN" />

app/src/main/java/tech/httptoolkit/android/MainActivity.kt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import android.content.Context
55
import android.content.Intent
66
import android.content.IntentFilter
77
import android.content.pm.PackageManager
8+
import android.content.res.Configuration
89
import android.net.Uri
910
import android.net.VpnService
1011
import android.os.Bundle
@@ -105,6 +106,12 @@ class MainActivity : AppCompatActivity(), CoroutineScope by MainScope() {
105106
}
106107
}
107108

109+
override fun onConfigurationChanged(newConfig: Configuration) {
110+
super.onConfigurationChanged(newConfig)
111+
setContentView(R.layout.main_layout)
112+
updateUi()
113+
}
114+
108115
override fun onResume() {
109116
super.onResume()
110117
Log.d(TAG, "onResume")

0 commit comments

Comments
 (0)