我有一个带有“主菜单”活动的应用程序。从那里用户可以转到Activity1或Activity2。在Activity1中,在AdMob广告中加载了programmaticaly,在Activity2中,它们是从xml文件自动加载的。问题是,点击广告并在我单击后退按钮后将其加载到Activity1中后,我将返回主菜单而不是Activity1。在Activity2中返回工作就像它应该的那样。这是为什么?活动1中与广告相关的代码:
public class Activity1 extends Activity implements OnClickListener, AdListener{
AdView ads;
public void onReceiveAd(Ad ad) {}
public void onFailedToReceiveAd(Ad ad, AdRequest.ErrorCode error){}
public void onPresentScreen(Ad ad){}
public void onDismissScreen(Ad ad){}
public void onLeaveApplication(Ad ad){}
...
@Override
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
ads.setAdListener(this);
ads.loadAd(new AdRequest());
}
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
...
ads = (AdView) findViewById(R.id.adView);
ads.setAdListener(this);
ads.loadAd(new AdRequest());
}
}