@Before("execution(* android.app.Activity.onPause(..))")
public void postOnPause(JoinPoint thisJoinPoint) {
Activity activity = (Activity) thisJoinPoint.getTarget();
Log.d("TEST", "YAY Activity paused");
}
This works out great if I in my MainActivity override:
@Override
protected void onPause() {
super.onPause();
}
Is there any way I could solve this without adding the override? Because the superclass Activity should still have that method defined and should be run even tho the subclass has not implemented it.
Is this possible?
Disclaimer: I am not an Android developer, my answer will explain basic AspectJ mechanisms.
As Aaron He already said when pointing you to my other answer, you either need to instrument the upstream JAR containing the base class during runtime via LTW (load-time weaving) or weave it during compile time via binary weaving.
If it was your own code calling onPause
, you could just use a call()
pointcut instead of execution()
, but probably the framework issues the calls, making this option a bad choice.