source/android-library/app/src/main/java/com/google/unity/ads/NativeExpressAd.java
/**
     * Creates a {@link NativeExpressAdView} to hold native express ads.
     *
     * @param publisherId  Your ad unit ID.
     * @param adSize       The size of the native express ad.
     * @param positionCode A code indicating where to place the ad.
     */
Creates a  NativeExpressAdView to hold native express ads.
@param publisherId  Your ad unit ID.
@param adSize       The size of the native express ad.
@param positionCode A code indicating where to place the ad.
Creates a NativeExpressAdView to hold native express ads . @param publisherId Your ad unit ID . @param adSize The size of the native express ad . @param positionCode A code indicating where to place the ad .
public void create(final String publisherId, final AdSize adSize, final int positionCode) {
        mUnityPlayerActivity.runOnUiThread(new Runnable() {
            @Override
            public void run() {
                mAdView = new NativeExpressAdView(mUnityPlayerActivity);
                mAdView.setBackgroundColor(Color.TRANSPARENT);
                mAdView.setAdUnitId(publisherId);
                mAdView.setAdSize(adSize);
                mAdView.setAdListener(new AdListener() {
                    @Override
                    public void onAdLoaded() {
                        if (mUnityListener != null) {
                            mUnityListener.onAdLoaded();
                        }
                    }
                    @Override
                    public void onAdFailedToLoad(int errorCode) {
                        if (mUnityListener != null) {
                            mUnityListener.onAdFailedToLoad(PluginUtils.getErrorReason(errorCode));
                        }
                    }
                    @Override
                    public void onAdOpened() {
                        if (mUnityListener != null) {
                            mUnityListener.onAdOpened();
                        }
                    }
                    @Override
                    public void onAdClosed() {
                        if (mUnityListener != null) {
                            mUnityListener.onAdClosed();
                        }
                    }
                    @Override
                    public void onAdLeftApplication() {
                        if (mUnityListener != null) {
                            mUnityListener.onAdLeftApplication();
                        }
                    }
                });
                FrameLayout.LayoutParams adParams = new FrameLayout.LayoutParams(
                        FrameLayout.LayoutParams.WRAP_CONTENT, FrameLayout.LayoutParams
                        .WRAP_CONTENT);
                adParams.gravity = PluginUtils.getLayoutGravityForPositionCode(positionCode);
                mUnityPlayerActivity.addContentView(mAdView, adParams);
            }
        });
    }
public void create ( final String publisherId , final AdSize adSize , final int positionCode ) { mUnityPlayerActivity . runOnUiThread ( new Runnable ( ) { @ Override public void run ( ) { mAdView = new NativeExpressAdView ( mUnityPlayerActivity ) ; mAdView . setBackgroundColor ( Color . TRANSPARENT ) ; mAdView . setAdUnitId ( publisherId ) ; mAdView . setAdSize ( adSize ) ; mAdView . setAdListener ( new AdListener ( ) { @ Override public void onAdLoaded ( ) { if ( mUnityListener != null ) { mUnityListener . onAdLoaded ( ) ; } } @ Override public void onAdFailedToLoad ( int errorCode ) { if ( mUnityListener != null ) { mUnityListener . onAdFailedToLoad ( PluginUtils . getErrorReason ( errorCode ) ) ; } } @ Override public void onAdOpened ( ) { if ( mUnityListener != null ) { mUnityListener . onAdOpened ( ) ; } } @ Override public void onAdClosed ( ) { if ( mUnityListener != null ) { mUnityListener . onAdClosed ( ) ; } } @ Override public void onAdLeftApplication ( ) { if ( mUnityListener != null ) { mUnityListener . onAdLeftApplication ( ) ; } } } ) ; FrameLayout . LayoutParams adParams = new FrameLayout . LayoutParams ( FrameLayout . LayoutParams . WRAP_CONTENT , FrameLayout . LayoutParams . WRAP_CONTENT ) ; adParams . gravity = PluginUtils . getLayoutGravityForPositionCode ( positionCode ) ; mUnityPlayerActivity . addContentView ( mAdView , adParams ) ; } } ) ; }
Creates a {@link NativeExpressAdView} to hold native express ads.
Creates a { @link NativeExpressAdView } to hold native express ads .
// Setting the background color works around an issue where the first ad isn't // visible.