I'm attempting to create a basic Cordova app for Android that involves vibrating the phone when a button is clicked, but I can't seem to get it to work. I've been using PhoneGap and have included the cordova-plugin-vibration
, but I keep getting an error message in the console saying
GET http://xxx.x.x.x:xxxxx/www/cordova.js
.
Even though cordova.js is located in the platform/android/assets/lib
directory as expected, the vibration feature still isn't functioning. What could be causing this issue?
edit***
Below is the code I am currently utilizing:
html:
<body>
<main>
<button id = "vibration">SHAKE IT</button>
</main>
<script type="text/javascript" src="cordova.js"></script>
<script type="text/javascript" src="js/index.js"></script>
</body>
js:
onDeviceReady: function() {
app.receivedEvent('deviceready');
document.getElementById("vibration").addEventListener("click", vibration);
},
function vibration() {
var time = 3000;
navigator.vibrate(time);
}
/Håkan
ps. I'm new to this so any assistance would be greatly appreciated.