Activity - onKeyDown

Top  Previous  Next

public class TESTEActivity extends Activity {

 

 @Override

  public void onCreate(Bundle savedInstanceState) {

      super.onCreate(savedInstanceState);

       setContentView(R.layout.main);

   }

   

  @Override

  public boolean onKeyDown(int keyCode, KeyEvent event) {

         if (keyCode == KeyEvent.KEYCODE_A) {

                 Toast.makeText(getBaseContext(), "A pressionardo", Toast.LENGTH_SHORT).show();

                 return true;

         }

         

         if (keyCode == KeyEvent.KEYCODE_B) {

                 Toast.makeText(getBaseContext(), "B pressionardo", Toast.LENGTH_SHORT).show();

                 return true;

         }

 

         return super.onKeyDown(keyCode, event);

   }

}