Android Admob减慢了我的应用程序
我正在使用帧动画,我在活动中执行横幅和间隙广告,但当我这样做时,它会减慢我的应用程序 这是我的密码: 私人间质Android Admob减慢了我的应用程序,android,eclipse,admob,Android,Eclipse,Admob,我正在使用帧动画,我在活动中执行横幅和间隙广告,但当我这样做时,它会减慢我的应用程序 这是我的密码: 私人间质 interstitial = new InterstitialAd(MainActivity.this); // Insert the Ad Unit ID interstitial.setAdUnitId("UNIT ID"); //Locate the Banner Ad in activity_main.xml AdView adView = (AdView) this.fin
interstitial = new InterstitialAd(MainActivity.this);
// Insert the Ad Unit ID
interstitial.setAdUnitId("UNIT ID");
//Locate the Banner Ad in activity_main.xml
AdView adView = (AdView) this.findViewById(R.id.adView);
// Request for Ads
AdRequest adRequest = new AdRequest.Builder()
// Add a test device to show Test Ads
.addTestDevice(AdRequest.DEVICE_ID_EMULATOR)
.addTestDevice("CC5F2C72DF2B356BBF0DA198")
.build();
// Load ads into Banner Ads
adView.loadAd(adRequest);
// Load ads into Interstitial Ads
interstitial.loadAd(adRequest);
// Prepare an Interstitial Ad Listener
interstitial.setAdListener(new AdListener() {
public void onAdLoaded() {
// Call displayInterstitial() function
displayInterstitial();
}
});
}
关于如何在我的课堂上有效地整合admob的任何解决方案。请回答您的评论 我是否可以将所有admob代码放在其他类中,并在我的 主要活动 是,例如:AdMob.java类: 通过执行以下操作,您可以在任何地方使用它:
AdMob adMob = new AdMob();
adMob.LoadInterstitialAd(getApplicationContext());
我只展示了间隙广告,但也可以为其他广告展示。您也可以使用线程加载请求。一旦从runonuithread方法加载了call display interstitual方法,这个主题已经很老了,但您可能会在admob逻辑中找到一些有用的要点。我还担心一些建议的解决方案在Android 4+设备上可能无法正常工作。
AdMob adMob = new AdMob();
adMob.LoadInterstitialAd(getApplicationContext());