This appears to avoid webview state loss when rotating.

git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@4252 ed5197a5-7fde-0310-b194-c3ffbd925b24
This commit is contained in:
Cory McWilliams 2023-03-29 22:43:41 +00:00
parent 20b0337e0a
commit 2df2fc5792
2 changed files with 17 additions and 1 deletions

View File

@ -6,7 +6,9 @@
<uses-sdk android:minSdkVersion="16"/> <uses-sdk android:minSdkVersion="16"/>
<uses-permission android:name="android.permission.INTERNET"/> <uses-permission android:name="android.permission.INTERNET"/>
<application android:label="Tilde Friends" android:usesCleartextTraffic="true" android:debuggable="true"> <application android:label="Tilde Friends" android:usesCleartextTraffic="true" android:debuggable="true">
<activity android:name=".MainActivity"> <activity
android:name=".MainActivity"
android:configChanges="orientation|screenSize">
<intent-filter> <intent-filter>
<action android:name="android.intent.action.MAIN"/> <action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/> <category android:name="android.intent.category.LAUNCHER"/>

View File

@ -182,6 +182,20 @@ public class MainActivity extends Activity {
}); });
} }
@Override
protected void onSaveInstanceState(Bundle outState)
{
super.onSaveInstanceState(outState);
web_view.saveState(outState);
}
@Override
protected void onRestoreInstanceState(Bundle savedInstanceState)
{
super.onRestoreInstanceState(savedInstanceState);
web_view.restoreState(savedInstanceState);
}
@Override @Override
public boolean onKeyDown(int keyCode, KeyEvent event) { public boolean onKeyDown(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_BACK && web_view.canGoBack()) { if (keyCode == KeyEvent.KEYCODE_BACK && web_view.canGoBack()) {