Ads

Google Admob - Banner & Interstitial

Config Adsense

We use firebase remote config to set ad unit id, In this app you must replace this 3 ID with your own data, at file res/xml/remote_config_defaults.xml Data from this file use as default value, anytime you want to change you can change it from firebase remote console.

here how to get ad app id and unit id https://support.google.com/admob/answer/7356431?hl=en

remote_config_defaults.xml
<entry>
    <key>ad_app_id</key>
    <value>ca-app-pub-3239677920 . . .</value>
</entry>

<entry>
    <key>banner_ad_unit_id</key>
    <value>ca-app-pub-32396779206 . . .</value>
</entry>

<entry>
    <key>interstitial_ad_unit_id</key>
    <value>ca-app-pub-32396779206 . . .</value>
</entry>

Set Remote Config

Parameter value must add for remote config must be same with value from file res/xml/remote_config_defaults.xml we can see we have 3 parameter for admob need, so you must add it all to remote config. 1. ad_app_id 2. banner_ad_unit_id 3. interstitial_ad_unit_id Here tutorial how to add update remote config http://blog.dream-space.web.id/?p=220

Disable

new we make easy way to disable or enable adsense in the app, you only need to set boolean value with TRUE or FALSE

public class AppConfig {

    // flag for enable/disable all ads
	public static final boolean ADS_ENABLE = true;
	
    // flag for display ads (change true & false only )
	. . .
	public static final boolean ADS_MAIN_PAGE = AppConfig.ADS_ENABLE && true;
	public static final boolean ADS_PLAYLIST_DETAIL_PAGE = AppConfig.ADS_ENABLE && true;
	public static final boolean ADS_SEARCH_PAGE = AppConfig.ADS_ENABLE && true;
	
	. . .
}

Last updated