0

My android (4.0.4) phone (xperia neo L) comes with physical buttons for the 4 primary actions (back, home, settings, search)

Is it possible to make these available within the OS also?

John Eipe
  • 10,922
  • 24
  • 72
  • 114
  • What does "make these available within the OS" mean? – CommonsWare Feb 10 '13 at 14:27
  • make it available within the screen so that I dont use the physical buttons. – John Eipe Feb 10 '13 at 14:27
  • Some smartphones don't have these physical buttons instead they are available within the touch panel/screen. Unfortunately mine doesn't have. – John Eipe Feb 10 '13 at 14:33
  • @John So wat you trying to do iz customize the OS to integrate the menu function iniside OS?? which can be used via some status bar type of area. Pulling from upper side type of menu?? – Vikalp Patel Feb 10 '13 at 17:26
  • exactly like status bar kind of. but i dont want to do programmatic ally.... would be great if there is a app that does that for me. – John Eipe Feb 10 '13 at 17:29

1 Answers1

1

For opening the menu (same behaviour as clicking Menu physical button) just use the openOptionsMenu() method of your activity.

Here is a code that open the Menu with a button :

public class MainActivity extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        setContentView(R.layout.activity_main);

        Button button = (Button) findViewById(R.id.testButton);

        button.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                openOptionsMenu();
            }
        });
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.activity_main, menu);
        return true;
    }
}