The method onBackPressed() of type FirstGroup must override a superclass method
I'm trying to override the onBackPressed()
method of the ActivityGroup
class:
public class MyClass extends ActivityGroup {
@Override
public void onBackPressed() {
// do something
return;
}
but I'm getting the error The method onBackPressed() of type MyClass must override a superclass method
.
I'm relatively new to Java, I've seen here that people do it and it works for them
Why I'm getting thi开发者_运维知识库s error?
I'm writing an app for android 1.5, could the problem be here?
Edit
You need to override the back button like this
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if ((keyCode == KeyEvent.KEYCODE_BACK)) {
Log.d(this.getClass().getName(), "back button pressed");
}
return super.onKeyDown(keyCode, event);
}
Yes u r correct onBackPressed()
method has been introduced only in API Level 5 which means you can use it only from 2.0 SDK
精彩评论