Ad Mute
Ad Mute Event
NAM SDK supports to mute ad for banner, native simple types. The callback function for the Ad Mute event has been added.
- When calling a banner ad through GfpBannerAdView, transmit the callback through onAdMuted() defined in BannerAdListener.
- Kotlin
- Java
bannerAdView.setAdListner(object : BannerAdListener() {
/* onAdLoaded(), onAdClicked(), ... */
override fun onAdMuted(ad: GfpBannerAd) {
/* ... */
}
})
bannerAdView.setAdListener(new BannerAdListener() {
/* onAdLoaded(), onAdClicked(), ... */
@Override
public void onAdMuted(GfpBannerAd ad) {
/* ... */
}
});
- When calling banner and native ads through GfpAdLoader, transmit the callback through onAdMuted() defined in AdEventListener.
- Kotlin
- Java
val adLoader = GfpAdLoader.Builder(activity, adParam)
.withAdListener(object: AdEventListener() {
/* onAdClicked(), onAdImpression(), ... */
override fun onAdMuted() {
/* ... */
}
})
.withNativeSimpleAd(nativeSimpleAdOptions) { nativeSimpleAd ->
/* ... */
}
.build()
GfpAdLoader adLoader = new GfpAdLoader.Builder(activity, adParam)
.withAdListener(new AdEventListener() {
/* onAdClicked(), onAdImpression(), ... */
@Override
public void onAdMuted() {
/* ... */
}
})
.withNativeSimpleAd(nativeSimpleAdOptions, nativeSimpleAd -> {
/* ... */
})
.build();
Dark Theme
Dark mode/light mode settings are available for the Ad Mute icon.
There are three available types: SYSTEM
, which follows the system settings; LIGHT
, which is the light mode; and DARK
, which is the dark mode.
There are two themes for the settings: global setting using NdaProviderOptions
and individual setting using GfpNativeSimpleAdOptions
.
1. Global setting
- Set
NdaProviderOptions
throughSdkProperties
GfpSdk.setSdkProperties(GfpSdk.getSdkProperties().buildUpon()
.addProviderOptions(new NdaProviderOptions.Builder()
.setTheme(ResolvedTheme.SYSTEM).build())
.build());
- When using the global settings, the settings will be applied to all
S2S banner ads
andNativeSimple ads
for which no individual settings have been made. - Without a setup, the default is
LIGHT
.
2. Individual setting
- Set through the
GfpNativeSimpleAdoption
object that is transmitted when an ad request is made throughGfpAdLoader
.
- Kotlin
- Java
val nativeSimpleAdOptions = GfpNativeSimpleAdOptions.Builder()
.setTheme(ResolvedTheme.DARK)
.build()
val adLoader = GfpAdLoader.Builder(activity, adParam)
.withAdListener(object: AdEventListener {
/* onAdClicked(), onAdImpression(), ... */
override fun onAdMuted() {
/* ... */
}
})
.withNativeSimpleAd(nativeSimpleAdOptions) { nativeSimpleAd ->
/* ... */
}
.build()
GfpNativeSimpleAdOptions nativeSimpleAdOptions = new GfpNativeSimpleAdOptions.Builder()
.setTheme(ResolvedTheme.DARK)
.build();
GfpAdLoader adLoader = new GfpAdLoader.Builder(activity, adParam)
.withAdListener(new AdEventListener() {
/* onAdClicked(), onAdImpression(), ... */
@Override
public void onAdMuted() {
/* ... */
}
})
.withNativeSimpleAd(nativeSimpleAdOptions, nativeSimpleAd -> {
/* ... */
})
.build();
Individual settings take precedence over global settings. Therefore, and global and individual settings both exist, the individual settings will be applied.
3. LazyTheme
LazyTheme is supported from version 6.1.1.
If a theme has not been applied on a screen where theme settings, such as dark mode settings, dynamically change, try applying the LazyTheme below.
The example below is based on native ad standards.
- Kotlin
- Java
val nativeAdOptions = GfpNativeAdOptions.Builder()
.setHasMediaView(true)
.setTheme(LazyTheme {
when {
caseSystem -> ResolvedTheme.SYSTEM
caseDark -> ResolvedTheme.DARK
else -> ResolvedTheme.LIGHT
}
})
.build()
val adLoader = GfpAdLoader.Builder(requireActivity(), adParam)
.withNativeAd(nativeAdOptions) { nativeAd ->
inflateAd(nativeAd)
}
.build()
GfpNativeAdOptions nativeAdOptions = new GfpNativeAdOptions.Builder()
.setHasMediaView(true)
.setTheme(new LazyTheme(() -> {
if (caseSystem) {
return ResolvedTheme.SYSTEM;
} else if (caseDark) {
return ResolvedTheme.DARK;
} else {
return ResolvedTheme.LIGHT;
}
}))
.build();
GfpAdLoader adLoader = new GfpAdLoader.Builder(requireActivity(), adParam)
.withNativeAd(
nativeAdOptions,
nativeAd -> {
inflateAd(nativeAd);
})
.build()