The home key is not delivered to applications.
On Fri, Aug 7, 2009 at 7:25 PM, eags<[email protected]> wrote: > > I have implemented onKeyDown and can successfully intercept > KEYCODE_BACK and many others to prohibit the default behavior. Is > this not possible with KEYCODE_HOME? I have a test activity that will > only finish() if KEYCODE_A is seen. Even KEYCODE_BACK does nothing. > However KEYCODE_HOME continues to have its effect. > > Anyone have any insight into this? > > Thanks. The test code is below. The strange thing to note is that > although the toast in the if/else that should handle the KEYCODE_HOME > never fires, if I relaunch the application the state is *not* restored > so it is like either the onDestroy is being called (previously I tried > finish() also) or it is like the application is crashing for some > other reason. > > I'm confused. > > > import android.app.Activity; > import android.os.Bundle; > import android.view.KeyEvent; > import android.widget.Toast; > > public class MainMenu extends Activity > { > public void onCreate(Bundle bun) > { > super.onCreate(bun); > setContentView(R.layout.main); > > } > public boolean onKeyDown(int keyCode, KeyEvent event) > { > //if we get any key, clear the Splash Screen > if(keyCode==KeyEvent.KEYCODE_HOME) { > Toast.makeText(getApplicationContext(), "HIT!", > Toast.LENGTH_SHORT).show(); > onDestroy(); > return true; > } else { > Toast.makeText(getApplicationContext(), "missed", > Toast.LENGTH_SHORT).show(); > return true; > } > //return super.onKeyDown(keyCode, event); > } > > } > > > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~----------~----~----~----~------~----~------~--~---

