コード例 #1
0
 /**
  * Finds an open device that has a name containing keypad. This probably is the event node
  * associated with the keypad Its purpose is to handle all hardware Android buttons such as Back,
  * Home, Volume, etc Key codes are defined in input.h (see NDK) , or use the Event Monitor to see
  * keypad messages This function sends the BACK key
  */
 public void SendBackKeyToKeypad() {
   for (InputDevice idev : events.m_Devs) {
     // * Finds an open device that has a name containing keypad. This probably is the keypad
     // associated event node
     if (idev.getOpen() && idev.getName().contains("keypad")) {
       idev.SendKey(158, true); // Back key down
       idev.SendKey(158, false); // back key up
     }
   }
 }
コード例 #2
0
 /**
  * Finds an open device that has a name containing keypad. This probably is the event node
  * associated with the keypad Its purpose is to handle all hardware Android buttons such as Back,
  * Home, Volume, etc Key codes are defined in input.h (see NDK) , or use the Event Monitor to see
  * keypad messages This function sends the HOME key
  */
 public void SendHomeKeyToKeypad() {
   boolean found = false;
   for (InputDevice idev : events.m_Devs) {
     // * Finds an open device that has a name containing keypad. This probably is the keypad
     // associated event node
     if (idev.getOpen() && idev.getName().contains("keypad")) {
       idev.SendKey(102, true); // home key down
       idev.SendKey(102, false); // home key up
       found = true;
       break;
     }
   }
   if (found == false) Toast.makeText(this, "Keypad not found.", Toast.LENGTH_SHORT).show();
 }