Home slows open another activity
Reply: 2

slows open another activity

mr.ahe3s
1#
mr.ahe3s Published in 2018-02-14 10:15:17Z

I have android application where i implemented AdMob ads after add AdMob code the activity take more time to open "slow" and after deleting AdMob code open do not be late.

MainActivity.java

  MobileAds.initialize(this, "ca-app-pub-669801637538109/5904052485");
        madView = (AdView) findViewById(R.id.adView);
        AdRequest adRequest = new AdRequest.Builder().build();
        madView.loadAd(adRequest);

activity_main.xml

 <com.google.android.gms.ads.AdView
        xmlns:ads="http://schemas.android.com/apk/res-auto"
        android:id="@+id/adView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_centerHorizontal="true"
        ads:adSize="SMART_BANNER"
        ads:adUnitId="ca-app-pub-669801637538109/5904052485" />
Praveen Thirumurugan
2#
Praveen Thirumurugan Reply to 2018-02-14 10:20:05Z

It is because of the network latency time. If the network data is reliable and fast, it will load sooner. I would suggest to initiate the ad loading in a background thread using AsyncTask to make the application loading fast.

Gautam Kushwaha
3#
Gautam Kushwaha Reply to 2018-02-14 11:34:31Z

We can not loadAd under background thread . I would suggest to call loadAd method under handler with postDelayed.

 Handler handler = new Handler();
    handler.postDelayed(new Runnable(){
    @Override
      public void run(){
        if(madView!=null)
        madView.loadAd(adRequest);
   }
}, 500);
You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.782241 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO