This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Override | |
public void fetchAd() { | |
new AdLoader.Builder(this.getContext(), this.adUnitId) | |
.forAppInstallAd(AdMobNativeAd.this) | |
.forContentAd(AdMobNativeAd.this) | |
.withNativeAdOptions(this.getNativeAdOptionsBuilder().build()) | |
.withAdListener(new AdListener() { | |
@Override | |
public void onAdOpened() { | |
AdMobNativeAd.this.notifyAdClicked(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
this.setTitle(this.nativeAd.getAdTitle()); | |
this.setText(this.nativeAd.getAdBody()); | |
final NativeAd.Image coverImage = this.nativeAd.getAdCoverImage(); | |
if (coverImage != null) this.setMainImageUrl(coverImage.getUrl()); | |
final NativeAd.Image icon = this.nativeAd.getAdIcon(); | |
if (icon != null) this.setIconImageUrl(icon.getUrl()); | |
this.setCallToAction(this.nativeAd.getAdCallToAction()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Override | |
public void loadNativeAd(@NonNull final Context context, | |
@NonNull final CustomEventNative.CustomEventNativeListener customEventNativeListener, | |
@NonNull final Map<String, Object> localExtras, | |
@NonNull final Map<String, String> serverExtras) { | |
final String adUnitId = serverExtras.get(KEY_AD_UNIT_ID); | |
if (this.validateAdUnitId(adUnitId)) { | |
final FacebookNativeAd nativeAd = this.createNativeAd(context, customEventNativeListener, null, adUnitId); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
nativeAd.destroy(); | |
moPubNative.destroy(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Override | |
public void onNativeLoad(final NativeAd nativeAd) { | |
nativeAd.setMoPubNativeEventListener(this); | |
nativeAd.renderAdView(view); | |
nativeAd.prepare(view); | |
} | |
@Override | |
public void onNativeFail(final NativeErrorCode errorCode) { | |
Log.w(this.getClass().getSimpleName(), errorCode.toString()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
moPubNative.makeRequest(new RequestParameters.Builder() | |
.desiredAssets(EnumSet.of( | |
RequestParameters.NativeAdAsset.TITLE, | |
RequestParameters.NativeAdAsset.TEXT, | |
RequestParameters.NativeAdAsset.MAIN_IMAGE, | |
RequestParameters.NativeAdAsset.CALL_TO_ACTION_TEXT)) | |
.build()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
moPubNative = new MoPubNative(context, adUnitId, moPubNativeNetworkListener); | |
moPubNative.registerAdRenderer(new MoPubStaticNativeAdRenderer(new ViewBinder.Builder(R.layout.view_native_ad) | |
.titleId(R.id.ad_title) | |
.textId(R.id.ad_body) | |
.mainImageId(R.id.ad_image) | |
.callToActionId(R.id.ad_call_to_action) | |
.build())); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- MoPub --> | |
<activity | |
android:name="com.mopub.mobileads.MoPubActivity" | |
android:configChanges="keyboardHidden|orientation|screenSize" /> | |
<activity | |
android:name="com.mopub.common.MoPubBrowser" | |
android:configChanges="keyboardHidden|orientation|screenSize" /> | |
<!-- Facebook Audience Network --> | |
<activity |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<manifest | |
xmlns:android="http://schemas.android.com/apk/res/android" | |
package="org.github.ayltai.mopub.adapter.app"> | |
<!-- Required --> | |
<uses-permission android:name="android.permission.INTERNET" /> | |
<!-- Required by Facebook Audience Network and Flurry Ads --> | |
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
dependencies { | |
compile('com.mopub:mopub-sdk-native-static:4.12.0@aar') { transitive = true } | |
// Other dependencies | |
} |