0
내 게임에 배너 광고를 추가하려고합니다. 로드 할 때 광고를 표시 할 수 있지만 문제는 Adview 개체를 백그라운드에서로드하지 않는 상태로 만들 때입니다. 광고는 Adview 개체의 공개 설정이 보이지 않음으로 설정되어있을 때만로드되지만 내 게임의 경우 종료 화면에 광고를 표시해야합니다. 사전에공개 여부가 INVISIBLE로 설정된 경우 배너 광고가로드되지 않습니다.
감사
코드 : 모든
public void initAds()
{
rect_layout = (FrameLayout) findViewById(R.id.rectangleView);
banner_layout = (LinearLayout) findViewById(R.id.bannerView);
banner_ad = new AdView(_activity);
banner_ad.setAdUnitId(BANNER_AD_ID);
banner_ad.setAdSize(AdSize.SMART_BANNER);
AdRequest adRequestBanner = new AdRequest.Builder().build();
banner_ad.loadAd(adRequestBanner);
banner_layout.addView(banner_ad);
rect_ad = new AdView(_activity);
rect_ad.setAdUnitId(RECTANGLE_AD_ID);
rect_ad.setAdSize(AdSize.MEDIUM_RECTANGLE);
AdRequest adRequestRectangle = new AdRequest.Builder().build();
rect_ad.loadAd(adRequestRectangle);
rect_layout.addView(rect_ad);
rect_ad.setAdListener(new AdListener() {
@Override
public void onAdClosed() {
super.onAdClosed();
}
@Override
public void onAdFailedToLoad(int errorCode) {
super.onAdFailedToLoad(errorCode);
}
@Override
public void onAdLeftApplication() {
super.onAdLeftApplication();
}
@Override
public void onAdOpened() {
super.onAdOpened();
}
@Override
public void onAdLoaded() {
super.onAdLoaded();
//rect_layout.setVisibility(View.INVISIBLE);
}
});
//rect_layout.setAlpha(0);
}
//Rectangular ad
public static void showRectangularAd(final String _show)
{
_activity.runOnUiThread(new Runnable() {
@Override
public void run() {
if(Boolean.parseBoolean(_show))
{
_activity.rect_layout.setVisibility(View.VISIBLE);
//_activity.rect_layout.setAlpha(1);
Log.d(TAG, "Set to visible");
}
else
{
_activity.rect_layout.setVisibility(View.INVISIBLE);
//_activity.rect_layout.setAlpha(0);
Log.d(TAG, "Set to invisible");
}
}
});
}
괜찮음 답을 보내 주셔서 감사합니다. 문제가 해결되었습니다. –
어떻게 해결 했습니까? 질문에 대한 답변을 공유하고 답변으로 표시하십시오. @JaiSharma – HourGlass