我正在为我的项目制作广告,我注意到广告占用了大量内存。我想我只需要忍受它。但我不想忍受的是,我似乎无法找到完全删除广告对象以恢复记忆的方法。
我正在使用 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 对象并取回内存?