com.mopub.common.SdkConfiguration Java Examples

The following examples show how to use com.mopub.common.SdkConfiguration. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AptoideApplication.java    From aptoide-client-v8 with GNU General Public License v3.0 6 votes vote down vote up
public void initializeMoPub() {
  SdkConfiguration sdkConfiguration = new SdkConfiguration.Builder(
      BuildConfig.MOPUB_BANNER_50_HOME_PLACEMENT_ID).withAdditionalNetwork(
      AppLovinBaseAdapterConfiguration.class.toString())
      .withMediatedNetworkConfiguration(AppLovinBaseAdapterConfiguration.class.toString(),
          getMediatedNetworkConfigurationBaseMap(BuildConfig.MOPUB_BANNER_50_HOME_PLACEMENT_ID))
      .withAdditionalNetwork(InMobiBaseAdapterConfiguration.class.getName())
      .withMediatedNetworkConfiguration(InMobiBaseAdapterConfiguration.class.toString(),
          getMediatedNetworkConfigurationBaseMap(BuildConfig.MOPUB_BANNER_50_HOME_PLACEMENT_ID))
      .withAdditionalNetwork(InneractiveAdapterConfiguration.class.getName())
      .withMediatedNetworkConfiguration(InneractiveAdapterConfiguration.class.getName(),
          getMediatedNetworkConfigurationWithAppIdMap(
              BuildConfig.MOPUB_BANNER_50_HOME_PLACEMENT_ID,
              BuildConfig.MOPUB_FYBER_APPLICATION_ID))
      .withAdditionalNetwork(AppnextBaseAdapterConfiguration.class.toString())
      .withMediatedNetworkConfiguration(AppnextBaseAdapterConfiguration.class.toString(),
          getMediatedNetworkConfigurationBaseMap(
              BuildConfig.MOPUB_BANNER_50_EXCLUSIVE_PLACEMENT_ID))
      .withAdditionalNetwork(GooglePlayServicesAdapterConfiguration.class.getName())
      .withMediatedNetworkConfiguration(GooglePlayServicesAdapterConfiguration.class.getName(),
          getAdMobAdsPreferencesMap())
      .withLogLevel(MoPubLog.LogLevel.DEBUG)
      .build();

  MoPub.initializeSdk(this, sdkConfiguration, null);
}
 
Example #2
Source File: MoPubSingleton.java    From googleads-mobile-android-mediation with Apache License 2.0 6 votes vote down vote up
public void loadRewardedAd(Context context,
    final String adUnitID,
    final MoPubRewardedVideoManager.RequestParameters requestParameters,
    final MoPubAdapterRewardedListener adapterRewardedListener) {
  if (hasListener(adUnitID)) {
    String errorMessage =
        "An ad has already been requested for the MoPub Ad Unit ID: " + adUnitID;
    adapterRewardedListener.onAdFailedToLoad(ERROR_AD_ALREADY_LOADED, errorMessage);
    return;
  }

  mListeners.put(adUnitID, new WeakReference<>(adapterRewardedListener));

  SdkConfiguration configuration = new SdkConfiguration.Builder(adUnitID).build();
  initializeMoPubSDK(context, configuration, new SdkInitializationListener() {
    @Override
    public void onInitializationFinished() {
      MoPubRewardedVideos.loadRewardedVideo(adUnitID, requestParameters);
    }
  });
}
 
Example #3
Source File: DemoActivity.java    From prebid-mobile-android with Apache License 2.0 5 votes vote down vote up
private void setupMPRubiconRewardedVideo() {
    SdkConfiguration sdkConfiguration = new SdkConfiguration.Builder(MP_ADUNITID_REWARDED)
            .build();
    MoPub.initializeSdk(this, sdkConfiguration, null);

    MoPubRewardedVideos.setRewardedVideoListener(this);
}
 
Example #4
Source File: MoPubSingleton.java    From googleads-mobile-android-mediation with Apache License 2.0 5 votes vote down vote up
public void initializeMoPubSDK(Context context,
    SdkConfiguration configuration,
    SdkInitializationListener listener) {
  if (MoPub.isSdkInitialized()) {
    MoPubRewardedVideos.setRewardedVideoListener(MoPubSingleton.this);
    listener.onInitializationFinished();
    return;
  }

  mInitListeners.add(listener);
  if (!isInitializing) {
    isInitializing = true;

    MoPub.initializeSdk(context, configuration, new SdkInitializationListener() {
      @Override
      public void onInitializationFinished() {
        MoPubLog.d("MoPub SDK initialized.");
        isInitializing = false;

        MoPubRewardedVideos.setRewardedVideoListener(MoPubSingleton.this);
        for (SdkInitializationListener initListener : mInitListeners) {
          initListener.onInitializationFinished();
        }
        mInitListeners.clear();
      }
    });
  }
}
 
Example #5
Source File: TestResultsActivity.java    From prebid-mobile-android with Apache License 2.0 4 votes vote down vote up
private void initMoPub(String adUnitId) {
    SdkConfiguration sdkConfiguration = new SdkConfiguration.Builder(adUnitId).build();
    MoPub.initializeSdk(this, sdkConfiguration, this::runTests);
}
 
Example #6
Source File: MoPubAdapter.java    From googleads-mobile-android-mediation with Apache License 2.0 4 votes vote down vote up
@Override
public void requestBannerAd(final Context context,
    MediationBannerListener mediationBannerListener,
    Bundle bundle,
    final AdSize adSize,
    MediationAdRequest mediationAdRequest,
    final Bundle mediationExtras) {
  mContext = context;
  mAdSize = adSize;
  mExtras = mediationExtras;

  String adUnit = bundle.getString(MOPUB_AD_UNIT_KEY);
  if (TextUtils.isEmpty(adUnit)) {
    String errorMessage = createAdapterError(ERROR_INVALID_SERVER_PARAMETERS,
        "Missing or Invalid MoPub Ad Unit ID.");
    Log.w(TAG, errorMessage);
    mediationBannerListener.onAdFailedToLoad(MoPubAdapter.this,
        ERROR_INVALID_SERVER_PARAMETERS);
    return;
  }

  mMoPubView = new MoPubView(context);
  mMoPubView.setBannerAdListener(new MBannerListener(mediationBannerListener));
  mMoPubView.setAdUnitId(adUnit);

  //If test mode is enabled
  if (mediationAdRequest.isTesting()) {
    mMoPubView.setTesting(true);
  }

  //If location is available
  if (mediationAdRequest.getLocation() != null) {
    mMoPubView.setLocation(mediationAdRequest.getLocation());
  }

  mMoPubView.setKeywords(getKeywords(mediationAdRequest, false));
  mMoPubView.setUserDataKeywords(getKeywords(mediationAdRequest, true));

  SdkConfiguration sdkConfiguration = new SdkConfiguration.Builder(adUnit).build();
  MoPubSingleton.getInstance().initializeMoPubSDK(context, sdkConfiguration,
      new SdkInitializationListener() {
        @Override
        public void onInitializationFinished() {
          mMoPubView.loadAd();
        }
      });
}