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();
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…