Android 轮换重定向到 webview 的根 URL
Android Rotation Redirects to root URL for webview
我有一个内置于 Laravel 和 Vue.js 中的 Web 应用程序。我已经将android中的应用程序用作WebView。当我旋转 android 设备时出现问题。旋转应用程序后,它会从任何页面重定向到根 URL,但它应该保持在同一页面上。是否可以从网络应用程序站点解决它?如果没有,那么我该如何从 Android 应用程序中解决这个问题。
这不会在 iOS 和浏览器中发生。该问题仅出现在 Android 应用程序中。
那是因为 onCreate() 被再次调用 iclude below code in manifest of app
<activity android:name=".MainActivity"
android:configChanges="orientation|screenSize">
使用 configChanges
Please try below approach
在您的清单 xml 文件中,
在您显示网页视图的 activity
标签中添加以下代码。
<activity
android:name=".youractivityname"
android:configChanges="orientation|keyboardHidden|screenSize"/>
For more info please refer this Handle configuration changes
我有一个内置于 Laravel 和 Vue.js 中的 Web 应用程序。我已经将android中的应用程序用作WebView。当我旋转 android 设备时出现问题。旋转应用程序后,它会从任何页面重定向到根 URL,但它应该保持在同一页面上。是否可以从网络应用程序站点解决它?如果没有,那么我该如何从 Android 应用程序中解决这个问题。
这不会在 iOS 和浏览器中发生。该问题仅出现在 Android 应用程序中。
那是因为 onCreate() 被再次调用 iclude below code in manifest of app
<activity android:name=".MainActivity"
android:configChanges="orientation|screenSize">
使用 configChanges
Please try below approach
在您的清单 xml 文件中,
在您显示网页视图的 activity
标签中添加以下代码。
<activity
android:name=".youractivityname"
android:configChanges="orientation|keyboardHidden|screenSize"/>
For more info please refer this Handle configuration changes