Search code examples
androidwebviewadmobinterstitial

Show interstitial Ad after download completed dialogue box pop up


i want to show interstitial ad when someone download my app's image in webView , now when user download the image pop up shows that image downloaded completely with ok , i want to show interstitial Ad when user click on that ok button , this is my pop up code

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

thanks


Solution

  • First implement the positive button click listener like this and then you can write your code for ad in that listener

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