android-OptionMenu
@Override public boolean onCreateOptionsMenu(Menu menu) { super.onCreateOptionsMenu(menu); menu.add(0, MENU_UPDATE, Menu.NONE, R.string.menu_update); menu.add(0, MENU_PREFERENCES, Menu.NONE, R.string.menu_preferences); return true; } public boolean onOptionsItemSelected(MenuItem item) { super.onOptionsItemSelected(item); switch (item.getItemId()) { case (MENU_UPDATE): { refreshEarthquakes(); return true; } case (MENU_PREFERENCES): { Intent i = new Intent(this, Preferences.class); startActivityForResult(i, SHOW_PREFERENCES); return true; } } return false; } @Override public void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (requestCode == SHOW_PREFERENCES) if (resultCode == Activity.RESULT_OK) { updateFromPreferences(); refreshEarthquakes(); } }