3

我有一个可以在 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 文件或 config.xml?

编辑:我应该补充一点,日志等中没有抛出任何错误......并且在确认的两侧都有一个 alert() 被调用......它就像它通过代码一样......

4

2 回答 2

4

我发现解决方案实际上是我的 config.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>
于 2013-10-29T01:39:54.377 回答
0

您的代码有错误尝试以下代码:

 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');
    }
于 2013-10-22T05:18:49.723 回答