How can I understand if a user clicked on an admob ad? the ontouch listener did not work.
Display display = ((WindowManager) this.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay(); int width = display.getWidth(); int height = display.getHeight(); Window window = getWindow(); adsLayout = new RelativeLayout(this); RelativeLayout.LayoutParams lp2 = new RelativeLayout.LayoutParams(//width,height); RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.FILL_PARENT); adsLayout.setGravity(Gravity.BOTTOM); adView = new AdView(this, AdSize.BANNER, "XXX"); com.google.ads.AdRequest adRequest1 = new com.google.ads.AdRequest(); adRequest1.addTestDevice(com.google.ads.AdRequest.TEST_EMULATOR); // Emulator int adwidth = height; adView.setPadding((width - adwidth) / 2, 0, 0, 0); adView.loadAd(adRequest1); adsLayout.addView(adView); adView.setOnTouchListener( (android.view.View.OnTouchListener) mOnTouchListener ); window.addContentView(adsLayout,lp2);
The second question: how to manage ads if they are at the top of the button or something related? Android runs on many phones and cannot test everything .. just read what is forbidden.
source share