Question

I want to know how many user click the ads on my application.Because of this I want to write code to understand touching ads.

CODE :

 final View touchView = findViewById(R.id.advertisement);
        touchView.setOnTouchListener(new View.OnTouchListener() {

            @Override
            public boolean onTouch(View v, MotionEvent event) {
                 counter++;

                return false;
            }

        });
Was it helpful?

Solution

You needn't do complicated things to intercept the click events with admob for android. There is an event in AdListener which is intended exactly to intercept the click events: onPresentScreen(Ad ad). I'm actually using it in my app to record click statistics in a database. It works.

More information: com.google.ads.AdListener

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top