开发者

The method onKeyPreIme(int, KeyEvent) of type myClass must override or implement a supertype

I am trying to create a lock screen in an app so that when the user requests it (remotely) the phone will lock itself with a preset password.

I'm trying to use the onKeyPreIme method because I read that onKeyDown() and other related methods sometimes will be consumed AFTER the android system does the default action (rare maybe, but possible).

I made my code extend View instead of Activity and that let onKeyPreIme work, but none of the other coding would work at that point because I needed to extend Activity for that. I also tried implementing KeyEvent.Callback but that doesn't change anything. I checked my settings in Eclipse, and it is developing based on java 1.6 and my android plugin is completely up to date as is my Eclipse. The eclipse I have is Eclipse IDE for Java Developers, and there's also Eclipse IDE for Java EE Developers and Eclipse Classic. I wonder if either of those would be different?

I built this project initially in Eclipse, so it wasn't imported from anywhere else, so I know that's not a problem.

@Override
public boolean onKeyPreIme(int keyCode, KeyEvent event) {
//do my work here
return super.onKeyPreIme(keyCode, event);
}

I tried not overriding, but of course that doesn't do anything, and I also get "The method onKeyPreIme(int, KeyEvent) is undefined for the type Activity" for 'return super.onKeyPreIme"

I'm at a loss of wh开发者_如何学运维at to do to get onKeyPreIme working.

If I can't get it to work, would there be any drawbacks to using onKeyDown (and onKeyUp and onKeyLongPress) instead?.

Anyone have any ideas on how to get the OnKeyPreIme to work properly?


OnKeyPreIme is a View function, so you must implement your custom View component and override the function there.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜