September 8, 2020
Android Tutorials | How to add banner ads with Facebook Audience Network
Manifest: <uses-permission android:name=”android.permission.INTERNET” /> <uses-permission android:name=”android.permission.ACCESS_WIFI_STATE” /> <uses-permission android:name=”android.permission.ACCESS_NETWORK_STATE” /> build.gradle – dependency implementation ‘com.facebook.android:audience-network-sdk:5.11.0’ Layout <LinearLayout android:id="@+id/banner_container" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_alignParentBottom="true" android:orientation="vertical" app:layout_constraintBottom_toBottomOf="parent" /> Source Code import com.facebook.ads.AudienceNetworkAds; import com.facebook.ads.*; private NativeBannerAd nativeBannerAd; oncreate() AudienceNetworkAds.initialize(this); adView = new AdView(this, "415395656050XXX_649219926001XXX", AdSize.BANNER_HEIGHT_50); // Find the Ad Container LinearLayout adContainer = (LinearLayout) findViewById(R.id.banner_container); // Add the ad