I have android application with 2 modules.
First module contains Activity class defined like so:
MyActivity extends AppCompatActivity
Second module contains aspect class,
where I want to create @Pointcut
to MyActivity.onCreate
method.
It works if defined like so:
@Pointcut("execution(* *.onCreate(..))")
Just don't want ANY onCreate
call,
but MyActivity.onCreate
or AppCompatActivity.onCreate
.
Tried @Pointcut(execution(* MyActivity.onCreate(..)))
,
but it doesn't work.
So, how can I reference class from another module with @Pointcut
?
How extend
ed classes behave with aspects ?
For example creating @Pointcut
to AppCompatActivity
also works at MyActivity
, beacuse it is it's child ?
Thanks for any responses :)
In your pointcut definition, whenever using a class, the compiler needs to know which class you're refering to unambigously. To do so, you should use the canonical name of your class.
For instance, if your activity is in package com.company.project
, then your pointcut should be :
@Pointcut(execution(* com.company.project.MyActivity.onCreate(..)))