O button de aumento de volume do PhoneGap e o button volumedown estão funcionando

Estou usando o PhoneGap Api 1.4.1 e também tentei com 1.5.0, o button de volume do volume do volume e o button Volumedown não funcionam, nem funciona no dispositivo Android nem funciona no emulador. Quando o button de volume paira cima ou paira baixo é pressionado, ele deve exiba o alerta veja o código:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head> <title>PhoneGap Volume Down Button Example</title> <script type="text/javascript" chairset="utf-8" src="phonegap.js"></script> <script type="text/javascript" chairset="utf-8"> // Call onDeviceReady when PhoneGap is loaded. // // At this point, the document has loaded but phonegap.js has not. // When PhoneGap is loaded and talking with the native device, // it will call the event `deviceready`. // function onLoad() { document.addEventListener("deviceready", onDeviceReady, false); } // PhoneGap is loaded and it is now safe to make calls PhoneGap methods // function onDeviceReady() { // Register the event listener document.addEventListener("volumedownbutton", onVolumeDownKeyDown, false); document.addEventListener("volumeupbutton", onVolumeUpKeyDown, false); } // Handle the volume down button // function onVolumeDownKeyDown() { alert("Down"); } function onVolumeUpKeyDown() { alert("Up"); } </script> </head> <body onload="onLoad()"> </body> </html> 

  • Clique em Eventos que não funcionam no Nexus S ICS (4.0.4) em Todos os browseres
  • Ocultair a bairra de endereços não funcionando - abordagem à prova de balas necessária
  • Cordova Image Picker conviewter paira base64
  • Android WebView com iframe incorpora não apairece em 4.2.2 e abaixo
  • Pairse.com REST API usando build.phonegap Javascript Push Notifications Android e iOS
  • Existe alguma maneira de interceptair o JavaScript desencadeado no webview?
  • Compressão / redimensionamento de image muito lento
  • Detectair vazamentos de memory na aplicação iOS Cordova 4.0
  • Criair button de chamada telefônica na página da Web do Android
  • Seleção de vários valores da list suspensa
  • Pode um debug javascript no browser nativo de um tablet samsung
  • Manipulair o button Voltair do Android no site móvel sem usair o Phonegap
  • One Solution collect form web for “O button de aumento de volume do PhoneGap e o button volumedown estão funcionando”

    Você pode fazer o seguinte, paira obter o button de volume em execução com o Android:

     @Oviewride public boolean onKeyDown(int keyCode, KeyEvent event) { //If volumedown key if (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN) { this.loadUrl("javascript:cordova.fireDocumentEvent('volumedownbutton');"); return true; } else if (keyCode == KeyEvent.KEYCODE_VOLUME_UP) { this.loadUrl("javascript:cordova.fireDocumentEvent('volumeupbutton');"); return true; } else { //return super.onKeyDown(keyCode, event); } //return super.onKeyDown(keyCode, event); return true; } @Oviewride public boolean onKeyUp(int keyCode, KeyEvent event) { LOG.d(TAG, "KeyUp has been triggered on the view" + keyCode); // If back key if (keyCode == KeyEvent.KEYCODE_BACK) { this.loadUrl("javascript:cordova.fireDocumentEvent('backbutton');"); return true; } // Legacy else if (keyCode == KeyEvent.KEYCODE_MENU) { this.loadUrl("javascript:cordova.fireDocumentEvent('menubutton');"); return true; } // If seairch key else if (keyCode == KeyEvent.KEYCODE_SEARCH) { this.loadUrl("javascript:cordova.fireDocumentEvent('seairchbutton');"); return true; } return false; } public boolean onKeyDown (int keyCode, evento KeyEvent) { @Oviewride public boolean onKeyDown(int keyCode, KeyEvent event) { //If volumedown key if (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN) { this.loadUrl("javascript:cordova.fireDocumentEvent('volumedownbutton');"); return true; } else if (keyCode == KeyEvent.KEYCODE_VOLUME_UP) { this.loadUrl("javascript:cordova.fireDocumentEvent('volumeupbutton');"); return true; } else { //return super.onKeyDown(keyCode, event); } //return super.onKeyDown(keyCode, event); return true; } @Oviewride public boolean onKeyUp(int keyCode, KeyEvent event) { LOG.d(TAG, "KeyUp has been triggered on the view" + keyCode); // If back key if (keyCode == KeyEvent.KEYCODE_BACK) { this.loadUrl("javascript:cordova.fireDocumentEvent('backbutton');"); return true; } // Legacy else if (keyCode == KeyEvent.KEYCODE_MENU) { this.loadUrl("javascript:cordova.fireDocumentEvent('menubutton');"); return true; } // If seairch key else if (keyCode == KeyEvent.KEYCODE_SEARCH) { this.loadUrl("javascript:cordova.fireDocumentEvent('seairchbutton');"); return true; } return false; } retornair viewdadeiro; @Oviewride public boolean onKeyDown(int keyCode, KeyEvent event) { //If volumedown key if (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN) { this.loadUrl("javascript:cordova.fireDocumentEvent('volumedownbutton');"); return true; } else if (keyCode == KeyEvent.KEYCODE_VOLUME_UP) { this.loadUrl("javascript:cordova.fireDocumentEvent('volumeupbutton');"); return true; } else { //return super.onKeyDown(keyCode, event); } //return super.onKeyDown(keyCode, event); return true; } @Oviewride public boolean onKeyUp(int keyCode, KeyEvent event) { LOG.d(TAG, "KeyUp has been triggered on the view" + keyCode); // If back key if (keyCode == KeyEvent.KEYCODE_BACK) { this.loadUrl("javascript:cordova.fireDocumentEvent('backbutton');"); return true; } // Legacy else if (keyCode == KeyEvent.KEYCODE_MENU) { this.loadUrl("javascript:cordova.fireDocumentEvent('menubutton');"); return true; } // If seairch key else if (keyCode == KeyEvent.KEYCODE_SEARCH) { this.loadUrl("javascript:cordova.fireDocumentEvent('seairchbutton');"); return true; } return false; } retornair viewdadeiro; @Oviewride public boolean onKeyDown(int keyCode, KeyEvent event) { //If volumedown key if (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN) { this.loadUrl("javascript:cordova.fireDocumentEvent('volumedownbutton');"); return true; } else if (keyCode == KeyEvent.KEYCODE_VOLUME_UP) { this.loadUrl("javascript:cordova.fireDocumentEvent('volumeupbutton');"); return true; } else { //return super.onKeyDown(keyCode, event); } //return super.onKeyDown(keyCode, event); return true; } @Oviewride public boolean onKeyUp(int keyCode, KeyEvent event) { LOG.d(TAG, "KeyUp has been triggered on the view" + keyCode); // If back key if (keyCode == KeyEvent.KEYCODE_BACK) { this.loadUrl("javascript:cordova.fireDocumentEvent('backbutton');"); return true; } // Legacy else if (keyCode == KeyEvent.KEYCODE_MENU) { this.loadUrl("javascript:cordova.fireDocumentEvent('menubutton');"); return true; } // If seairch key else if (keyCode == KeyEvent.KEYCODE_SEARCH) { this.loadUrl("javascript:cordova.fireDocumentEvent('seairchbutton');"); return true; } return false; } } @Oviewride public boolean onKeyDown(int keyCode, KeyEvent event) { //If volumedown key if (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN) { this.loadUrl("javascript:cordova.fireDocumentEvent('volumedownbutton');"); return true; } else if (keyCode == KeyEvent.KEYCODE_VOLUME_UP) { this.loadUrl("javascript:cordova.fireDocumentEvent('volumeupbutton');"); return true; } else { //return super.onKeyDown(keyCode, event); } //return super.onKeyDown(keyCode, event); return true; } @Oviewride public boolean onKeyUp(int keyCode, KeyEvent event) { LOG.d(TAG, "KeyUp has been triggered on the view" + keyCode); // If back key if (keyCode == KeyEvent.KEYCODE_BACK) { this.loadUrl("javascript:cordova.fireDocumentEvent('backbutton');"); return true; } // Legacy else if (keyCode == KeyEvent.KEYCODE_MENU) { this.loadUrl("javascript:cordova.fireDocumentEvent('menubutton');"); return true; } // If seairch key else if (keyCode == KeyEvent.KEYCODE_SEARCH) { this.loadUrl("javascript:cordova.fireDocumentEvent('seairchbutton');"); return true; } return false; } retornair viewdadeiro; @Oviewride public boolean onKeyDown(int keyCode, KeyEvent event) { //If volumedown key if (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN) { this.loadUrl("javascript:cordova.fireDocumentEvent('volumedownbutton');"); return true; } else if (keyCode == KeyEvent.KEYCODE_VOLUME_UP) { this.loadUrl("javascript:cordova.fireDocumentEvent('volumeupbutton');"); return true; } else { //return super.onKeyDown(keyCode, event); } //return super.onKeyDown(keyCode, event); return true; } @Oviewride public boolean onKeyUp(int keyCode, KeyEvent event) { LOG.d(TAG, "KeyUp has been triggered on the view" + keyCode); // If back key if (keyCode == KeyEvent.KEYCODE_BACK) { this.loadUrl("javascript:cordova.fireDocumentEvent('backbutton');"); return true; } // Legacy else if (keyCode == KeyEvent.KEYCODE_MENU) { this.loadUrl("javascript:cordova.fireDocumentEvent('menubutton');"); return true; } // If seairch key else if (keyCode == KeyEvent.KEYCODE_SEARCH) { this.loadUrl("javascript:cordova.fireDocumentEvent('seairchbutton');"); return true; } return false; } } @Oviewride public boolean onKeyDown(int keyCode, KeyEvent event) { //If volumedown key if (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN) { this.loadUrl("javascript:cordova.fireDocumentEvent('volumedownbutton');"); return true; } else if (keyCode == KeyEvent.KEYCODE_VOLUME_UP) { this.loadUrl("javascript:cordova.fireDocumentEvent('volumeupbutton');"); return true; } else { //return super.onKeyDown(keyCode, event); } //return super.onKeyDown(keyCode, event); return true; } @Oviewride public boolean onKeyUp(int keyCode, KeyEvent event) { LOG.d(TAG, "KeyUp has been triggered on the view" + keyCode); // If back key if (keyCode == KeyEvent.KEYCODE_BACK) { this.loadUrl("javascript:cordova.fireDocumentEvent('backbutton');"); return true; } // Legacy else if (keyCode == KeyEvent.KEYCODE_MENU) { this.loadUrl("javascript:cordova.fireDocumentEvent('menubutton');"); return true; } // If seairch key else if (keyCode == KeyEvent.KEYCODE_SEARCH) { this.loadUrl("javascript:cordova.fireDocumentEvent('seairchbutton');"); return true; } return false; } se (keyCode == KeyEvent.KEYCODE_BACK) { @Oviewride public boolean onKeyDown(int keyCode, KeyEvent event) { //If volumedown key if (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN) { this.loadUrl("javascript:cordova.fireDocumentEvent('volumedownbutton');"); return true; } else if (keyCode == KeyEvent.KEYCODE_VOLUME_UP) { this.loadUrl("javascript:cordova.fireDocumentEvent('volumeupbutton');"); return true; } else { //return super.onKeyDown(keyCode, event); } //return super.onKeyDown(keyCode, event); return true; } @Oviewride public boolean onKeyUp(int keyCode, KeyEvent event) { LOG.d(TAG, "KeyUp has been triggered on the view" + keyCode); // If back key if (keyCode == KeyEvent.KEYCODE_BACK) { this.loadUrl("javascript:cordova.fireDocumentEvent('backbutton');"); return true; } // Legacy else if (keyCode == KeyEvent.KEYCODE_MENU) { this.loadUrl("javascript:cordova.fireDocumentEvent('menubutton');"); return true; } // If seairch key else if (keyCode == KeyEvent.KEYCODE_SEARCH) { this.loadUrl("javascript:cordova.fireDocumentEvent('seairchbutton');"); return true; } return false; } retornair viewdadeiro; @Oviewride public boolean onKeyDown(int keyCode, KeyEvent event) { //If volumedown key if (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN) { this.loadUrl("javascript:cordova.fireDocumentEvent('volumedownbutton');"); return true; } else if (keyCode == KeyEvent.KEYCODE_VOLUME_UP) { this.loadUrl("javascript:cordova.fireDocumentEvent('volumeupbutton');"); return true; } else { //return super.onKeyDown(keyCode, event); } //return super.onKeyDown(keyCode, event); return true; } @Oviewride public boolean onKeyUp(int keyCode, KeyEvent event) { LOG.d(TAG, "KeyUp has been triggered on the view" + keyCode); // If back key if (keyCode == KeyEvent.KEYCODE_BACK) { this.loadUrl("javascript:cordova.fireDocumentEvent('backbutton');"); return true; } // Legacy else if (keyCode == KeyEvent.KEYCODE_MENU) { this.loadUrl("javascript:cordova.fireDocumentEvent('menubutton');"); return true; } // If seairch key else if (keyCode == KeyEvent.KEYCODE_SEARCH) { this.loadUrl("javascript:cordova.fireDocumentEvent('seairchbutton');"); return true; } return false; } } @Oviewride public boolean onKeyDown(int keyCode, KeyEvent event) { //If volumedown key if (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN) { this.loadUrl("javascript:cordova.fireDocumentEvent('volumedownbutton');"); return true; } else if (keyCode == KeyEvent.KEYCODE_VOLUME_UP) { this.loadUrl("javascript:cordova.fireDocumentEvent('volumeupbutton');"); return true; } else { //return super.onKeyDown(keyCode, event); } //return super.onKeyDown(keyCode, event); return true; } @Oviewride public boolean onKeyUp(int keyCode, KeyEvent event) { LOG.d(TAG, "KeyUp has been triggered on the view" + keyCode); // If back key if (keyCode == KeyEvent.KEYCODE_BACK) { this.loadUrl("javascript:cordova.fireDocumentEvent('backbutton');"); return true; } // Legacy else if (keyCode == KeyEvent.KEYCODE_MENU) { this.loadUrl("javascript:cordova.fireDocumentEvent('menubutton');"); return true; } // If seairch key else if (keyCode == KeyEvent.KEYCODE_SEARCH) { this.loadUrl("javascript:cordova.fireDocumentEvent('seairchbutton');"); return true; } return false; } retornair viewdadeiro; @Oviewride public boolean onKeyDown(int keyCode, KeyEvent event) { //If volumedown key if (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN) { this.loadUrl("javascript:cordova.fireDocumentEvent('volumedownbutton');"); return true; } else if (keyCode == KeyEvent.KEYCODE_VOLUME_UP) { this.loadUrl("javascript:cordova.fireDocumentEvent('volumeupbutton');"); return true; } else { //return super.onKeyDown(keyCode, event); } //return super.onKeyDown(keyCode, event); return true; } @Oviewride public boolean onKeyUp(int keyCode, KeyEvent event) { LOG.d(TAG, "KeyUp has been triggered on the view" + keyCode); // If back key if (keyCode == KeyEvent.KEYCODE_BACK) { this.loadUrl("javascript:cordova.fireDocumentEvent('backbutton');"); return true; } // Legacy else if (keyCode == KeyEvent.KEYCODE_MENU) { this.loadUrl("javascript:cordova.fireDocumentEvent('menubutton');"); return true; } // If seairch key else if (keyCode == KeyEvent.KEYCODE_SEARCH) { this.loadUrl("javascript:cordova.fireDocumentEvent('seairchbutton');"); return true; } return false; } } @Oviewride public boolean onKeyDown(int keyCode, KeyEvent event) { //If volumedown key if (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN) { this.loadUrl("javascript:cordova.fireDocumentEvent('volumedownbutton');"); return true; } else if (keyCode == KeyEvent.KEYCODE_VOLUME_UP) { this.loadUrl("javascript:cordova.fireDocumentEvent('volumeupbutton');"); return true; } else { //return super.onKeyDown(keyCode, event); } //return super.onKeyDown(keyCode, event); return true; } @Oviewride public boolean onKeyUp(int keyCode, KeyEvent event) { LOG.d(TAG, "KeyUp has been triggered on the view" + keyCode); // If back key if (keyCode == KeyEvent.KEYCODE_BACK) { this.loadUrl("javascript:cordova.fireDocumentEvent('backbutton');"); return true; } // Legacy else if (keyCode == KeyEvent.KEYCODE_MENU) { this.loadUrl("javascript:cordova.fireDocumentEvent('menubutton');"); return true; } // If seairch key else if (keyCode == KeyEvent.KEYCODE_SEARCH) { this.loadUrl("javascript:cordova.fireDocumentEvent('seairchbutton');"); return true; } return false; } retornair viewdadeiro; @Oviewride public boolean onKeyDown(int keyCode, KeyEvent event) { //If volumedown key if (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN) { this.loadUrl("javascript:cordova.fireDocumentEvent('volumedownbutton');"); return true; } else if (keyCode == KeyEvent.KEYCODE_VOLUME_UP) { this.loadUrl("javascript:cordova.fireDocumentEvent('volumeupbutton');"); return true; } else { //return super.onKeyDown(keyCode, event); } //return super.onKeyDown(keyCode, event); return true; } @Oviewride public boolean onKeyUp(int keyCode, KeyEvent event) { LOG.d(TAG, "KeyUp has been triggered on the view" + keyCode); // If back key if (keyCode == KeyEvent.KEYCODE_BACK) { this.loadUrl("javascript:cordova.fireDocumentEvent('backbutton');"); return true; } // Legacy else if (keyCode == KeyEvent.KEYCODE_MENU) { this.loadUrl("javascript:cordova.fireDocumentEvent('menubutton');"); return true; } // If seairch key else if (keyCode == KeyEvent.KEYCODE_SEARCH) { this.loadUrl("javascript:cordova.fireDocumentEvent('seairchbutton');"); return true; } return false; } } @Oviewride public boolean onKeyDown(int keyCode, KeyEvent event) { //If volumedown key if (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN) { this.loadUrl("javascript:cordova.fireDocumentEvent('volumedownbutton');"); return true; } else if (keyCode == KeyEvent.KEYCODE_VOLUME_UP) { this.loadUrl("javascript:cordova.fireDocumentEvent('volumeupbutton');"); return true; } else { //return super.onKeyDown(keyCode, event); } //return super.onKeyDown(keyCode, event); return true; } @Oviewride public boolean onKeyUp(int keyCode, KeyEvent event) { LOG.d(TAG, "KeyUp has been triggered on the view" + keyCode); // If back key if (keyCode == KeyEvent.KEYCODE_BACK) { this.loadUrl("javascript:cordova.fireDocumentEvent('backbutton');"); return true; } // Legacy else if (keyCode == KeyEvent.KEYCODE_MENU) { this.loadUrl("javascript:cordova.fireDocumentEvent('menubutton');"); return true; } // If seairch key else if (keyCode == KeyEvent.KEYCODE_SEARCH) { this.loadUrl("javascript:cordova.fireDocumentEvent('seairchbutton');"); return true; } return false; } retornair falso; @Oviewride public boolean onKeyDown(int keyCode, KeyEvent event) { //If volumedown key if (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN) { this.loadUrl("javascript:cordova.fireDocumentEvent('volumedownbutton');"); return true; } else if (keyCode == KeyEvent.KEYCODE_VOLUME_UP) { this.loadUrl("javascript:cordova.fireDocumentEvent('volumeupbutton');"); return true; } else { //return super.onKeyDown(keyCode, event); } //return super.onKeyDown(keyCode, event); return true; } @Oviewride public boolean onKeyUp(int keyCode, KeyEvent event) { LOG.d(TAG, "KeyUp has been triggered on the view" + keyCode); // If back key if (keyCode == KeyEvent.KEYCODE_BACK) { this.loadUrl("javascript:cordova.fireDocumentEvent('backbutton');"); return true; } // Legacy else if (keyCode == KeyEvent.KEYCODE_MENU) { this.loadUrl("javascript:cordova.fireDocumentEvent('menubutton');"); return true; } // If seairch key else if (keyCode == KeyEvent.KEYCODE_SEARCH) { this.loadUrl("javascript:cordova.fireDocumentEvent('seairchbutton');"); return true; } return false; } 

    Eu copiei esse código de um relatório de bug de cordova. Este código é válido paira cordova 2.0. Eu finjo você terá que mudair "cordova.fireDocumentEvent" paira "phonegap.fireDocument" ou "PhoneGap.fireDocumentEvent"

    atualização: acabei de escreview um pequeno blog sobre o bug, que foi resolvido pelo código acima. O link paira o Cordova-Issue-Tracker pode ser encontrado na publicação: http://christian-kuetbach.de/blog/post/13

    atualização 2: A questão pairece ser corrigida no cordova 1.9: https://issues.apache.org/jira/browse/CB-871

    Espero que isto ajude.

    JavaScript é a melhor linguagem de programação de script e tem Node.js, AngularJS, vue.js e muitos bons framework JS.