This repository has been archived by the owner on Feb 26, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Android Backward Compatibility
pyricau edited this page Jan 14, 2012
·
4 revisions
Since AndroidAnnotations 1.0
Since Android 2.0, activities can implement onBackPressed()
to modify the default behavior when the user presses the back key.
There was an article on the Android blog that showed how to reproduce this for pre 2.0 Android versions.
We automatically support that since AndroidAnnotations
2.1 (with issue 46): if an @EActivity
annotated class has an onBackPressed()
method, the generated class adds the needed code for support on pre 2.0 Android versions.
For instance:
@EActivity
public class MyActivity extends Activity {
public void onBackPressed() {
// Do something
}
}
Generates:
public final class MyActivity_ extends MyActivity
{
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if (((SdkVersionHelper.getSdkInt()< 5)&&(keyCode == KeyEvent.KEYCODE_BACK))&&(event.getRepeatCount() == 0)) {
onBackPressed();
}
return super.onKeyDown(keyCode, event);
}
}
19/11/2020 The 4.8.0 release is out !
- Get started!
- Cookbook, full of recipes
- Customize annotation processing
- List of all available annotations
- Release Notes
- Examples
- Read the FAQ
- Join the Mailing list
- Create an issue
- Tag on Stack Overflow
- Ask on Gitter