App based on website

This section is for posting questions which are not directly related to WYSIWYG Web Builder.
Examples of off topics: web server configuration, hosting, programming related questions, third party scripts.

Note that these questions will generally not be answered by the administrators of this forum.
Post Reply
User avatar
Billywiz
 
 
Posts: 161
Joined: Thu Jul 17, 2008 3:32 pm
Location: UK
Contact:

App based on website

Post by Billywiz »

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
The Cheapest Car Hire, Worldwide.

Summit Car Hire
User avatar
Billywiz
 
 
Posts: 161
Joined: Thu Jul 17, 2008 3:32 pm
Location: UK
Contact:

Re: App based on website

Post by Billywiz »

I found this java script after doing a search and wonder if it would work in WB and if so where would it go.

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) {       
     }
Cheers
The Cheapest Car Hire, Worldwide.

Summit Car Hire
User avatar
crispy68
 
 
Posts: 2833
Joined: Thu Oct 23, 2014 12:43 am
Location: Acworth, GA
Contact:

Re: App based on website

Post by crispy68 »

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.
User avatar
miguelss
 
 
Posts: 142
Joined: Thu Aug 15, 2013 12:25 pm
Location: Madrid, Spain

Re: App based on website

Post by miguelss »

Here is an alternative that may works:

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);
Cheers,
M.
User avatar
Billywiz
 
 
Posts: 161
Joined: Thu Jul 17, 2008 3:32 pm
Location: UK
Contact:

Re: App based on website

Post by Billywiz »

Thanks Miguelss, where would I place this and would it need opening and closing <script>

Cheers
The Cheapest Car Hire, Worldwide.

Summit Car Hire
User avatar
miguelss
 
 
Posts: 142
Joined: Thu Aug 15, 2013 12:25 pm
Location: Madrid, Spain

Re: App based on website

Post by miguelss »

Hi,

You must copy and paste this code between <head> <head/> tags (into the Site HTLM properties):

Image

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>
And this is how it must looks after publishing the page:

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.
User avatar
Billywiz
 
 
Posts: 161
Joined: Thu Jul 17, 2008 3:32 pm
Location: UK
Contact:

Re: App based on website

Post by Billywiz »

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
The Cheapest Car Hire, Worldwide.

Summit Car Hire
Post Reply