Preroll Ads – Android 2.4

Preroll ads are served before the content video. Use this ad format if the user is in the context of viewing content video, and you…

1. Import Libraries

Copy to Clipboard import com.vdopia.ads.lw.LVDOAdRequest; import com.vdopia.ads.lw.LVDOAdSize; import com.vdopia.ads.lw.LVDOConstants; import com.vdopia.ads.mp.MVDOAdRequest; import com.vdopia.ads.mp.PreRollVideoAd; import com.vdopia.ads.mp.PrerollAdListener;…

3. Initialize it.

Copy to Clipboard PreRollVideoAd preRollVideoAd = PreRollVideoAd.getInstance(this); Here, this = context…

6. Load it with an ad.

Copy to Clipboard LVDOAdSize adSize = new LVDOAdSize(300, 250); preRollVideoAd.loadAd(adRequest,apiKey, adSize, AdListActivity.this, isMainContentFullscreen); Where, adRequest = Request for targeting parameters apiKey = ID for your…

1. Import Libraries

Copy to Clipboard import com.vdopia.ads.lw.LVDOAdRequest; import com.vdopia.ads.lw.LVDOConstants; import com.vdopia.ads.mp.MVDOAdRequest; import com.vdopia.ads.mp.PreRollVideoAd; import com.vdopia.ads.mp.PrerollAdListener;…

3. Initialize it.

Copy to Clipboard PreRollVideoAd preRollVideoAd = PreRollVideoAd.getInstance(this); preRollVideoAd.setAdContext(this); //this is Activity Object…

4. Set the Main Content URL and Ad Request

Copy to Clipboard preRollVideoAd.setVideoPath(contentVideo); MVDOAdRequest adRequest = new MVDOAdRequest(YourActivity.this); preRollVideoAd.setAdRequest(adRequest);…

6. Add Ad to Layout

Copy to Clipboard ViewGroup parent = (ViewGroup) preRollVideoAd.getParent(); if (parent != null) { parent.removeAllViews(); } mAdLayout = (RelativeLayout) findViewById(R.id.adLayout); mAdLayout.addView(preRollVideoAd);…

Sample code

Copy to Clipboard Sample codes below are from Vdopia Sample App. The high level flow looks like below. AdListActivity → AdPartnersListActivity → MediaActivity AdListActivity -…

See below for code snippets in AdListActivity class.

Copy to Clipboard public class AdListActivity extends RequestPermissionActivity { private void initializePrerollAd() { Handler handler = new Handler(Looper.getMainLooper()); handler.post(new Runnable() { @Override public void run()…