Admob add within multiple activities

2019-07-13 00:39发布

问题:

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



标签: android admob