I hit a weird issue with my Android app. In my main activity there is a menu attached to a menu button. The problem is that the menu button works exactly once. After clicking, the application must be restarted before the menu button will work again.
Code (sanitized):
public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_NO_TITLE); getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); setContentView(R.layout.main); settings = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()); } @Override public boolean onCreateOptionsMenu(Menu menu) { startActivity(new Intent(this, PreferencesActivity.class)); return(super.onCreateOptionsMenu(menu)); } @Override public void onBackPressed() { this.finish(); } @Override public void onDestroy() { super.onDestroy(); this.finish(); } @Override public void onStop() { super.onStop(); this.finish(); }
and preference activity looks like
public class PreferencesActivity extends PreferenceActivity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); addPreferencesFromResource(R.xml.preferences); } @Override public void onResume() { super.onResume(); } @Override public void onStop() { super.onStop(); this.finish(); } @Override public void onBackPressed() { this.finish(); } }
Any ideas how I should solve this?
TIA
source share