After using Applovin ads for over 6 months, I have noticed that for certain countries like India, Admob works better than Applovin. So to switch the ad network based on geo location of the user, we need to implement Admob Mediation.
Admob by default supports mediation for a few networks, which Applovin is not a part of. But they have an option to implement it using Custom Events. Applovin has a guide on that, in this url (you may have to login to see it)
https://www.applovin.com/developer#tab=Integration&page=AdMobMediation&platform=android
Could you please explain how to accomplish this with B4A? I am posting the contents of the above url here:
AppLovin Android SDK
You must first make sure to do the basic integration of the AppLovin Android SDK.
Those instructions can be found here.
https://www.applovin.com/developer#tab=Integration&page=SDKIntegration&platform=android
AdMobMediationListener Class
You must add the following class to your application:
Replace "YOUR_PACKAGE" with your package name.
Add AdMob Custom Event
Add a new custom event in the AdMob web UI. The class name must be YOUR_PACKAGE.AdMobMediationListener.
Enable AppLovin Mediation
Enable AppLovin Ad rotation in the AdMob mediation web UI.
Demo Project
https://github.com/AppLovin/AppLovin-Android-SDK-DemoApp
Admob by default supports mediation for a few networks, which Applovin is not a part of. But they have an option to implement it using Custom Events. Applovin has a guide on that, in this url (you may have to login to see it)
https://www.applovin.com/developer#tab=Integration&page=AdMobMediation&platform=android
Could you please explain how to accomplish this with B4A? I am posting the contents of the above url here:
AppLovin Android SDK
You must first make sure to do the basic integration of the AppLovin Android SDK.
Those instructions can be found here.
https://www.applovin.com/developer#tab=Integration&page=SDKIntegration&platform=android
AdMobMediationListener Class
You must add the following class to your application:
B4X:
package YOUR_PACKAGE;
import android.app.Activity;
import com.applovin.adview.AppLovinAdView;
import com.applovin.sdk.AppLovinAd;
import com.applovin.sdk.AppLovinAdClickListener;
import com.applovin.sdk.AppLovinAdLoadListener;
import com.applovin.sdk.AppLovinAdSize;
import com.applovin.sdk.AppLovinSdk;
import com.google.ads.AdSize;
import com.google.ads.mediation.MediationAdRequest;
import com.google.ads.mediation.customevent.CustomEventBanner;
import com.google.ads.mediation.customevent.CustomEventBannerListener;
/**
* This class must be defined and referenced from AdMob's website for AdMob Mediation
*
* @author David Anderson
* @since 4.2
*/
public class AdMobMediationListener implements CustomEventBanner
{
/**
* This method will be called by AdMob's Mediation through Custom Event mechanism.
*/
@Override
public void requestBannerAd(final CustomEventBannerListener listener,
final Activity activity,
String label,
String serverParameter,
AdSize adSize,
MediationAdRequest request)
{
// Create AppLovin Ad View
final AppLovinSdk sdk = AppLovinSdk.getInstance(activity);
final AppLovinAdView adView = new AppLovinAdView(sdk, AppLovinAdSize.BANNER, activity);
adView.setAdClickListener(new AppLovinAdClickListener() {
@Override
public void adClicked(AppLovinAd arg0)
{
listener.onClick();
listener.onPresentScreen();
listener.onLeaveApplication();
}
});
// fetch an ad
sdk.getAdService().loadNextAd(AppLovinAdSize.BANNER, new AppLovinAdLoadListener() {
@Override
public void failedToReceiveAd(int errorCode)
{
listener.onFailedToReceiveAd();
}
@Override
public void adReceived(AppLovinAd ad)
{
adView.renderAd(ad);
listener.onReceivedAd(adView);
}
});
}
}
Replace "YOUR_PACKAGE" with your package name.
Add AdMob Custom Event
Add a new custom event in the AdMob web UI. The class name must be YOUR_PACKAGE.AdMobMediationListener.
Enable AppLovin Mediation
Enable AppLovin Ad rotation in the AdMob mediation web UI.
Demo Project
https://github.com/AppLovin/AppLovin-Android-SDK-DemoApp