我正在使用phoneGap的移動應用程序工作。我正在顯示deviceInfo並且它不適用於Android模擬器!但適用於BlackBerry模擬器。我正在使用Dreamweaver cs 5.5。這個問題的任何解決方案?Android設備上的PhoneGap無法使用!
這裏是我的代碼:
// invoked when device is ready
function deviceInfo() {
document.getElementById('window.device.platform').innerHTML = 'window.device.platform = ' + window.device.platform;
document.getElementById('window.device.version').innerHTML = 'window.device.version = ' + window.device.version;
document.getElementById('window.device.uuid').innerHTML = 'window.device.uuid = ' + window.device.uuid;
document.getElementById('window.device.phonegap').innerHTML = 'window.device.phonegap = ' + window.device.phonegap;
navigator.network.isReachable("phonegap.com", function(reachability) {
var states = {};
states[NetworkStatus.NOT_REACHABLE] = 'No network connection';
states[NetworkStatus.REACHABLE_VIA_CARRIER_DATA_NETWORK] = 'Carrier data connection';
states[NetworkStatus.REACHABLE_VIA_WIFI_NETWORK] = 'WiFi connection';
document.getElementById('networkStatus').innerHTML = 'isReachable = ' + states[reachability];
},
{ isIpAddress: false });
}
// invoked when application is resumed (brought to foregroud)
function doResume() {
console.log('doResume()');
}
// invoked when application is paused (sent to background)
function doPause() {
console.log('doPause()');
}
// register PhoneGap event listeners when DOM content loaded
function init() {
console.log('init()');
document.addEventListener("deviceready", deviceInfo, true);
document.addEventListener("resume", doResume, false);
document.addEventListener("pause", doPause, false);
}
function unload() {
console.log('unload()');
}
function fail(error) {
navigator.notification.alert(error, null, "Error");
}
在我的HTML:<body onload="init()" onunload="unload()">
您的JavaScript在Android 2.2模擬器上運行正常。也許你應該展示足夠的HTML來重現問題。 – 2011-05-27 21:19:39
這是我的!它不適用於我的。你是通過Dreamweaver運行你的模擬器嗎? – 2011-05-30 20:12:47
我從ADT運行模擬器。我沒有Dreamweaver。 – 2011-05-30 20:14:19