【发布时间】:2021-09-03 12:10:23
【问题描述】:
我需要调用此函数以通过可组合函数内的按钮点击显示插页式广告,该函数需要show() 方法的活动:
fun showInterstitial() {
if (mInterstitialAd != null) {
mInterstitialAd?.show(this)
} else {
Log.d("MainActivity", "The interstitial ad wasn't ready yet.")
}
}
如何获取当前活动并替换 this 部分?
感谢您的回答!
【问题讨论】:
-
“
the”部分?你的意思是“'this'部分”吗? -
val activity = LocalContext.current as AppCompatActivity
-
@MARSK 对不起,是的,
this。 -
好吧,我没看到 Gabirelle 的评论
-
@RawHasan 检查飞利浦的答案。就是这样。
标签: android kotlin android-jetpack-compose