I am having issues getting keyboard input for my game. I am currently just trying to get it to print either “KEY DOWN” or “KEY UP” to the log to see that it worked. All I get when I press any keys (whether it is the menu key or any other keys on my phone’s physical keyboard), is a log printout saying:
01-20 02:53:57.718: WARN/System.err(13847): No Keyboard Setting saved.
I don’t know what that means, and a google search has not been helpful. I did not put that log output in myself. I am basing my game off the lunar lander example. Has anyone seen this before?
The code I am using to test:
@Override
public boolean onKeyDown(int keyCode, KeyEvent msg)
{
if (keyCode == KeyEvent.KEYCODE_MENU)
{
Log.i("myActivity","KEY DOWN");
return true;
}
else return false;
}
@Override
public boolean onKeyUp(int keyCode, KeyEvent msg)
{
if (keyCode == KeyEvent.KEYCODE_MENU)
{
Log.i("myActivity","KEY UP");
return true;
}
else return false;
}
EDIT: Note that it never prints out either KEY DOWN or KEY UP, and even if I move either log output out of the “if (keycode==…)” section, it still doesnt run.
Fixed it by adding ‘setFocusableInTouchMode(true);’ to the constructor.