当我点击“后退箭头”图标时,如何显示非页内广告

问题描述

活动主代码中的箭头代码:

    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    getSupportActionBar().setTitle("App Name");
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);

我已经添加了其他代码现在,当我单击“箭头”时我需要显示非页内广告

解决方法

您正在寻找的代码段是

override fun onBackPressed() {
if (mInterstitialAd.isLoaded) {
mInterstitialAd.show()
} else {
<functionYouWanttoRun>}
}

如果您使用的是按钮,则要使用onClickListener

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...