I need set android device smart phone portrait only? window.isTablet is find the mobile or tablet only, so I need to set screen lock orientation and write code too.
Asked
Active
Viewed 1,124 times
2
-
Since you are using Onsen UI, have a look at `ons.ready` and `ons.orientation` utilities to handle this easily. – Fran Dios Jul 06 '17 at 09:27
-
Thanks @FranDios for your suggestion.. – Santhoshkumar Jul 06 '17 at 09:30
3 Answers
2
Using Cordova Screen Orientation Plugin we fixed.
In app.js
document.addEventListener("deviceready", function() {
if (window.innerHeight <= 736 || window.innerWidth <= 736) {
screen.orientation.lock('portrait');
} else {
screen.orientation.unlock('portrait');
}
});
window.addEventListener("orientationchange", function() {
if (window.innerHeight <= 736 || window.innerWidth <= 736) {
screen.orientation.lock('portrait');
} else {
screen.orientation.unlock('portrait');
}
});

Santhoshkumar
- 780
- 1
- 16
- 36
0
If you want to allow potrait
mode only, then add -
<platform name="android">
<preference name="Orientation" value="portrait" />
<allow-intent href="market:*" />
</platform>
inside <widget>
tag in config.xml
in your project folder.
You may not be able to find Tablet or Mobile version
as far as this Cordova Device plugin is considered.
You can get the following properties -
- device.cordova //version of Cordova running on the device.
- device.model //name of the device's model or product
- device.platform //device's operating system name
- device.uuid
- device.version
- device.manufacturer //the device's manufacturer.
- device.isVirtual //device is virtual(emulated) or real
- device.serial

pro_cheats
- 1,534
- 1
- 15
- 25
0
Use following code,
document.addEventListener("deviceready", function() {
if (window.innerHeight <= 736 || window.innerWidth <= 736) {
screen.orientation.lock('portrait');
} else {
screen.orientation.unlock('portrait');
}
});