3

I have a phonegap app that is working perfectly on iOS.. it has now come time to port it to android... I am using phonegap 3.0 so the CLI installs the plugin however it still does not work.

Here is my code for the page requiring the alert or in this case the confirm.

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
   {
   }                                       
}  

Could someone please help me with what I should be checking in my files? I am very new an Android dev so it might be the .java file or the config.xml?

EDIT: I should add that there are no errors being thrown in the log etc... and there is an alert() on either side of the confirm that gets called... its just as if it passes over the code..

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 に答える