First of all, I did not do what @Mejo pointed out, thanks. Here is the solution to the problem.
Step 1: You do not need to include Script in HTML physically in a zip application, as PhoneGap Build is automatically added
<script src="cordova.js"></script> or <script src="phonegap.js"></script> any of them will work fine.
Step 2: Add this to Script to call the device :
document.addEventListener("deviceready", onDeviceReady, false);
Step 3: Add an event listener to the button and add code to this call:
function onDeviceReady(){ document.addEventListener("backbutton", onBackKeyDown, false); } function onBackKeyDown(){ alert('back'); return false; }
Now this will not work if you do not set the minSDK preference for the application by config.xml
Step 4: Add This To The Config.xml Preferences Area
<preference name="android-minSdkVersion" value="5" />
For reference: http://community.phonegap.com/nitobi/topics/how_to_handle_back_button_in_android
source share