Your best bet is to use a plugin to launch the home screen. I've already created one for my own purposes - you can download my Eclipse test project containing the source code and resulting compiled APK from here.
You would then use my plugin to override the default behaviour of the back button something like this:
function onBackKeyDown(e) {
e.preventDefault();
cordova.require('cordova/plugin/home').goHome(function(){
console.info("Successfully launched home intent");
}, function(){
console.error("Error launching home intent");
});
}
document.addEventListener("backbutton", onBackKeyDown, false);
Here's the plugin source code:
Home.java
package org.apache.cordova.plugin;
import org.json.JSONArray;
import org.json.JSONException;
import android.content.Intent;
import android.util.Log;
import org.apache.cordova.api.CallbackContext;
import org.apache.cordova.api.CordovaPlugin;
public class Home extends CordovaPlugin {
private static final String LOG_TAG = "HomePlugin";
@Override
public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException {
if ("goHome".equals(action)) {
try {
Intent i = new Intent(Intent.ACTION_MAIN);
i.addCategory(Intent.CATEGORY_HOME);
this.cordova.getActivity().startActivity(i);
} catch (Exception e) {
Log.e(LOG_TAG, "Exception occurred: ".concat(e.getMessage()));
return false;
}
callbackContext.success();
return true;
}
Log.e(LOG_TAG, "Called invalid action: "+action);
return false;
}
}
home.js
cordova.define("cordova/plugin/home", function(require, exports, module) {
var exec = require('cordova/exec');
var Home = function() {};
Home.prototype.goHome = function(successCallback, errorCallback) {
return cordova.exec(successCallback, errorCallback, 'Home', 'goHome', []);
};
var home = new Home();
module.exports = home;
});
config.xml
<plugin name="Home" value="org.apache.cordova.plugin.Home"/>