我有一个在iOS上运行良好的Phonegap应用程序.现在是时候将其移植到Android了...我正在使用 phonegap 3.0,因此 CLI 会安装插件,但它仍然不起作用。
这是我需要警报或在本例中为确认的页面的代码。
function onDeviceReady() {
//setup page
alert('deviceRead');
}
navigator.notification.confirm(
'blah blah', // message
onConfirm, // callback to invoke with index of button pressed
'title', // title
'cancel','ok' // buttonLabels
);
function onConfirm(button) {
if(button == 2)
{
alert('button 2 pressed');
}
else
{
}
}
有人可以帮我检查我应该在我的文件中检查什么吗?我是一个非常新的Android开发人员,所以它可能是.java文件或配置.xml?
编辑:我应该补充一点,日志等中没有抛出任何错误......并且在确认的两侧都有一个 alert() 被调用...就好像它传递了代码一样。
我发现解决方案实际上是我的配置.xml...
我正在使用:
<feature name="Notification">
<param name="android-package" value="org.apache.cordova.Notification" />
</feature>
这就是他们的安装页面上的电话差距......但实际上我需要将功能更改为:
<feature name="Notification">
<param name="android-package" value="org.apache.cordova.dialogs.Notification" />
</feature>
您的代码有错误,请尝试以下代码:
function onDeviceReady() {
navigator.notification.alert(
'This is Alert',
onOK,
'Alert',
'ok'
);
navigator.notification.confirm(
'This is confirm', // message
onConfirm, // callback to invoke with index of button pressed
'button 2', // title
'cancel', 'ok' // buttonLabels
);
}
function onConfirm(button) {
if (button == 2) {
alert('button 2 pressed');
} else {
}
}
function onOK() {
alert('OK pressed');
}