Intercepting method calls Intercepting method calls android android

Intercepting method calls


Use Java's Proxy class. It creates dynamic implementations of interfaces and intercepts methods, all reflectively.

Here's a tutorial.


Have you considered aspect-oriented-programming and perhaps AspectJ ? See here and here for AspectJ/Android info.


Take a look at Spring AOP . You dont have to subclass your class by hand - but Spring will generate them behind the scenes and add code to do the interception.