0

I've been playing a while with the latest release of Facebook's SDK for Android. In particular, I've been trying out the Native Ad API. My problem is I want to be able to preload several ads (lets say 3 or 5 or 10, doesn't matter), so they appear the instant they appear on screen. I've managed to do this but I've got stuck with the images. Apparently, the images (icon and coverImage) can only be obtain via the NativeAd.downloadAndDisplayImage which requires the imageView where the images will be displayed.

Is there anyone having this same kind of issue? Anyone who has played/worked with the Native Ad API in Android and can give me some insight?

It's kinda difficult since I can't look into the source code of the AudienceNetwork library yet, plus there's no javadoc. I've tried googling around but with no success.

Igy
  • 43,710
  • 8
  • 89
  • 115
acrespo
  • 1,134
  • 1
  • 10
  • 33
  • I would like to prefetch or preload the images because I want the ad to be displayed right away when it comes into the screen, and not have to wait x seconds/milliseconds until the image is available. – acrespo Jun 09 '14 at 13:44

1 Answers1

2

NativeAd.downloadAndDisplayImage is just a helper to make download and display images easier. You can get url and dimension of the ad icon/image from NativeAd.getAdIcon() and NativeAd.getAdCoverImage(). Then you can do prefetching using the urls.

If you download the latest Facebook SDK for Android, Audience Network javadoc is available under AudienceNetwork/docs.

Song Qian
  • 611
  • 1
  • 5
  • 9
  • Thanks! I ended up doing exactly that. I told myself to answer this question myself but somehow I forgot to do it along the way. Great job! – acrespo Aug 06 '14 at 17:15
  • It is not possible until you are ussing MediaView, because you must put NativeAd as parameter and you have no control over pre-fetching. – ATom Jul 17 '15 at 10:26
  • 2
    Check out the new NativeAdsManager class introduced in v4.1. You can specify what level of media caching you want on your NativeAd objects. `NativeAdsManager manager = new NativeAdsManager(this, "YOUR_PLACEMENT_ID", 5); manager.loadAds(NativeAd.MediaCacheFlag.ALL);` – Song Qian Jul 18 '15 at 21:38