I have tried integrating interstitial ads according to these docs given on their website. But ads are not loading up.
This is my code,
import android.content.Intent
import android.content.pm.PackageManager
import android.os.AsyncTask
import android.os.Build
import android.os.Bundle
import android.preference.PreferenceManager
import android.util.Log
import android.view.View
import android.widget.Button
import androidx.annotation.NonNull
import androidx.appcompat.app.AppCompatActivity
import com.smaato.sdk.core.Config
import com.smaato.sdk.core.SmaatoSdk
import com.smaato.sdk.core.log.LogLevel
import com.smaato.sdk.interstitial.EventListener
import com.smaato.sdk.interstitial.Interstitial
import com.smaato.sdk.interstitial.InterstitialAd
import com.smaato.sdk.interstitial.InterstitialError
import com.smaato.sdk.interstitial.InterstitialRequestError
import kotlinx.android.synthetic.main.activity_download_page.*
class DownloadPageActivity : AppCompatActivity() {
private val TAG = "DownloadPageActivity"
lateinit var bannerView: BannerView
lateinit var newspaperList: NewspaperList
lateinit var tagOfCardClicked: String
lateinit var pdfLinks: MutableList<String>
lateinit var dates: MutableList<String>
lateinit var date: Date
var tagOfButtonClicked: Int = 0
var result: String = ""
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
/*val config: Config = Config.builder() // log errors only
.setLogLevel(LogLevel.ERROR) // allow HTTPS traffic only
.setHttpsOnly(true)
.build()
SmaatoSdk.init(application, config, "1100046327")
SmaatoSdk.setGPSEnabled(true)*/
setContentView(R.layout.activity_download_page)
newspaperList = NewspaperList()
pdfLinks = mutableListOf()
dates = mutableListOf()
val bundle = intent.extras
tagOfCardClicked = bundle!!.getString("card_clicked")!!
title_text_downloadpage.text = newspaperList.getNewspaper(tagOfCardClicked.toInt()).title
}
fun buttonClicked(view: View) {
tagOfButtonClicked = Integer.parseInt(view.tag.toString())
println("Button clicked + ${view.resources.getResourceName(view.id)}")
Interstitial.loadAd("130626426", eventListener)
}
val eventListener = object : EventListener {
override fun onAdImpression(p0: InterstitialAd) {
Log.i(TAG, "onAdImpression-> $p0 ")
}
override fun onAdTTLExpired(p0: InterstitialAd) {
Log.i(TAG, "onAdTTLExpired-> $p0 ")
}
override fun onAdClicked(p0: InterstitialAd) {
Log.i(TAG, "onAdClicked-> $p0 ")
}
override fun onAdFailedToLoad(p0: InterstitialRequestError) {
Log.i(TAG, "onAdFailedToLoad -> $p0")
}
override fun onAdLoaded(@NonNull interstitialAd: InterstitialAd) {
Log.i(TAG, "Interstitial ad loaded")
interstitialAd.setBackgroundColor(-0xedcbaa)
interstitialAd.showAd(DownloadPageActivity())
}
override fun onAdOpened(p0: InterstitialAd) {
Log.i(TAG, "onAdOpened-> $p0 ")
}
override fun onAdClosed(p0: InterstitialAd) {
val intent = Intent(applicationContext, WebViewActivity::class.java)
intent.putExtra("pdf_link", pdfLinks[tagOfButtonClicked - 1])
Log.i(TAG, "onAdClosed-> $p0 ")
startActivity(intent)
}
override fun onAdError(p0: InterstitialAd, p1: InterstitialError) {
Log.i(TAG, "onAdError-> $p0 ")
}
}
}
This is the log report I am getting,
I/DownloadPageActivity: onAdFailedToLoad -> com.smaato.sdk.interstitial.InterstitialRequestError@d7e0f16
I am using test ID to load the ads. I have tried to load ads on emulator as well as a real device but no progress. I cant find any articles, tutorials, blogs, anything related to this error.
Kindly check the error code in onAdFailedToLoad:
what error message you are getting in onAdFailedToLoad?
interstitialRequestError : [NO_AD_AVAILABLE]: No ad is currently available matching the requested parameters. Please try again later.
Above error message is showing fillrate is 0 now, but implementation don't has any issue. Ads could be load later at some point.
Note: Ads Fill Rate depends on users traffic in case of some ads service providers.
Or
What you can do check your implementation by testing units
Change Publisher ID with test publisher Id
Ads unit with test ads Id
public class SmaatoConfig {
}
I hope it will help you. Don't forget to respond on solution if it works for you just add your comment and vote it. So it will be helpfull for others also.
:) all the BEST !