(android) How I understand touch the advertisement in code?
-
04-12-2019 - |
Pergunta
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;
}
});
Solução
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
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow