com.mopub.common.MoPub Java Examples
The following examples show how to use
com.mopub.common.MoPub.
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: AppLovinCustomEventNative.java From aptoide-client-v8 with GNU General Public License v3.0 | 6 votes |
@Override public void loadNativeAd(final Context context, final CustomEventNativeListener customEventNativeListener, final Map<String, Object> localExtras, final Map<String, String> serverExtras) { log(DEBUG, "Requesting AppLovin native ad with server extras: " + serverExtras); // Pass the user consent from the MoPub SDK as per GDPR PersonalInfoManager personalInfoManager = MoPub.getPersonalInformationManager(); if (personalInfoManager != null && personalInfoManager.gdprApplies()) { boolean canCollectPersonalInfo = personalInfoManager.canCollectPersonalInformation(); AppLovinPrivacySettings.setHasUserConsent(canCollectPersonalInfo, context); } this.context = context; this.nativeListener = customEventNativeListener; sdk = retrieveSdk(serverExtras, context); sdk.setPluginVersion("MoPub-3.0.0"); sdk.getNativeAdService() .loadNativeAds(1, this); }
Example #2
Source File: MainActivity.java From aptoide-client-v8 with GNU General Public License v3.0 | 6 votes |
@Override protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); getActivityComponent().inject(this); final AptoideApplication application = (AptoideApplication) getApplicationContext(); MoPub.onCreate(this); installManager = application.getInstallManager(); snackBarLayout = findViewById(R.id.snackbar_layout); installErrorsDismissEvent = PublishRelay.create(); authenticationSubject = PublishSubject.create(); themeAnalytics.setDarkThemeUserProperty(themeManager.getDarkThemeMode()); progressDialog = GenericDialogs.createGenericPleaseWaitDialog(this, themeManager.getAttributeForTheme(R.attr.dialogsTheme).resourceId); setupUpdatesNotification(); attachPresenter(presenter); handleAuthenticationIntent(getIntent()); }
Example #3
Source File: AppLovinCustomEventNative.java From SDK-Network-Adapters with MIT License | 6 votes |
@Override public void loadNativeAd(final Context context, final CustomEventNativeListener customEventNativeListener, final Map<String, Object> localExtras, final Map<String, String> serverExtras) { log( DEBUG, "Requesting AppLovin native ad with server extras: " + serverExtras ); // Pass the user consent from the MoPub SDK as per GDPR PersonalInfoManager personalInfoManager = MoPub.getPersonalInformationManager(); if ( personalInfoManager != null && personalInfoManager.gdprApplies() ) { boolean canCollectPersonalInfo = personalInfoManager.canCollectPersonalInformation(); AppLovinPrivacySettings.setHasUserConsent( canCollectPersonalInfo, context ); } this.context = context; this.nativeListener = customEventNativeListener; sdk = retrieveSdk( serverExtras, context ); sdk.setPluginVersion( "MoPub-3.0.0" ); sdk.getNativeAdService().loadNativeAds( 1, this ); }
Example #4
Source File: MoPubMediationAdapter.java From googleads-mobile-android-mediation with Apache License 2.0 | 6 votes |
@Override public VersionInfo getSDKVersionInfo() { String versionString = MoPub.SDK_VERSION; String[] splits = versionString.split("\\."); if (splits.length >= 3) { int major = Integer.parseInt(splits[0]); int minor = Integer.parseInt(splits[1]); int micro = Integer.parseInt(splits[2]); return new VersionInfo(major, minor, micro); } String logMessage = String.format("Unexpected SDK version format: %s. " + "Returning 0.0.0 for SDK version.", versionString); Log.w(TAG, logMessage); return new VersionInfo(0, 0, 0); }
Example #5
Source File: AptoideApplication.java From aptoide-client-v8 with GNU General Public License v3.0 | 6 votes |
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 #6
Source File: MoPubConsentManager.java From aptoide-client-v8 with GNU General Public License v3.0 | 6 votes |
@Override public void showConsentDialog() { PersonalInfoManager personalInfoManager = MoPub.getPersonalInformationManager(); personalInfoManager.loadConsentDialog(new ConsentDialogListener() { @Override public void onConsentDialogLoaded() { if (personalInfoManager != null && personalInfoManager.isConsentDialogReady() && !wasMoPubConsentDialogShown) { wasMoPubConsentDialogShown = true; personalInfoManager.showConsentDialog(); } } @Override public void onConsentDialogLoadFailed(@NonNull MoPubErrorCode moPubErrorCode) { Logger.getInstance() .d("MoPubConsent", "MoPub Consent dialog failed to load due to " + moPubErrorCode.toString()); } }); }
Example #7
Source File: DemoActivity.java From prebid-mobile-android with Apache License 2.0 | 5 votes |
private void setupMPRubiconRewardedVideo() { SdkConfiguration sdkConfiguration = new SdkConfiguration.Builder(MP_ADUNITID_REWARDED) .build(); MoPub.initializeSdk(this, sdkConfiguration, null); MoPubRewardedVideos.setRewardedVideoListener(this); }
Example #8
Source File: MainActivity.java From aptoide-client-v8 with GNU General Public License v3.0 | 5 votes |
@Override protected void onDestroy() { autoUpdateDialog = null; installErrorsDismissEvent = null; installManager = null; updatesBadge = null; snackBarLayout = null; snackbar = null; progressDialog = null; authenticationSubject = null; super.onDestroy(); MoPub.onDestroy(this); }
Example #9
Source File: App.java From cannonball-android with Apache License 2.0 | 5 votes |
@Override public void onCreate() { super.onCreate(); singleton = this; extractAvenir(); authConfig = new TwitterAuthConfig(BuildConfig.CONSUMER_KEY, BuildConfig.CONSUMER_SECRET); Fabric.with(this, new Crashlytics(), new Digits(), new Twitter(authConfig), new MoPub()); Crashlytics.setBool(CRASHLYTICS_KEY_CRASHES, areCrashesEnabled()); }
Example #10
Source File: MoPubSingleton.java From googleads-mobile-android-mediation with Apache License 2.0 | 5 votes |
static String getKeywords(MediationAdConfiguration mediationConfiguration, boolean intendedForPII) { if (intendedForPII) { if (MoPub.canCollectPersonalInformation()) { return containsPII(mediationConfiguration) ? MoPubAdapter.MOPUB_NATIVE_CEVENT_VERSION : ""; } else { return ""; } } else { return containsPII(mediationConfiguration) ? "" : MoPubAdapter.MOPUB_NATIVE_CEVENT_VERSION; } }
Example #11
Source File: MoPubSingleton.java From googleads-mobile-android-mediation with Apache License 2.0 | 5 votes |
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 #12
Source File: MoPubAdapter.java From googleads-mobile-android-mediation with Apache License 2.0 | 5 votes |
public static String getKeywords(MediationAdRequest mediationAdRequest, boolean intendedForPII) { Date birthday = mediationAdRequest.getBirthday(); String ageString = ""; if (birthday != null) { int ageInt = getAge(birthday); ageString = "m_age:" + ageInt; } int gender = mediationAdRequest.getGender(); String genderString = ""; if (gender != -1) { if (gender == GENDER_FEMALE) { genderString = "m_gender:f"; } else if (gender == GENDER_MALE) { genderString = "m_gender:m"; } } StringBuilder keywordsBuilder = new StringBuilder(); keywordsBuilder = keywordsBuilder.append(MOPUB_NATIVE_CEVENT_VERSION) .append(",").append(ageString) .append(",").append(genderString); if (intendedForPII) { if (MoPub.canCollectPersonalInformation()) { return keywordsContainPII(mediationAdRequest) ? keywordsBuilder.toString() : ""; } else { return ""; } } else { return keywordsContainPII(mediationAdRequest) ? "" : keywordsBuilder.toString(); } }
Example #13
Source File: AppLovinCustomEventInterstitial.java From SDK-Network-Adapters with MIT License | 4 votes |
@Override public void loadInterstitial(final Context context, final CustomEventInterstitialListener listener, final Map<String, Object> localExtras, final Map<String, String> serverExtras) { log( DEBUG, "Requesting AppLovin interstitial with serverExtras: " + serverExtras + " and localExtras: " + localExtras ); // SDK versions BELOW 7.2.0 require a instance of an Activity to be passed in as the context if ( AppLovinSdk.VERSION_CODE < 720 && !( context instanceof Activity ) ) { log( ERROR, "Unable to request AppLovin banner. Invalid context provided." ); listener.onInterstitialFailed( MoPubErrorCode.ADAPTER_CONFIGURATION_ERROR ); return; } // Pass the user consent from the MoPub SDK as per GDPR PersonalInfoManager personalInfoManager = MoPub.getPersonalInformationManager(); if ( personalInfoManager != null && personalInfoManager.gdprApplies() ) { boolean canCollectPersonalInfo = personalInfoManager.canCollectPersonalInformation(); AppLovinPrivacySettings.setHasUserConsent( canCollectPersonalInfo, context ); } // Store parent objects this.listener = listener; this.context = context; sdk = retrieveSdk( serverExtras, context ); sdk.setPluginVersion( "MoPub-3.0.0" ); // Zones support is available on AppLovin SDK 7.5.0 and higher final String serverExtrasZoneId = serverExtras != null ? serverExtras.get( "zone_id" ) : null; zoneId = ( !TextUtils.isEmpty( serverExtrasZoneId ) && AppLovinSdk.VERSION_CODE >= 750 ) ? serverExtrasZoneId : DEFAULT_ZONE; // Check if we already have a preloaded ad for the given zone final AppLovinAd preloadedAd = dequeueAd( zoneId ); if ( preloadedAd != null ) { log( DEBUG, "Found preloaded ad for zone: {" + zoneId + "}" ); adReceived( preloadedAd ); } else { // If this is a default Zone, create the incentivized ad normally if ( DEFAULT_ZONE.equals( zoneId ) ) { sdk.getAdService().loadNextAd( AppLovinAdSize.INTERSTITIAL, this ); } // Otherwise, use the Zones API else { sdk.getAdService().loadNextAdForZoneId( zoneId, this ); } } }
Example #14
Source File: AppLovinCustomEventRewardedVideo.java From SDK-Network-Adapters with MIT License | 4 votes |
@Override protected void loadWithSdkInitialized(@NonNull final Activity activity, @NonNull final Map<String, Object> localExtras, @NonNull final Map<String, String> serverExtras) throws Exception { log( DEBUG, "Requesting AppLovin banner with serverExtras: " + serverExtras + " and localExtras: " + localExtras ); // Pass the user consent from the MoPub SDK as per GDPR PersonalInfoManager personalInfoManager = MoPub.getPersonalInformationManager(); if ( personalInfoManager != null && personalInfoManager.gdprApplies() ) { boolean canCollectPersonalInfo = personalInfoManager.canCollectPersonalInformation(); AppLovinPrivacySettings.setHasUserConsent( canCollectPersonalInfo, activity.getApplicationContext() ); } parentActivity = activity; // Zones support is available on AppLovin SDK 7.5.0 and higher final String zoneId; if ( AppLovinSdk.VERSION_CODE >= 750 && serverExtras != null && serverExtras.containsKey( "zone_id" ) ) { zoneId = serverExtras.get( "zone_id" ); } else { zoneId = DEFAULT_ZONE; } // Check if incentivized ad for zone already exists if ( GLOBAL_INCENTIVIZED_INTERSTITIAL_ADS.containsKey( zoneId ) ) { incentivizedInterstitial = GLOBAL_INCENTIVIZED_INTERSTITIAL_ADS.get( zoneId ); } else { // If this is a default Zone, create the incentivized ad normally if ( DEFAULT_ZONE.equals( zoneId ) ) { incentivizedInterstitial = AppLovinIncentivizedInterstitial.create( activity ); } // Otherwise, use the Zones API else { incentivizedInterstitial = AppLovinIncentivizedInterstitial.create( zoneId, sdk ); } GLOBAL_INCENTIVIZED_INTERSTITIAL_ADS.put( zoneId, incentivizedInterstitial ); } incentivizedInterstitial.preload( this ); }
Example #15
Source File: MoPubConsentManager.java From aptoide-client-v8 with GNU General Public License v3.0 | 4 votes |
@Override public Single<Boolean> shouldShowConsentDialog() { PersonalInfoManager personalInfoManager = MoPub.getPersonalInformationManager(); return Single.just(personalInfoManager.shouldShowConsentDialog()); }
Example #16
Source File: MainActivity.java From aptoide-client-v8 with GNU General Public License v3.0 | 4 votes |
@Override protected void onRestart() { super.onRestart(); MoPub.onRestart(this); }
Example #17
Source File: MainActivity.java From aptoide-client-v8 with GNU General Public License v3.0 | 4 votes |
@Override protected void onStop() { super.onStop(); MoPub.onStop(this); }
Example #18
Source File: MainActivity.java From aptoide-client-v8 with GNU General Public License v3.0 | 4 votes |
@Override protected void onPause() { super.onPause(); MoPub.onPause(this); }
Example #19
Source File: MainActivity.java From aptoide-client-v8 with GNU General Public License v3.0 | 4 votes |
@Override protected void onResume() { super.onResume(); MoPub.onResume(this); }
Example #20
Source File: MainActivity.java From aptoide-client-v8 with GNU General Public License v3.0 | 4 votes |
@Override protected void onStart() { super.onStart(); MoPub.onStart(this); }
Example #21
Source File: TestResultsActivity.java From prebid-mobile-android with Apache License 2.0 | 4 votes |
private void initMoPub(String adUnitId) { SdkConfiguration sdkConfiguration = new SdkConfiguration.Builder(adUnitId).build(); MoPub.initializeSdk(this, sdkConfiguration, this::runTests); }