سؤال

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

        });
هل كانت مفيدة؟

المحلول

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

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top