Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
125 views
in Technique[技术] by (71.8m points)

java - How can execute to alertDialog when rewardAds loaded?

I have alert dialog in onCreate. When open alert dialog if user click yes, that will open rewardAds. But, the rewardAds doesn't loaded and it doesn't work for this reason. I just tried to move code that open dialogAlert inside of onRewardedAdLoaded(). But it isn't that what I want. I want to use this alertDialog show after rewardAd loaded. How can do this?

@Override
protected void onCreate(Bundle savedInstanceState) {
  onRequestAd();
  if (ballAmount == 0){
   alertWatchVideoAds();
    }
 }

void onRequestAd()
{
    rewardedAd = new RewardedAd(this,MyConstants.rewardedBallAds);
    RewardedAdLoadCallback adLoadCallback =new RewardedAdLoadCallback(){
        @Override
        public void onRewardedAdLoaded()
        {
            super.onRewardedAdLoaded();
            Log.i("sadasd","On Rewarded Ad Loaded Successfully");
        }

        @Override
        public void onRewardedAdFailedToLoad(LoadAdError loadAdError)
        {
            super.onRewardedAdFailedToLoad(loadAdError);
            //onRequestAd();
            Log.i("sadasd","Rewarded Ad Load Failed");
        }
    };
    rewardedAd.loadAd(new AdRequest.Builder().build(), adLoadCallback);
 }
   private void alertWatchVideoAds(){
    AlertDialog.Builder builder = new AlertDialog.Builder(QuestionActivityWFourPic.this);
    builder.setTitle(R.string.text_title_ads_dialog);
    builder.setMessage(R.string.text_full_ads_dialog);

    //Yes Button
    builder.setPositiveButton(R.string.text_alert_ads_dialog_ok, new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            // buraya ?düllü reklam izleme kodlar? gelecek
            progressforAds.setVisibility(View.GONE);
            onShowRewardAd();
        }
    });

    //No Button
    builder.setNegativeButton(R.string.text_alert_ads_dialog_cancel, new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            progressforAds.setVisibility(View.GONE);
            dialog.dismiss();

        }
    });
    AlertDialog alertDialog = builder.create();
    alertDialog.show();
}

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...