【问题标题】:Show interstitial Ad after download completed dialogue box pop up弹出下载完成后显示插页式广告对话框
【发布时间】:2018-05-16 06:26:50
【问题描述】:

当有人在 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();
}

谢谢

【问题讨论】:

  • 您是否注册并在单击确定按钮时发送广播??
  • 没有怎么办? @HemantParmar
  • 我把答案贴出来,看看。

标签: android webview admob interstitial


【解决方案1】:

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

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
    }
})

【讨论】:

  • 发布更多代码,我会帮助你。如果可能的话课程代码
【解决方案2】:

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

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

    }

现在在确定按钮广播接收器上

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

希望对你有帮助!!

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-11-15
    • 2021-12-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-11-25
    相关资源
    最近更新 更多