Is that even possible? I doubt it, but want to make sure.
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
If you’re not allowed to write any Java code to perform this “orientation lock”, then, no, it’s not possible to lock the orientation of the app from JavaScript.
You could simulate ‘locking’ if you detected the orientation change as mentioned in the Detect rotation of Android phone in the browser with javascript link and readjusted your HTML accordingly. But that seems like a lot of work.
If you can use Java, then you can expose a Java object through the WebView.addJavascriptInterface method and write some JavaScript to get/set the orientation using the Activity.setRequestedOrientation and Activity.getRequestedOrientation methods.