Button 当我点击后退箭头图标时如何显示间隙广告

Button 当我点击后退箭头图标时如何显示间隙广告,button,ads,show,interstitial,Button,Ads,Show,Interstitial,活动主目录中的箭头代码: Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); getSupportActionBar().setTitle("App Name"); getSupportActionBar().setDisplayHomeAsUpEnabled(true); 我已经添加了其他代码,现在我需要在单击箭头时显示I

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

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

我已经添加了其他代码,现在我需要在单击箭头时显示Interstitual

您要查找的代码是

override fun onBackPressed() {
if (mInterstitialAd.isLoaded) {
mInterstitialAd.show()
} else {
<functionYouWanttoRun>}
}
override fun onBackPressed(){
如果(Minterstitalad.已加载){
minterstitalad.show()
}否则{
}
}
如果您使用的是using按钮,则需要使用
onClickListener