How to Use Facebook / Meta Audience Network Ads Implantation 2023 || Facebook Banner And Interstitial Ads || RSM Developer

 Facebook Banner And Interstitial Ads

How to Use Facebook / Meta Audience Network Ads Implantation 2023 || Facebook Banner And Interstitial Ads

Step 1Creating a new project

  • Open a new project.
  • We will be working on Empty Activity with language as Java. Leave all other options unchanged.
  • You can change the name of the project at your convenience.
  • There will be two default files named activity_main.xml and MainActivity.java.
Step 2: Navigate to Build scripts > build.gradle(module) file and add the following dependency to it and Syne Now
//Facebook Ads
implementation 'com.github.AtikulSoftware:FacebookMetaAds:1.0.0'
And
targetSdk 33
compileSdk 33
Or
implementation 'androidx.appcompat:appcompat:1.5.1'

Step 3: Navigate to Build scripts > gradle.properties(Project Properties) file and add the following dependency to dependencyResolutionManagement and Syne Now

   android.enableJetifier=true

Step 4: Navigate to Build scripts > settings.gradle(Project Setting) file and add the following dependency to dependencyResolutionManagement and Syne Now

       maven url 'https://jitpack.io' } 

Step 5: Open res -> layout ->activity_main.xml (or) main.xml and add following code:

In this step we open an XML file and add the code :-

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="5dp"
tools:context=".MainActivity">

<Button
android:id="@+id/Interstitial_Ads"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="InterstitialAd"
android:textSize="30sp"
/>


<LinearLayout
android:id="@+id/Banner_Ads"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:orientation="vertical"
/>
</RelativeLayout>

Step 6: Open Java -> package – > MainActivity.Java and add following code:

In this step we open an Java file and add the code :-

package com.rsmdeveloper.fackbookads;

import android.content.Intent;
import android.os.Bundle;
import android.widget.Button;
import android.widget.Toast;

import androidx.appcompat.app.AppCompatActivity;

import com.atikulsoftware.metaadslibrary.MetaAds.AdsUnit;
import com.atikulsoftware.metaadslibrary.MetaAds.FacebookAds;

/**
* Created by RSM Developer on 09-03-2023.
* Follow Facebook : https://www.facebook.com/RSMDeveloper
* Subscribe YouTube : https://www.youtube.com/@RSMDeveloper
* Visit Website : https://rsmdeveloper.blogspot.com/
* Developed Your Creativity With RSM Developer
**/

public class MainActivity extends AppCompatActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

AdsUnit.BANNER = "IMG_16_9_APP_INSTALL#YOUR_PLACEMENT_ID";
AdsUnit.INTERSTITIAL = "IMG_16_9_APP_INSTALL#YOUR_PLACEMENT_ID";

FacebookAds.loadInterstitial(MainActivity.this);

FacebookAds.setBanner(findViewById(R.id.Banner_Ads), MainActivity.this);

Button showAds = findViewById(R.id.Interstitial_Ads);
showAds.setOnClickListener(v -> {
// Code here
new FacebookAds(() -> {
Intent intent = new Intent(MainActivity.this, MainActivity2.class);
startActivity(intent);
// Next Action
Toast.makeText(MainActivity.this, "Ads Closed", Toast.LENGTH_SHORT).show();
}).showInterstitial();
});


}
}


Step 7: Create a New Empty Activity with language as Java:- Name Activaty2 

Java:- Name Activaty2 

Output:

Now run the App and you will see main topics and sub-topics listed.....

Watch Video


Post a Comment

Previous Post Next Post

যোগাযোগ ফর্ম