Is there any way in android to intercept activity method calls (just the standart ones, like “onStart. onCreate”)?
I have a lot of functionality that must be present in every activity in my app, and (since it uses different types of activities (List, Preferences)) the only way to do it is to create my custom extensions for every activity class, which sucks 🙁
P.S. I use roboguice, but since Dalvik doesn’t support code generation at runtime, I guess it doesn’t help much.
P.S.S. I thought about using AspectJ, but it’s too much of a hassle since it requires a lot of complications (ant’s build.xml and all that junk)
You could delegate all the repetitive work to another class that would be embedded in your other activities. This way you limit the repetitive work to creating this object and calling its onCreate, onDestroy methods.
This minimalises the hassle and factorises all common methods and members of your activities. The other way to do it is to subclasse all the API’s XXXActivty classes 🙁