Web Learners, This blog is gonna give you huge knowledge about Mobile App Development, Game development, Internet Marketing, Social Network Marketing, Search Engine Optimization (SEO) ,Mobile Marketing, and website and web application Code knowledge such as HTML, CSS, JavaScript etc. This site is also gonna give you free tools and software with installation guides. Most important Tips and tricks about marketing, software installation and Coding is always available.
Hi, Today I am going to show you How to integrate Facebook Native Banner Ads in Android App. In the last post, I have shown you how to integrate Facebook Banner Ads in Android App. Let's start.
First, add the below dependency in build.gradle(Module: App) for importing Facebook ads SDK.
Code:
And then move to the activity_main.xml file, then paste the below layout code.
Code:
It will show your ad bottom of the screen if you want to show your ad Top of the screen you need to write android:layout_alignParentBottom="true". Then you have to create a new layout for your Native Banner Ad, named it native_banner_ad_layout.xml
Then paste the below code in native_banner_ad_layout.xml file.
Code:
So the final full code will be in activity_main.xml file is as follows:
Code:
Now move to the MainActivity.java file, first import the Facebook ads SDK write the following code.
Code:
Then paste the below code above Oncreate.
Code:
Now initialize the Facebook SDK in Oncreate.
Code:
Then create NativeBannerAd object, set an AdListener, then retrieve the "Native Banner Ad's" properties and display it in onAdLoaded() method. It will display the ad once it is loaded successfully. After that call loadAd() after AdListener in your Activity as follows.
Code:
Then paste the following code in your activity after Oncreate.
Code:
So the final code will be in your java activity file is as follows:
Code:
Now if you run your App you will see the Native Banner ad.
I am nothing but a online business man. more than 12 years of experiences in online business. I have learned everything of my own. You know if you learn something from your own you will learn more than somebody taught you on that topic. Long story short, I did lots of experiments, did lots of online jobs for the people, got lots of errors changes the way again and again. At the end got the perfect knowledge about online business. I would love to let you know all of my 12 years of knowledge about online business. Keep in touch with the blog to be knowledged about online business.
Thanks
, click here →
bidvertiser
About Site
WebLearners is a blog to teach online business such as E-com Business, App Business, SEO Business, Digital Marketing, etc. Lots of free tools and web applications will be given for free. Actually, We will dig deep on every topic one by one. It will be a long journey but in the end, you will be a succesful online businessman. Tutorials are expressed as a guideline for the person who wishes to start an online business. Readers can ask any questions or can ask for help to develop their business. We will be happy to help.
, click here →
How to Enable Download in Android Webview App? In the Last post of our Webview Series, I have shown How to Add Splash Screen in Any Androi...
bidvertiser
About Me
I am nothing but a online business man. more than 12 years of experiences in online business. I have learned everything of my own. You know if you learn something from your own you will learn more than somebody taught you on that topic. Long story short, I did lots of experiments, did lots of online jobs for the people, got lots of errors changes the way again and again. At the end got the perfect knowledge about online business. I would love to let you know all of my 12 years of knowledge about online business. Keep in touch with the blog to be knowledged about online business.
Thanks
, click here →
4.1 risk violation discce amar sokol app a please help me brother :(
ReplyDeleteOk we will try to create a video on it brother :)
Delete