title: How to disable exit functionality on press of android device back button in phonegap app?
body: <p>I have a sample phonegapp application which plays an audio stream(i.e- kalimba.mp3) in background of the app. Playing audio in background is working fine. when I press device home button application is getting minimized but audio playing continues  but when I press device back button, the application is getting terminated and so as the background audio. </p>
  
  <p>I have added this line, for not exiting the app on click on back button in my .java file</p>
  
  <pre><code>super.setBooleanProperty("keepRunning", true);
  </code></pre>
  
  <p>But application is still getting terminated. I want my application be still running when I press back button or home button in my android device and play the audio stream until I close the app from task manager. How to do it?</p>
  
  <p>I am using Android V4.0.0.</p>
  
  <p>here is my code</p>
  
  <pre><code> &lt;html&gt;
        &lt;head&gt;
          &lt;title&gt;Media Example&lt;/title&gt;
  
          &lt;script type="text/javascript" charset="utf-8" src="cordova.js"&gt;&lt;/script&gt;
  
          &lt;script type="text/javascript" charset="utf-8"&gt;
  
          // Wait for Cordova to load
          //
          document.addEventListener("deviceready", onDeviceReady, false);
  
          // Cordova is ready
          //
          function onDeviceReady() {
              playAudio("/android_asset/www/Kalimba.mp3");
          }
  
          // Audio player
          //
          var my_media = null;
          var mediaTimer = null;
  
          // Play audio
          //
          function playAudio(src) {
              // Create Media object from src
              my_media = new Media(src, onSuccess, onError);
  
              // Play audio
              my_media.play();
  
              // Update my_media position every second
              if (mediaTimer == null) {
                  mediaTimer = setInterval(function() {
                      // get my_media position
                      my_media.getCurrentPosition(
                          // success callback
                          function(position) {
                              if (position &gt; -1) {
                                  setAudioPosition((position) + " sec");
                              }
                          },
                          // error callback
                          function(e) {
                              console.log("Error getting pos=" + e);
                              setAudioPosition("Error: " + e);
                          }
                      );
                  }, 1000);
              }
          }
  
          // Pause audio
          // 
          function pauseAudio() {
              if (my_media) {
                  my_media.pause();
              }
          }
  
          // Stop audio
          // 
          function stopAudio() {
              if (my_media) {
                  my_media.stop();
              }
              clearInterval(mediaTimer);
              mediaTimer = null;
          }
  
          // onSuccess Callback
          //
          function onSuccess() {
              console.log("playAudio():Audio Success");
          }
  
          // onError Callback 
          //
          function onError(error) {
              alert('code: '    + error.code    + '\n' + 
                    'message: ' + error.message + '\n');
          }
  
          // Set audio position
          // 
          function setAudioPosition(position) {
              document.getElementById('audio_position').innerHTML = position;
          }
  
          function disalert(){
          alert("extra functionality is working fine");
  
          }
  
          &lt;/script&gt;
        &lt;/head&gt;
        &lt;body&gt;
          &lt;a href="#" class="btn large" onclick="playAudio('/android_asset/www/Kalimba.mp3');"&gt;Play Audio&lt;/a&gt;
          &lt;a href="#" class="btn large" onclick="pauseAudio();"&gt;Pause Playing Audio&lt;/a&gt;
          &lt;a href="#" class="btn large" onclick="stopAudio();"&gt;Stop Playing Audio&lt;/a&gt;
          &lt;p id="audio_position"&gt;&lt;/p&gt;
          &lt;button onclick="disalert();"&gt;click to interupt&lt;/button&gt;
        &lt;/body&gt;
      &lt;/html&gt;
  </code></pre>