views:

22

answers:

1

Beginning with a basic approach -- Options Menu.

Question: What is the best way to capture a cancel (return) event? I.e. the user changes their mind and hits the back arrow. The issue is that I would like to unpause my an application thread.

 @Override
 public boolean onCreateOptionsMenu(Menu menu) {

  onPause();

  MenuInflater inflater = getMenuInflater();
  inflater.inflate(R.menu.game_menu, menu);
  return true;
 }

 @Override
 public boolean onOptionsItemSelected(MenuItem item) {
  // Handle item selection
  switch (item.getItemId()) {

  case R.id.preferences:
   Intent settingsActivity = new Intent(this, PreferencesActivity.class);
   startActivity(settingsActivity);
   return true;

  case R.id.quit:
   finish();
   return true;

  default:
   return super.onOptionsItemSelected(item);
  }
 }

Is there something like @Override onCancelOptionsMenu ??

A: 

I think the function you are looking for is onOptionsMenuClosed.

Mayra
Thanks again Mayra! :)
Jamasan