Got an iPhone or iPad? We have a brand new Pastebin App for both devices, and it's totally free! Click here to download the new Pastebin App for iOS.
Guest

Untitled

By: a guest on Feb 9th, 2010  |  syntax: None  |  size: 0.78 KB  |  hits: 97  |  expires: Never
download  |  raw  |  embed  |  report abuse
Copied
  1. public class MainListActivity extends ListActivity{
  2.     @Override
  3.     public boolean onKeyDown(int keyCode, KeyEvent event)  {
  4.         if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.ECLAIR
  5.                 && keyCode == KeyEvent.KEYCODE_BACK
  6.                 && event.getRepeatCount() == 0) {
  7.             // Take care of calling this method on earlier versions of
  8.             // the platform where it doesn't exist.
  9.             onBackPressed();
  10.         }
  11.  
  12.         return super.onKeyDown(keyCode, event);
  13.     }
  14.  
  15.     @Override
  16.     public void onBackPressed() {
  17.         // This will be called either automatically for you on 2.0
  18.         // or later, or by the code above on earlier versions of the
  19.         // platform.
  20.                 finish();
  21.         return;
  22.     }
  23. }