How to get admob in webview?

一世执手 提交于 2019-12-25 03:49:25

问题


I have a web page that I load via webView. Page has a div block to show an advertize and my task is get this div blok and insert code for adMob. Unfortunatly I doesn't found any docs that describes this approach or even says that it is possible.

If you know something that can help me I will be glad to hear it. Thanks.


回答1:


First advice: do not use webview unless you are forced to.

To display an as in an application, do not use the web one, but an AdView (https://developers.google.com/mobile-ads-sdk/download#downloadandroid)

  <com.google.ads.AdView android:id="@+id/adView"
                         android:layout_width="wrap_content"
                         android:layout_height="wrap_content"
                         ads:adUnitId="MY_AD_UNIT_ID"
                         ads:adSize="BANNER"
                         ads:testDevices="TEST_EMULATOR, TEST_DEVICE_ID"
                         ads:loadAdOnCreate="true"/>

Place your AdView below your Webview and voila!



来源:https://stackoverflow.com/questions/16151526/how-to-get-admob-in-webview

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!