Phonegap how is it possible to have a "settings" page from the application menu?

Dimitrios Mistriotis picture Dimitrios Mistriotis · Sep 2, 2012 · Viewed 9.8k times · Source

I am developing an application for phonegap and discovered that when I press the menu button on my phone, I see an option named "settings".

The option that gets triggered on the debugger when I choose it is the following:

: D/DroidGap(12793): onMessage(onOptionsItemSelected,Settings)

Is there any possible way to hook that call to a page/parametered query inside the application, something in the lines of "settings.html" or "index.html?page=settings"?

I tried to google around but with no luck. My application just got upgraded to version 2.0, but I do not believe that this matters.

Update: This is an extract of my current implementation:

var onMenuKeyDown;
onMenuKeyDown = function(ev) {
  return $("#mainBox").html(ev.type);
};
document.addEventListener("menubutton", onMenuKeyDown, false);

It seems to change "mainBox"'es inner html to "menubutton" when firing the event on the simulator, but this does not happen when I run it on the actual devise.

Answer

Simon MacDonald picture Simon MacDonald · Sep 3, 2012

You have two options.

1) You can listen for "menubutton" events then provide your own html settings page. 2) You can implement a native preferences pane and call it via the AppPreferences plugin.

http://simonmacdonald.blogspot.com/2012/06/phongap-android-application-preferences.html