Reputation: 1575
I have big problem with my keyevent i am trying to call my another acvitity but the keyevent is not working please check what mistake i made for my code. actually i created one carousel design if i press softkeyboard enter button in my laptop the keyevent is not working...
This case is not working for me...
case KeyEvent.KEYCODE_ENTER:
System.out.println("enter pressed");
if(position==0);{
Intent intent = new Intent(sampleActivity.this, test.class);
startActivity(intent);
}
Upvotes: 1
Views: 171
Reputation: 1785
Your code seems correct (apart from the synthax error), the only difference I see from working examples is your event.getAction() condition. I'd suggest to check the ACTION_DOWN clause.
Upvotes: 1
Reputation: 3822
I suppose you need to enable your keyboard input. Even though the developer documentation says keyboard support is enabled by default it doesn't seem to be that way in SDK rev 20. I explicitly enabled keyboard support in my emulator's config.ini file and that worked!
Add: hw.keyboard=yes
To: ~/.android/avd/.avd/config.ini
Reference: http://developer.android.com/tools/devices/managing-avds-cmdline.html#hardwareopts
Upvotes: 2