Admob And Meta Audience Network (Android Studio) Included Example PDF আমরা একই সাথে, গুগল এডমোব এবং ফেসবুক অডিয়েন্স নেটওয়ার্ক ।বিজ্ঞাপন আমাদের, অ্যাপের ভিতরে শো করাবো।
দয়াকরে স্টেপগুলো ভালো করে খেয়াল করুন। আপনি আপনার অ্যাপ এর ভিতরে অ্যাডগুলো শো করাতে পারেন। Link
প্রয়োজন হলে এই লিঙ্কে ক্লিক করে ভিডিও টিউটোরিয়াল দেখে নিতে পারেন। Link । আপনি চাইলে android-studio সাহায্যে অ্যান্ড্রয়েড অ্যাপ ডেভেলপ করতে পারেন। তার জন্য আমাদের সম্পূর্ণ টিউটোরিয়াল কোর্স ঘরে বসে দেখে নিজের ক্যারিয়ার গড়তে পারেন। Full Course Link
01 Step (অ্যাপ এর ভিতরে এস ডি কে এড করুন) build.gradle
implementation 'androidx.annotation:annotation:1.0.0'implementation 'com.facebook.android:audience-network-sdk:6.8.0'implementation 'com.google.android.gms:play-services-ads:20.5.0'
02: Step (Add ) strings.xml
<string name="ad_app_id" translatable="false">ca-app-pub-3940256099942544~3347511713</string><string name="banner_ad_unit_id" translatable="false">ca-app-pub-3940256099942544/6300978111</string><string name="interstitial_ad_unit_id" translatable="false">ca-app-pub-3940256099942544/1033173712</string><string name="Facebook_banner_placement">IMG_16_9_APP_INSTALL#YOUR_PLACEMENT_ID</string><string name="Facebook_Interstitial_placement" translatable="false">IMG_16_9_APP_INSTALL#YOUR_PLACEMENT_ID</string>
03: Step (Add ) AndroidManifest.xml
<meta-dataandroid:name="com.google.android.gms.ads.APPLICATION_ID"android:value="@string/ad_app_id" />
04: Step (Create a) AdMobClass.Java
package com.i_techbangla.myapplication;import android.app.Activity;import android.content.Context;import android.util.Log;import androidx.annotation.NonNull;import com.google.android.gms.ads.AdError;import com.google.android.gms.ads.AdRequest;import com.google.android.gms.ads.FullScreenContentCallback;import com.google.android.gms.ads.LoadAdError;import com.google.android.gms.ads.interstitial.InterstitialAd;import com.google.android.gms.ads.interstitial.InterstitialAdLoadCallback;public class AdMobClass extends Activity { private static final String TAG = "ADMOB"; private InterstitialAd mInterstitialAd; private Context mContext; public AdMobClass(Context mContext) { this.mContext = mContext; } public void initInterstitialAd() { AdRequest adRequest = new AdRequest.Builder().build(); InterstitialAd.load(mContext,mContext.getString(R.string.interstitial_ad_unit_id), adRequest, new InterstitialAdLoadCallback() { private AdMobClass mContext; @Override public void onAdLoaded(@NonNull InterstitialAd interstitialAd) { mInterstitialAd = interstitialAd; Log.i(TAG, "onAdLoaded"); mInterstitialAd.setFullScreenContentCallback(new FullScreenContentCallback(){ @Override public void onAdDismissedFullScreenContent() { } @Override public void onAdFailedToShowFullScreenContent(AdError adError) { } @Override public void onAdShowedFullScreenContent() { mInterstitialAd = null; } }); mInterstitialAd.show(this.mContext); } @Override public void onAdFailedToLoad(@NonNull LoadAdError loadAdError) { this.mContext.mInterstitialAd=null; }}); } @Override public void onPointerCaptureChanged(boolean hasCapture) { }}
05: Step (Create a) facebook.Java
package com.i_techbangla.myapplication;import android.app.Activity;import android.content.Context;import android.util.Log;import com.facebook.ads.Ad;import com.facebook.ads.AdError;import com.facebook.ads.AudienceNetworkAds;import com.facebook.ads.InterstitialAd;import com.facebook.ads.InterstitialAdListener;public class facebook extends Activity { private static final String TAG = "ADMOB"; private InterstitialAd interstitialAd; private Context mContext; public facebook(Context mContext) { this.mContext = mContext; AudienceNetworkAds.initialize(mContext); } public void facebook_ads() { interstitialAd = new InterstitialAd(mContext, mContext.getString(R.string.Facebook_Interstitial_placement)); // Create listeners for the Interstitial Ad InterstitialAdListener interstitialAdListener = new InterstitialAdListener() { @Override public void onInterstitialDisplayed(Ad ad) { // Interstitial ad displayed callback Log.e(TAG, "Interstitial ad displayed."); } @Override public void onInterstitialDismissed(Ad ad) { // Interstitial dismissed callback Log.e(TAG, "Interstitial ad dismissed."); } @Override public void onError(Ad ad, AdError adError) { // Ad error callback Log.e(TAG, "Interstitial ad failed to load: " + adError.getErrorMessage()); } @Override public void onAdLoaded(Ad ad) { // Interstitial ad is loaded and ready to be displayed Log.d(TAG, "Interstitial ad is loaded and ready to be displayed!"); // Show the ad interstitialAd.show(); } @Override public void onAdClicked(Ad ad) { // Ad clicked callback Log.d(TAG, "Interstitial ad clicked!"); } @Override public void onLoggingImpression(Ad ad) { // Ad impression logged callback Log.d(TAG, "Interstitial ad impression logged!"); } }; // For auto play video ads, it's recommended to load the ad // at least 30 seconds before it is shown interstitialAd.loadAd( interstitialAd.buildLoadAdConfig() .withAdListener(interstitialAdListener) .build()); } @Override public void onPointerCaptureChanged(boolean hasCapture) { }}
06: Step (Your activity ) activity.java
Below this class,public class
private AdMobClass admob;private facebook facebook;
07: Step (Call Facebook & AdMobClass ,Display Ads ) activity.java
/// Admob Call admob = new AdMobClass(getApplicationContext()); /// facebook Call facebook = new facebook(getApplicationContext()); /// admob Ads Call Display ads admob.initInterstitialAd();/// facebook Ads Call Display ads facebook.facebook_ads();