I'd like to listen for a long key press in my Android application, and from Android 2.0 there is a method
public boolean onKeyLongPress(int keyCode, KeyEvent event)
to override. But what can I do if my app absolutely has to support API 4 (Android 1.6)? I know that I can call API methods with reflection, but I'm pretty sure that I cannot override with reflection.
@Override is an java annotation . Indicates that a method declaration is intended to override a method declaration in a superclass. If a method is annotated with this annotation type but does not override a superclass method, compilers are required to generate an error message.
The getFact() method is a new method declared in this FactBook class (it's not a method of the Object class), so you do not need to override it. To have a list of all the methods your class inherits, just call Ctrl+O in Android Studio.
3) An instance method cannot override a static method, and a static method cannot hide an instance method. For example, the following program has two compiler errors.
Why don't you just remove @Override
annotation above the method? Android 1.6 would ignore it, 2.0 would still interpret it correctly.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With