Chuyển đến nội dung chính

Bài đăng

Hiển thị các bài đăng có nhãn Cordova

How to find the device mobile or pc using javascript?

     You can find the type of the device using javascript, for example your website If you want to hide some features in particular device you can use this code. From this code you can find what type of device is it like Android, Windows Phone, ipod, ipad, iphone, chrome or firefox and etc.. The following method will return the useragent full details.      navigator.userAgent You can find is this is mobile device or not using the following code      /(ipad|iphone|ipod|android|windows phone)/i.test(navigator.userAgent) Mostly we need to check it for cordova mobile application, because we need to check it in desktop pc or in normal browser and mobile native application, in that situation we can check like below. if(( /(ipad|iphone|ipod|android|windows phone)/i.test(navigator.userAgent) )) { cordova.plugins.Keyboard.close(); } In the above method is only working in mobile, we can't run cordova methods in PC. Example Program:-...

Code for vibrate the android mobile using cordova

     The following codova plugin is used to control the vibration in android mobile. This can be set the time of vibration and cancel the vibration.      cordova plugin add cordova-plugin-vibration Screen shot: <!DOCTYPE html> <html> <head>     <meta name="format-detection" content="telephone=no">     <meta name="msapplication-tap-highlight" content="no">     <meta http-equiv="Content-Security-Policy" content="default-src *; style-src 'self' 'unsafe-inline'; script-src 'self' 'unsafe-inline' 'unsafe-eval'" />     <meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width">     <title>Vibration Test</title> </head> <body>     <center>         <input type="button" value="Vibrate 3 sec" onclick="vibr3();"...

check battery status using cordova/phonegap android

     In the following plugin is used to get the battery status while change the battery level, when the battery level is going to  Critical or Low level. How to install cordova and configure? Problems in this plugin       Battery Status button will work only once. command for installing the plugin      cordova plugin add org.apache.cordova.battery-status <!DOCTYPE html> <html lang="en"> <head>     <meta charset="UTF-8">     <meta http-equiv="Content-Security-Policy" content="default-src *; style-src 'self' 'unsafe-inline'; script-src 'self' 'unsafe-inline' 'unsafe-eval'" />     <title>Battery Status</title>     <script type="text/javascript" src="cordova.js"></script>     <script type="text/javascript">         window.addEventListener("deviceready", init, false);         function i...