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?
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?
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;
}
}