[英]Android AdMob completely remove a InterstitialAd object
Iam正在为我的项目制作广告,我注意到这些广告占用了大量内存。 我想我只需要忍受这一点。 但我不想忍受的是,我似乎找不到完全删除广告对象以恢复记忆的方法。
我正在使用InterstialAds,这是我的主要活动:
public class Main extends Activity implements Constants, AdListener
{
private GameView mGameView;
private Activity mThis = this;
private AdListener mThisListener = this;
private InterstitialAd mFullScreenAd;
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
mGameView = new GameView(this, getAssets());
setContentView(mGameView);
}
public void showAd()
{
mFullScreenAd = new InterstitialAd(mThis, "asdasdasdasd");
// Create ad request
AdRequest adRequest = new AdRequest();
// Begin loading your interstitial
mFullScreenAd.loadAd(adRequest);
// Set Ad Listener to use the callbacks below
mFullScreenAd.setAdListener(mThisListener);
}
public void onDismissScreen(Ad ad)
{
mFullScreenAd.stopLoading();
mFullScreenAd = null;
}
public void onFailedToReceiveAd(Ad ad, ErrorCode errorCode) {
}
public void onLeaveApplication(Ad ad) {
}
public void onPresentScreen(Ad ad) {
}
public void onReceiveAd(Ad ad)
{
if (ad == mFullScreenAd)
mFullScreenAd.show();
}
}
所以我的问题是:如何完全删除mFullScreenAd对象并找回内存?
一旦调用了onDismissScreen()
方法,您就不再需要对插页式广告的引用,因此垃圾收集器应该能够在需要时取回该内存。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.