Admob causing app to load, but not show
When admob is present in my app, the main layout (at times) will not display at all. Other times it starts just fine. I have had this intermittent issue for awhile now and cant figure out a way around it. Im sure it has something with the fetching of the ads (or the lack there of). When I enabled Google adsense in admob along with 'adult" ads, the app acted just fine and loaded those ads. If I remove ad mob from my application, the app starts up fine. It randomly will just show a blank screen and never loads any of the buttons and other times loads all buttons with the ads. Any ideas?
Here is my index activity:
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
AdView adView = (AdView)this.findViewById(R.id.adView1);
adView.loadAd(new AdRequest());
backCheck = 0;
}
main.xml is just 10 buttons and the ad.... nothing fancy. But it will just sit there and show a blank screen (it seems if it cant fetch an ad.)
The only information I have on logcat is...
06-02 19:45:10.923: INFO/Ads(264): To get test ads on this device, call adRequest.addTestDevice(AdRequest.TEST_EMULATOR);
06-02 19:45:11.053: WARN/Ads(264): loadAd called while the ad is already loading.
06-02 19:45:12.033: INFO/ARMAssembler(64): generated scanline__00000077:03010104_00000004_00000000 [ 22 ip开发者_如何学Cp] (41 ins) at [0x451220:0x4512c4] in 2310362 ns
06-02 19:45:12.323: INFO/ActivityManager(64): Displayed activity com.robores.elect/.Index: 3500 ms (total 3500 ms)
06-02 19:45:12.453: INFO/Ads(264): adRequestUrlHtml: <html><head><script src="http://www.gstatic.com/afma/sdk-core-v40.js"></script><script>AFMA_buildAdURL({"preqs":0,"u_sd":1.5,"slotname":"a14dd7f0258a8b7","u_w":320,"msid":"com.robores.elect","simulator":1,"cap":"m,a","js":"afma-sdk-a-v4.1.0","isu":"B3EEABB8EE11C2BE770B684D95219ECB","format":"320x50_mb","net":"ed","app_name":"1.android.com.robores.elect","hl":"en","u_h":533,"u_audio":4,"u_so":"p"});</script></head><body></body></html>
06-02 19:45:14.573: INFO/Ads(264): Received ad url: <"url": "http://r.admob.com:80/ad_source.php?preqs=0&u_sd=1.5&slotname=a14dd7f0258a8b7&u_w=320&msid=com.robores.elect&cap=m%2Ca&js=afma-sdk-a-v4.1.0&isu=B3EEABB8EE11C2BE770B684D95219ECB&format=320x50_mb&net=ed&app_name=1.android.com.robores.elect&hl=en&u_h=533&u_audio=4&u_so=p&output=html®ion=mobile_app&u_tz=0&ex=1&client_sdk=1", "afmaNotifyDt": "null">
06-02 19:45:16.573: WARN/webcore(264): Can't get the viewWidth after the first layout
06-02 19:45:16.693: DEBUG/dalvikvm(264): GC freed 3551 objects / 299672 bytes in 100ms
06-02 19:45:16.753: DEBUG/webviewglue(264): nativeDestroy view: 0x365538
06-02 19:45:16.763: ERROR/webcoreglue(264): The real object has been deleted
06-02 19:45:17.075: INFO/Ads(264): onReceiveAd()
AdView adView = (AdView)findById(R.id.adview1);
(new Thread() {
public void run() {
Looper.prepare();
adView.loadAd(new AdRequest());
}
}).start();
Put the above code in onCreate of Activity!!
Do loading of ad in separate thread not in main thread !!
精彩评论