cdsincfl Member Licensed User Longtime User Feb 10, 2013 #1 Hello, How can I make the WebView persistant during device orientation? I am trying to create a wrapper that will open a web page and allow the viewer to navigate through the website. I have created this Appsgeyser and App Inventor and they both work well but have their branding on the Android app. I turned to B4A and have created the basics using the WebView. It navigates to the URL when the app is started and I can navigate through the website as expected. It seemed so simple and easy. BUT, each time the device orientation is changed the WebView reloads the original URL. Is the any way to make the current URL in the WebView persistent even through device orientation? I have tried using WebViewExtras and StateManager but have been unable to find a solution. I have searched the Forum and cannot find anything that addresses this except a post suggesting that the orientation be set fixed to either portrait or landscape. This fixes the issue but is not an acceptable solution for my purpose. I understand the life cycle of the app but is there truly no way to do this in B4A? It appears that it is possible in Android since both of the other solutions work as expected. Does B4A always have to recreate all resources on device orientation change? Is there any way around this for my situation? Any direction or help will be appreciated. BTW, this is fantastic work and a very usefull tool. Congrats to all involved in this project. I have uploaded my test files, hope it helps. Attachments WebViewerWrapper.zip WebViewerWrapper.zip 186.4 KB · Views: 519
Hello, How can I make the WebView persistant during device orientation? I am trying to create a wrapper that will open a web page and allow the viewer to navigate through the website. I have created this Appsgeyser and App Inventor and they both work well but have their branding on the Android app. I turned to B4A and have created the basics using the WebView. It navigates to the URL when the app is started and I can navigate through the website as expected. It seemed so simple and easy. BUT, each time the device orientation is changed the WebView reloads the original URL. Is the any way to make the current URL in the WebView persistent even through device orientation? I have tried using WebViewExtras and StateManager but have been unable to find a solution. I have searched the Forum and cannot find anything that addresses this except a post suggesting that the orientation be set fixed to either portrait or landscape. This fixes the issue but is not an acceptable solution for my purpose. I understand the life cycle of the app but is there truly no way to do this in B4A? It appears that it is possible in Android since both of the other solutions work as expected. Does B4A always have to recreate all resources on device orientation change? Is there any way around this for my situation? Any direction or help will be appreciated. BTW, this is fantastic work and a very usefull tool. Congrats to all involved in this project. I have uploaded my test files, hope it helps.
Erel B4X founder Staff member Licensed User Longtime User Feb 11, 2013 #2 Have you tried to save the current URL in a process global variable? This will allow you to set the URL again when the activity is recreated. Upvote 0
Have you tried to save the current URL in a process global variable? This will allow you to set the URL again when the activity is recreated.
cdsincfl Member Licensed User Longtime User Feb 13, 2013 #3 Erel said: Have you tried to save the current URL in a process global variable? This will allow you to set the URL again when the activity is recreated. Click to expand... Thanks Erel for the reply. The Webview still performs a complete reload of the page. It goes blank then reloads page as when the page is originally accessed. I am attempting to get the webpage contents of the Webview remain where the user is viewing it and just resize the view contents to fit the device display. Upvote 0
Erel said: Have you tried to save the current URL in a process global variable? This will allow you to set the URL again when the activity is recreated. Click to expand... Thanks Erel for the reply. The Webview still performs a complete reload of the page. It goes blank then reloads page as when the page is originally accessed. I am attempting to get the webpage contents of the Webview remain where the user is viewing it and just resize the view contents to fit the device display.
cdsincfl Member Licensed User Longtime User Feb 15, 2013 #4 Erel said: Have you tried to save the current URL in a process global variable? This will allow you to set the URL again when the activity is recreated. Click to expand... I read in the Forum about adding [android:configChanges="orientation"] to the manifest. I have tried this also and it still seems to reload the webpage as if the app was initially started. This is what I used, maybe there is some error in my syntax: <code <supports-screens android:largeScreens="true" android:normalScreens="true" android:smallScreens="true" android:anyDensity="true" android:configChanges="orientation"/>) /code> Any help is appreciated. Upvote 0
Erel said: Have you tried to save the current URL in a process global variable? This will allow you to set the URL again when the activity is recreated. Click to expand... I read in the Forum about adding [android:configChanges="orientation"] to the manifest. I have tried this also and it still seems to reload the webpage as if the app was initially started. This is what I used, maybe there is some error in my syntax: <code <supports-screens android:largeScreens="true" android:normalScreens="true" android:smallScreens="true" android:anyDensity="true" android:configChanges="orientation"/>) /code> Any help is appreciated.
Erel B4X founder Staff member Licensed User Longtime User Feb 17, 2013 #5 You should add this line to the manifest editor: Code: Copy SetActivityAttribute(main, android:configChanged, keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize) Upvote 0
You should add this line to the manifest editor: Code: Copy SetActivityAttribute(main, android:configChanged, keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize)
cdsincfl Member Licensed User Longtime User Feb 17, 2013 #6 Thank you Erel, that works great to stop the page reload. It also stops the view from resizing when the orientation changes. The view stays in the portrait width when changed to landscape orientation. This setting seems to stop the automatic layout change also. I have used the layout scripts but they also seem to not work with this setting. Is it true these also are affected by this setting? I know I must handle the orientation change in my code but the layout does not respond to setting my webview.width = activity.width or webview.height = activity.height. Upvote 0
Thank you Erel, that works great to stop the page reload. It also stops the view from resizing when the orientation changes. The view stays in the portrait width when changed to landscape orientation. This setting seems to stop the automatic layout change also. I have used the layout scripts but they also seem to not work with this setting. Is it true these also are affected by this setting? I know I must handle the orientation change in my code but the layout does not respond to setting my webview.width = activity.width or webview.height = activity.height.
cdsincfl Member Licensed User Longtime User Feb 18, 2013 #7 I have accomplished resetting the layout size width and height when the orientaion is changed. I used the Orientation_OrientationChanged to check if the layout size has changed and if so I set the correct size for the current orientation. Is there a listener for the DeviceLayout or ScreenLayout that I can use? I have been unable to find any reference to it in the forum or guides. I appreciate all the help on this issue. Upvote 0
I have accomplished resetting the layout size width and height when the orientaion is changed. I used the Orientation_OrientationChanged to check if the layout size has changed and if so I set the correct size for the current orientation. Is there a listener for the DeviceLayout or ScreenLayout that I can use? I have been unable to find any reference to it in the forum or guides. I appreciate all the help on this issue.
A abner69 Member Licensed User Longtime User Feb 18, 2013 #8 SetActivityAttribute Erel said: You should add this line to the manifest editor: Code: Copy SetActivityAttribute(main, android:configChanged, keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize) Click to expand... @Erel, can this be done in the activity module area for each activity, or does each diferent activity need an entry in the manifest editor? regards, ...Pablo Upvote 0
SetActivityAttribute Erel said: You should add this line to the manifest editor: Code: Copy SetActivityAttribute(main, android:configChanged, keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize) Click to expand... @Erel, can this be done in the activity module area for each activity, or does each diferent activity need an entry in the manifest editor? regards, ...Pablo
Erel B4X founder Staff member Licensed User Longtime User Feb 19, 2013 #9 You can add an dynamic intent filter with the BroadcastReceiver and listen to the following event: android.intent.action.CONFIGURATION_CHANGED or does each diferent activity need an entry in the manifest editor? Click to expand... You need to add it to each activity. Upvote 0
You can add an dynamic intent filter with the BroadcastReceiver and listen to the following event: android.intent.action.CONFIGURATION_CHANGED or does each diferent activity need an entry in the manifest editor? Click to expand... You need to add it to each activity.