Hi guys,
I followed many guides on web to detect the long press of the Power Button which show you the device-off confirmation window, but nothing seems to work. I used onKeyDown to start tracking and onKeyLongPress with the specific keycode but they doesn’t seem to be called as well. Do you have any suggest?
@Override
public boolean onKeyDown( int keyCode, KeyEvent event ) {
if( keyCode == KeyEvent.KEYCODE_POWER ) {
event.startTracking();
return true;
}
return super.onKeyDown( keyCode, event );
}
@Override
public boolean onKeyLongPress( int keyCode, KeyEvent event ) {
if( keyCode == KeyEvent.KEYCODE_POWER ) {
//Handle what you want in long press.
UnityPlayer.UnitySendMessage("Pfb_GameControl","PauseGameFromNative","");
return true;
}
return super.onKeyLongPress( keyCode, event );
}