Hi, I have created an Android app based on a website created in WB but there is a problem. The app opens on a home page with a dropdown menu where a country can be selected. when that country is selected all is ok but if the viewer rotates the screen the page reverts to the home page.
Is there a code I can drop into WB to keep the viewer on the page they were viewing or is it something controlled by Google Play.
Any response welcomed.
Cheers
App based on website
Re: App based on website
I found this java script after doing a search and wonder if it would work in WB and if so where would it go.
Cheers
Code: Select all
@Override
public void onConfigurationChanged(Configuration newConfig) {
try {
super.onConfigurationChanged(newConfig);
if (this.getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
// land
} else if (this.getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) {
// port
}
} catch (Exception ex) {
}
Re: App based on website
When I looked up that code it looks like it is java. I'm not sure how you would use that in WB. Initially i'm inclined to say you can't but I know zero about java.
Re: App based on website
Here is an alternative that may works:
Cheers,
M.
Code: Select all
function preventViewportRotation() {
const metaViewport = document.querySelector("meta[name=viewport]");
if (!metaViewport) {
return;
}
metaViewport.setAttribute("content", "width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, viewport-fit=cover");
}
window.addEventListener("load", preventViewportRotation);
M.
Re: App based on website
Thanks Miguelss, where would I place this and would it need opening and closing <script>
Cheers
Cheers
Re: App based on website
Hi,
You must copy and paste this code between <head> <head/> tags (into the Site HTLM properties):

This is the whole code:
And this is how it must looks after publishing the page:
Cheers,
M.
You must copy and paste this code between <head> <head/> tags (into the Site HTLM properties):

This is the whole code:
Code: Select all
<script>
function preventViewportRotation() {
const metaViewport = document.querySelector("meta[name=viewport]");
if (!metaViewport) {
return;
}
metaViewport.setAttribute("content", "width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, viewport-fit=cover");
}
window.addEventListener("load", preventViewportRotation);
</script>
Code: Select all
<!DOCTYPE html>
<html>
<head>
<title>My Page</title>
<script>
function preventViewportRotation() {
const metaViewport = document.querySelector("meta[name=viewport]");
if (!metaViewport) {
return;
}
metaViewport.setAttribute("content", "width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, viewport-fit=cover");
}
window.addEventListener("load", preventViewportRotation);
</script>
</head>
<body>
<!-- Your HTML content goes here -->
</body>
</html>
Cheers,
M.
Re: App based on website
Thanks to crispy68 and Miguelss for getting back to me.
I have found out that this is a function that can only be altered within the app in the Google Play console so putting code into WB has no affect i'm afraid. So it's back to the drawing board in the play console to figure this one out.
Thanks again guys for your input.
Cheers
I have found out that this is a function that can only be altered within the app in the Google Play console so putting code into WB has no affect i'm afraid. So it's back to the drawing board in the play console to figure this one out.
Thanks again guys for your input.
Cheers