我正在使用WebWorks和Sencha Touch 2.2在BlackBerry 10上开发Phonegap 2.3应用程序。当我尝试根据文档调用getPreferredLanguage()
方法时:
navigator.globalization.getPreferredLanguage(
function (language) {alert('language: ' + language.value + '\n');},
function () {alert('Error getting language\n');}
);
我收到以下错误:
Error: Status=2 Message=Class Globalization cannot be found
文档声明在OS5及更高版本的BlackBerry上支持全球化类,那么为什么我会发现类未找到错误?
答案 0 :(得分:1)
尝试检查“设备就绪”事件是否已被触发:
$(document).ready(function() {
document.addEventListener("deviceready", onDeviceReady, false);
});
function onDeviceReady() {
alert('device ready');
navigator.globalization.getPreferredLanguage(
function (language) {alert('language: ' + language.value + '\n');},
function () {alert('Error getting language\n');}
);
}
答案 1 :(得分:0)
在config.xml文件中更改
这
<feature name="Geolocation">
<param name="android-package" value="org.apache.cordova.Globalization" />
</feature>
到
<feature name="Geolocation">
<param name="android-package" value="org.apache.cordova.globalization.Globalization" />
</feature>