gpt4 book ai didi

java - 无法加载admob广告错误:3 ERROR_CODE_NO_FILL

转载 作者:行者123 更新时间:2023-12-02 04:53:05 25 4
gpt4 key购买 nike

我收到“无法加载广告”错误:3。

我已经尝试过请求欧洲用户的同意。但是它不起作用,我已经等了 7 天了。

class MainActivity{
lateinit var mAdView: AdView
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)

getUserConsent()
}

@SuppressLint("HardwareIds")
private fun getUserConsent() {
try {
if (!isConsentYet) {
val msg = "Your privacy policy"

@SuppressLint("InflateParams")
val view = LayoutInflater.from(this@MainActivity)
.inflate(R.layout.dialog_consent, null, false)

val d = AlertDialog.Builder(this)
.setView(view)
.setCancelable(false)
.setTitle("User Consent")
.setIcon(R.mipmap.ic_launcher)
.create()
view.txtAlertMsg.text = Html.fromHtml(msg)
view.btnAccept.setOnClickListener {

ConsentInformation.getInstance(this@MainActivity).addTestDevice(
Settings.Secure.getString(
contentResolver,
Settings.Secure.ANDROID_ID
)
)

ConsentInformation.getInstance(this@MainActivity).consentStatus =
if (view.chkGDPR.isChecked)
ConsentStatus.PERSONALIZED else ConsentStatus.NON_PERSONALIZED
isConsentYet = true
d.dismiss()
loadAds()
}
d.show()
setTextViewHTML(view.txtAlertMsg, msg)
} else {
loadAds()
}
} catch (e: Exception) {
e.printStackTrace()
}

}

protected fun setTextViewHTML(text: TextView, html: String) {
val sequence = Html.fromHtml(html)
val strBuilder = SpannableStringBuilder(sequence)
val urls = strBuilder.getSpans(0, sequence.length,
URLSpan::class.java)
for (span in urls) {
makeLinkClickable(strBuilder, span)
}
text.text = strBuilder
text.movementMethod = LinkMovementMethod.getInstance()
}

protected fun makeLinkClickable(strBuilder:
SpannableStringBuilder, span: URLSpan) {
val start = strBuilder.getSpanStart(span)
val end = strBuilder.getSpanEnd(span)
val flags = strBuilder.getSpanFlags(span)
val clickable = object : ClickableSpan() {
override fun onClick(view: View) {
val i = Intent(Intent.ACTION_VIEW)
i.data = Uri.parse("Privacy URL")
startActivity(i)
}
}
strBuilder.setSpan(clickable, start, end, flags)
strBuilder.removeSpan(span)
}

private fun loadAds() {
mAdView = findViewById(R.id.adView)
MobileAds.initialize(this, getString(R.string.app_id))
val adRequest = AdRequest.Builder().build()
val adView = AdView(this)
adView.adSize = AdSize.BANNER
adView.adUnitId = getString(R.string.ad_bottom)
mAdView.loadAd(adRequest)

mAdView.adListener = object : AdListener() {
override fun onAdLoaded() {
// Code to be executed when an ad finishes loading.
Log.w("AdListener", "onAdLoaded")
}

override fun onAdFailedToLoad(errorCode: Int) {
// Code to be executed when an ad request fails.
Log.w("AdListener",
"onAdFailedToLoad".plus(errorCode))
}

override fun onAdOpened() {
// Code to be executed when an ad opens an overlay
that
// covers the screen.
Log.w("AdListener", "onAdOpened")
}

override fun onAdClicked() {
// Code to be executed when the user clicks on an ad.
Log.w("AdListener", "onAdClicked")
}

override fun onAdLeftApplication() {
// Code to be executed when the user has left the app.
Log.w("AdListener", "onAdLeftApplication")
}

override fun onAdClosed() {
// Code to be executed when the user is about to
return
// to the app after tapping on an ad.
Log.w("AdListener", "onAdClosed")
}
}
}

总是,几天后我就会收到 ERROR_CODE_NO_FILL。

最佳答案

谷歌解释

ERROR_CODE_NO_FILL The ad request was successful, but no ad was returned due to lack of ad inventory.

但是如果您能够看到测试广告,则您的代码没有问题。也许谷歌支持可以帮助你,他们会要求你的 AdsUnitId 和 appId 进行测试并回答你的真正问题。 Here

关于java - 无法加载admob广告错误:3 ERROR_CODE_NO_FILL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56423585/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com