facebook native banner ads android example | how to integrate facebook ads in android apps 2021 | facebook ad integration android | facebook ads integration in android studio | facebook audience network android tutorial



facebook native banner ads android example
Facebook natuve ads are bigger sized ads than banner ads , you can insert banner ads in you android app by following this tutorial , also if you have any question you can ask in comments in youtube or here.

facebook native banner ads android youtube video

First insert below code in build.gradle (Module)

implementation 'com.facebook.android:audience-network-sdk:5.11.0'

Then use below code in layout file
<com.facebook.ads.NativeAdLayout
android:id="@+id/native_ad_container"
android:layout_width="match_parent"
android:layout_height="300dp"
android:orientation="vertical" />


Then Use below code in java directory after
"public class MainActivity extends AppCompatActivity {"

 loadNativeAd();
}
private void loadNativeAd() {
// Instantiate a NativeAd object.
// NOTE: the placement ID will eventually identify this as your App, you can ignore it for
// now, while you are testing and replace it later when you have signed up.
// While you are using this temporary code you will only get test ads and if you release
// your code like this to the Google Play your users will not receive ads (you will get a no fill error).
nativeAd = new NativeAd(this, "IMG_16_9_APP_INSTALL#YOUR_PLACEMENT_ID");

NativeAdListener nativeAdListener = new NativeAdListener() {

@Override
public void onMediaDownloaded(Ad ad) {

}

@Override
public void onError(Ad ad, AdError adError) {

}

@Override
public void onAdLoaded(Ad ad) {
// Race condition, load() called again before last ad was displayed
if (nativeAd == null || nativeAd != ad) {
return;
}
// Inflate Native Ad into Container
inflateAd(nativeAd);
}

@Override
public void onAdClicked(Ad ad) {

}

@Override
public void onLoggingImpression(Ad ad) {

}

};

// Request an ad
nativeAd.loadAd(
nativeAd.buildLoadAdConfig()
.withAdListener(nativeAdListener)
.build());
}

private void inflateAd(NativeAd nativeAd) {

nativeAd.unregisterView();

// Add the Ad view into the ad container.
nativeAdLayout = findViewById(R.id.native_ad_container);
LayoutInflater inflater = LayoutInflater.from(MainActivity2.this);
// Inflate the Ad view. The layout referenced should be the one you created in the last step.
adView = (LinearLayout) inflater.inflate(R.layout.native_ads_layout, nativeAdLayout, false);
nativeAdLayout.addView(adView);

// Add the AdOptionsView
LinearLayout adChoicesContainer = findViewById(R.id.ad_choices_container);
AdOptionsView adOptionsView = new AdOptionsView(MainActivity2.this, nativeAd, nativeAdLayout);
adChoicesContainer.removeAllViews();
adChoicesContainer.addView(adOptionsView, 0);

// Create native UI using the ad metadata.
MediaView nativeAdIcon = adView.findViewById(R.id.native_ad_icon);
TextView nativeAdTitle = adView.findViewById(R.id.native_ad_title);
MediaView nativeAdMedia = adView.findViewById(R.id.native_ad_media);
TextView nativeAdSocialContext = adView.findViewById(R.id.native_ad_social_context);
TextView nativeAdBody = adView.findViewById(R.id.native_ad_body);
TextView sponsoredLabel = adView.findViewById(R.id.native_ad_sponsored_label);
Button nativeAdCallToAction = adView.findViewById(R.id.native_ad_call_to_action);

// Set the Text.
nativeAdTitle.setText(nativeAd.getAdvertiserName());
nativeAdBody.setText(nativeAd.getAdBodyText());
nativeAdSocialContext.setText(nativeAd.getAdSocialContext());
nativeAdCallToAction.setVisibility(nativeAd.hasCallToAction() ? View.VISIBLE : View.INVISIBLE);
nativeAdCallToAction.setText(nativeAd.getAdCallToAction());
sponsoredLabel.setText(nativeAd.getSponsoredTranslation());

// Create a list of clickable views
List<View> clickableViews = new ArrayList<>();
clickableViews.add(nativeAdTitle);
clickableViews.add(nativeAdCallToAction);

// Register the Title and CTA button to listen for clicks.
nativeAd.registerViewForInteraction(
adView, nativeAdMedia, nativeAdIcon, clickableViews);




Then you need to create two classes , one in layout and other in java , you can download
files from below link and paste it in your project

https://drive.google.com/file/d/1au-ru_fPsLsIlK4C2sDkek9N2PLyQXHf/view?usp=sharing


YouTube video link

https://youtu.be/OjFf6O-pmOE


All Done Native ad will load 

If you want to earn more with your already published app you can contact me on facebook , 
i will help you to earn more with secret tricks ( Paid Work )

If you face some problem you can contact on Facebook page on comment on youtube video

https://www.facebook.com/Android-App-development-1790181861260693



Search terms

how to integrate facebook ads in android apps 2021

facebook banner ads example 

facebook ad integrate android 

facebook ads integration in android studio 

facebook audience network android tutorial

how to implement facebook native ads in android

facebook native banner ads android example

facebook audience network ads integration

facebook interstitial ads android example

facebook interstitial ads android github

Post a Comment

12 Comments

  1. Really an interesting and amazing post. Thanks for sharing this wonderful informative article here. I appreciate your hard work.
    Android Apps Development Islamabad

    ReplyDelete
  2. Thanks for sharing this amazing article.
    android app development .

    ReplyDelete
  3. Nice Article, Thank you for sharing a wonderful blog post

    Mobile App Development Company in Noida

    ReplyDelete
  4. Thank you Sharing this Valuble Facebook Native banner Ads Android Example.

    Visit for Free Android Studio Tutorials in Hindi

    ReplyDelete
  5. W2S Solutions is one of the best-in-class mobile app development companies texas, delivering feature-packed mobile apps that stand out from the crowd. We work seamlessly for our global clients by adapting the latest as well as traditional technologies to make your business requirements into a reality.

    ReplyDelete
  6. AppInfusion.co.uk is a leading technology blog platform that provides the latest news, blogs and articles on evolving technologies, the latest marketing trends, effective business strategies, web & mobile app development, digital marketing, and more to help businesses stay relevant in the fast-paced world.

    ReplyDelete
  7. Really I am very impressed with this post. Just awesome... I haven’t any word to appreciate this post.

    software developer Yorkshire

    ReplyDelete
  8. Amazing website.click here to make free android apps without coding.

    ReplyDelete
  9. Amazing.... blog shared. Alteza holds an upper hand in Telemedicine App Development. We make telemedicine applications that will give the advantage of consultation anytime and anywhere for your patients.

    ReplyDelete