Back to project page AspectJ-Android-Example.
The source code is released under:
Apache License
If you think the Android project AspectJ-Android-Example listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package android.mobile.peakgames.net.aspectjandroid.aspect; //from www . j a v a2s . c o m import android.util.Log; import android.widget.Button; import org.aspectj.lang.JoinPoint; import org.aspectj.lang.ProceedingJoinPoint; import org.aspectj.lang.annotation.*; @Aspect public class LoggingAspect { private static final String TAG = LoggingAspect.class.getName(); @Pointcut("execution(* android.view.View.OnClickListener.onClick(..))") public void onClickEntryPoint() { } @Before("onClickEntryPoint()") public void onClickBefore(JoinPoint joinPoint) { Log.d(TAG, "Before Advice ==> Clicked on : " + ((Button)joinPoint.getArgs()[0]).getText()); } @Around("onClickEntryPoint()") public void onClickAround(ProceedingJoinPoint joinPoint) { Log.d(TAG, "Around Advice ==> Clicked on : " + ((Button)joinPoint.getArgs()[0]).getText()); try { joinPoint.proceed(); } catch (Throwable throwable) { throwable.printStackTrace(); } } @After("onClickEntryPoint()") public void onClickAfter(JoinPoint joinPoint) { Log.d(TAG, "After Advice ==> Clicked on : " + ((Button)joinPoint.getArgs()[0]).getText()); } @AfterReturning(pointcut = "onClickEntryPoint()") public void onClickAfterReturning() { Log.d(TAG, "AfterReturning Advice ==>"); } }