I am writing a simple Phonegap application for Android. This program will send notification to notification bar and make the phone vibrate periodically.

I use navigator.notification.vibrate(time_period) to achieve the target. According to this article, both beep and vibration are not supported by android emulator. Hence, I was expecting that there could be entry indicating failure of it in the Catlog, but there is no such entry. The question is how to make sure that a vibration event has happened or failed (without deploying to a device).

AppHarbor looks like one of the ways to debug Phonegap application remotely. I wonder if there is other local ways to test Phonegap application as an HTML5 website in a Chrome browser (navigator.notification call is a standard call)? If yes, then it is probably possible to somehow parse the browser's console automatically to find out if the vibration event has happened.

有帮助吗?

解决方案

Can you hide the vibrate() call behind an abstraction which you can replace depending on which platform you are using?

For example

var vibrateFunc = function(time_period) {
    if (navigator.userAgent.toLowerCase().indexOf('chrome') > -1) {
        console.log('vibrating for ' + time_period)
    } else {
        navigator.notification.vibrate(time_period)
    }
}

and then have your app code call vibrateFunc() whenever it wants to vibrate.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top