下载完成对话框弹出后显示插页式广告

Show interstitial Ad after download completed dialogue box pop up

我想在有人在 webView 中下载我的应用程序图片时显示插页式广告,现在当用户下载图片时弹出窗口显示该图片已完全下载并成功,我想在用户单击该确定按钮时显示插页式广告,这是我的弹出代码

registerReceiver(downloadListener, new IntentFilter(DownloadManager.ACTION_DOWNLOAD_COMPLETE));

BroadcastReceiver downloadListener = new BroadcastReceiver(){
public void onReceive(Context ct, Intent intent){
    new MaterialDialog.Builder(this)
          .title("Download Completed")
          .content("Download Successfully Completed")
          .positiveText("OK")
          .show();
}

谢谢

在需要回调的地方注册本地广播接收器,看看

 @Override
    protected void onResume() {
        super.onResume();
          LocalBroadcastManager.getInstance(this).registerReceiver(downloadListener, new IntentFilter(DownloadManager.ACTION_DOWNLOAD_COMPLETE));

    }

现在在 ok 按钮广播接收器上

 Intent intent = new Intent();
 intent.setAction(DownloadManager.ACTION_DOWNLOAD_COMPLETE);
 LocalBroadcastManager.getInstance(context).sendBroadcast(intent);

希望对您有所帮助!!

首先像这样实现正面按钮点击监听器,然后您可以在该监听器中编写广告代码

new MaterialDialog.Builder(this)
.onPositive(new MaterialDialog.SingleButtonCallback() {
    @Override
    public void onClick(MaterialDialog dialog, DialogAction which) {
        // here you can write the code for showing ads
    }
})