Admob add within multiple activities

三世轮回 提交于 2019-12-24 02:23:34

问题


I am trying to add Admob in my android application which consists of over 15 activities. My question is which solution is the best one, considering that I can't extend any "BaseActivity" (for various reasons), as presented in this example: Admob on Multiple Activities? and I don't want to violate any agreements regarding rules making adds requests and their use.

So far i've created a file admob.xml containing the com.admob.android.ads.AdView and I use "include layout" in each layout ".xml" file loaded in every activity.

Is this OK? Will I have any problems with Google policies or something like that? Or will this implementation cause me losing potential revenue?


回答1:


That is a reasonable solution and complies with AdMob policies. Just make sure you don't have two banners on the same page.




回答2:


The Best way is to switch to fragments, Your main application will be in the main fragment, and your ad in the Ad Fragment. This way you can switch your previus activities with fragments, and you will need to initialize the ad Fragment only once, also this will prevent new ad request when you create a new activity (which can lower your admob RPM).

Eli



来源:https://stackoverflow.com/questions/11955123/admob-add-within-multiple-activities

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