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;
            }

        });
Était-ce utile?

La 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

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top