我对原生广告有些问题。我得到了原生广告的empy列表。这是代码:
Appodeal.setAutoCacheNativeIcons(true)
Appodeal.setAutoCacheNativeMedia(false)
Appodeal.initialize(this, apiKey, Appodeal.NATIVE)
Appodeal.setNativeCallbacks(object : NativeCallbacks {
override fun onNativeLoaded() {
Toast.makeText(this@ViewActivity, "onNativeLoaded", Toast.LENGTH_SHORT).show()
}
override fun onNativeFailedToLoad() {
Toast.makeText(this@ViewActivity, "onNativeFailedToLoad", Toast.LENGTH_SHORT).show()
}
override fun onNativeShown(nativeAd: NativeAd) {
Toast.makeText(this@ViewActivity, "onNativeShown", Toast.LENGTH_SHORT).show()
}
override fun onNativeClicked(nativeAd: NativeAd) {
Toast.makeText(this@ViewActivity, "onNativeClicked", Toast.LENGTH_SHORT).show()
}
})
val list = Appodeal.getNativeAds(5)
nativeAd.getProviderView(this)
Toast.makeText(this@ViewActivity, "size = " + list.size , Toast.LENGTH_SHORT).show()
所以每次我得到list.size等于0.我做错了什么?
答案 0 :(得分:1)
在使用autocache
方法初始化sdk
之前禁用Appodeal.setAutoCache(Appodeal.NATIVE, false);
。
之后,需要在初始化Appodeal.cache(this, Appodeal.NATIVE, 5);
sdk
简单的例子:
Appodeal.setAutoCache(Appodeal.NATIVE, false);
Appodeal.initialize(this, tools.appodealApiKey, Appodeal.NATIVE)
Appodeal.cache(this, Appodeal.NATIVE, 5);
并将Appodeal.getNativeAds(5);
等移至onNativeLoaded()
回调。
显示缓存广告后,需要再次使用缓存方法