com.applovin.sdk.AppLovinSdk Java Examples
The following examples show how to use
com.applovin.sdk.AppLovinSdk.
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: AppLovinCustomEventInterstitial.java From SDK-Network-Adapters with MIT License | 6 votes |
@Override public void showInterstitial() { final AppLovinAd preloadedAd = dequeueAd( zoneId ); if ( preloadedAd != null ) { final AppLovinSdk sdk = AppLovinSdk.getInstance( context ); final AppLovinInterstitialAdDialog interstitialAd = AppLovinInterstitialAd.create( sdk, context ); interstitialAd.setAdDisplayListener( this ); interstitialAd.setAdClickListener( this ); interstitialAd.setAdVideoPlaybackListener( this ); interstitialAd.showAndRender( preloadedAd ); } else { log( ERROR, "Failed to show an AppLovin interstitial before one was loaded" ); listener.onAdFailedToLoad( AdRequest.ERROR_CODE_INTERNAL_ERROR ); } }
Example #2
Source File: AppLovinUtils.java From googleads-mobile-android-mediation with Apache License 2.0 | 6 votes |
/** * Retrieves the appropriate instance of AppLovin's SDK from the SDK key given in the server * parameters, or Android Manifest. */ public static AppLovinSdk retrieveSdk(Bundle serverParameters, Context context) { final String sdkKey = (serverParameters != null) ? serverParameters.getString(ServerParameterKeys.SDK_KEY) : null; final AppLovinSdk sdk; if (!TextUtils.isEmpty(sdkKey)) { sdk = AppLovinSdk.getInstance(sdkKey, new AppLovinSdkSettings(), context); } else { sdk = AppLovinSdk.getInstance(context); } sdk.setPluginVersion(BuildConfig.VERSION_NAME); sdk.setMediationProvider(AppLovinMediationProvider.ADMOB); return sdk; }
Example #3
Source File: MainActivity.java From Android-SDK-Demo with MIT License | 6 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate( savedInstanceState ); AppLovinSdk.getInstance( this ).initializeSdk( new AppLovinSdk.SdkInitializationListener() { @Override public void onSdkInitialized(final AppLovinSdkConfiguration config) { // SDK finished initialization } } ); // Set an identifier for the current user. This identifier will be tied to various analytics events and rewarded video validation AppLovinSdk.getInstance( this ).setUserIdentifier( "[email protected]" ); // Check that SDK key is present in Android Manifest checkSdkKey(); }
Example #4
Source File: AppLovinMediationAdapter.java From googleads-mobile-android-mediation with Apache License 2.0 | 6 votes |
@Override public void initialize( Context context, InitializationCompleteCallback initializationCompleteCallback, List<MediationConfiguration> mediationConfigurations) { log(DEBUG, "Attempting to initialize SDK."); if (!(context instanceof Activity)) { initializationCompleteCallback.onInitializationFailed( "AppLovin requires an Activity context to initialize."); return; } Activity activity = (Activity) context; if (AppLovinUtils.androidManifestHasValidSdkKey(activity)) { AppLovinSdk.getInstance(activity).initializeSdk(); } for (MediationConfiguration mediationConfig : mediationConfigurations) { AppLovinSdk sdk = AppLovinUtils.retrieveSdk(mediationConfig.getServerParameters(), activity); sdk.initializeSdk(); } initializationCompleteCallback.onInitializationSucceeded(); }
Example #5
Source File: AppLovinMediationAdapter.java From googleads-mobile-android-mediation with Apache License 2.0 | 6 votes |
@Override public VersionInfo getSDKVersionInfo() { String versionString = AppLovinSdk.VERSION; String[] splits = versionString.split("\\."); if (splits.length >= 3) { int major = Integer.parseInt(splits[0]); int minor = Integer.parseInt(splits[1]); int patch = Integer.parseInt(splits[2]); return new VersionInfo(major, minor, patch); } 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 #6
Source File: AppLovinCustomEventBanner.java From SDK-Network-Adapters with MIT License | 6 votes |
/** * Retrieves the appropriate instance of AppLovin's SDK from the SDK key given in the server parameters, or Android Manifest. */ private static AppLovinSdk retrieveSdk(final Map<String, String> serverExtras, final Context context) { final String sdkKey = serverExtras != null ? serverExtras.get( "sdk_key" ) : null; final AppLovinSdk sdk; if ( !TextUtils.isEmpty( sdkKey ) ) { sdk = AppLovinSdk.getInstance( sdkKey, new AppLovinSdkSettings(), context ); } else { sdk = AppLovinSdk.getInstance( context ); } return sdk; }
Example #7
Source File: AppLovinCustomEventNative.java From SDK-Network-Adapters with MIT License | 6 votes |
/** * Retrieves the appropriate instance of AppLovin's SDK from the SDK key given in the server parameters, or Android Manifest. */ private static AppLovinSdk retrieveSdk(final Map<String, String> serverExtras, final Context context) { final String sdkKey = serverExtras != null ? serverExtras.get( "sdk_key" ) : null; final AppLovinSdk sdk; if ( !TextUtils.isEmpty( sdkKey ) ) { sdk = AppLovinSdk.getInstance( sdkKey, new AppLovinSdkSettings(), context ); } else { sdk = AppLovinSdk.getInstance( context ); } return sdk; }
Example #8
Source File: AppLovinCustomEventRewardedVideo.java From SDK-Network-Adapters with MIT License | 6 votes |
/** * Retrieves the appropriate instance of AppLovin's SDK from the SDK key given in the server parameters, or Android Manifest. */ private static AppLovinSdk retrieveSdk(final Map<String, String> serverExtras, final Context context) { final String sdkKey = serverExtras != null ? serverExtras.get( "sdk_key" ) : null; final AppLovinSdk sdk; if ( !TextUtils.isEmpty( sdkKey ) ) { sdk = AppLovinSdk.getInstance( sdkKey, new AppLovinSdkSettings(), context ); } else { sdk = AppLovinSdk.getInstance( context ); } return sdk; }
Example #9
Source File: AppLovinCustomEventInterstitial.java From SDK-Network-Adapters with MIT License | 6 votes |
/** * Retrieves the appropriate instance of AppLovin's SDK from the SDK key given in the server parameters, or Android Manifest. */ private static AppLovinSdk retrieveSdk(final Map<String, String> serverExtras, final Context context) { final String sdkKey = serverExtras != null ? serverExtras.get( "sdk_key" ) : null; final AppLovinSdk sdk; if ( !TextUtils.isEmpty( sdkKey ) ) { sdk = AppLovinSdk.getInstance( sdkKey, new AppLovinSdkSettings(), context ); } else { sdk = AppLovinSdk.getInstance( context ); } return sdk; }
Example #10
Source File: InlineCarouselCardView.java From Android-SDK-Demo with MIT License | 6 votes |
public void setUpView() { this.uiHandler = new Handler( Looper.getMainLooper() ); final LayoutInflater inflater = (LayoutInflater) getContext().getSystemService( Context.LAYOUT_INFLATER_SERVICE ); inflater.inflate( R.layout.applovin_card_view, this, true ); bindViews(); renderActivityIndicator(); if ( sdk == null ) { sdk = AppLovinSdk.getInstance( getContext() ); } sdk.getNativeAdService().precacheResources( ad, this ); }
Example #11
Source File: AppLovinCarouselView.java From Android-SDK-Demo with MIT License | 6 votes |
public AppLovinCarouselView(Context context, AttributeSet attrs, int defStyleAttr, AppLovinSdk sdk, List<AppLovinNativeAd> nativeAds) { super( context, attrs, defStyleAttr ); if ( !isInEditMode() ) { this.sdk = sdk; this.cardStates = new HashMap<Integer, InlineCarouselCardState>(); this.nativeAds = nativeAds; if ( context instanceof Activity ) { parentActivity = (Activity) context; } renderActivityIndicator(); } }
Example #12
Source File: ApplovinAdapter.java From SDK-Network-Adapters with MIT License | 5 votes |
@Override public void initialize(final Context context, final MediationAdRequest adRequest, final String userId, final MediationRewardedVideoAdListener listener, final Bundle serverParameters, final Bundle networkExtras) { // 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 rewarded video. Invalid context provided." ); listener.onInitializationFailed( this, AdRequest.ERROR_CODE_INVALID_REQUEST ); return; } log( DEBUG, "Initializing AppLovin rewarded video..." ); this.context = context; this.listener = listener; if ( !initialized ) { AppLovinSdk.initializeSdk( context ); AppLovinSdk.getInstance( context ).setPluginVersion( "AdMob-2.2.1" ); initialized = true; } listener.onInitializationSucceeded( this ); }
Example #13
Source File: ApplovinAdapter.java From SDK-Network-Adapters with MIT License | 5 votes |
@Override public void loadAd(final MediationAdRequest adRequest, final Bundle serverParameters, final Bundle networkExtras) { log( DEBUG, "Requesting AppLovin rewarded video with networkExtras: " + networkExtras ); // Zones support is available on AppLovin SDK 7.5.0 and higher final String zoneId; if ( AppLovinSdk.VERSION_CODE >= 750 && networkExtras != null && networkExtras.containsKey( "zone_id" ) ) { zoneId = networkExtras.getString( "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( this.context ); } // Otherwise, use the Zones API else { incentivizedInterstitial = AppLovinIncentivizedInterstitial.create( zoneId, AppLovinSdk.getInstance( this.context ) ); } GLOBAL_INCENTIVIZED_INTERSTITIAL_ADS.put( zoneId, incentivizedInterstitial ); } incentivizedInterstitial.preload( this ); }
Example #14
Source File: AppLovinRtbBannerRenderer.java From googleads-mobile-android-mediation with Apache License 2.0 | 5 votes |
public void loadAd() { Context context = adConfiguration.getContext(); if (!(context instanceof Activity)) { String adapterError = createAdapterError( ERROR_CONTEXT_NOT_ACTIVITY, "AppLovin requires an Activity context to load ads."); Log.e(TAG, "Failed to load banner ad from AppLovin: " + adapterError); callback.onFailure(adapterError); return; } AppLovinAdSize adSize = AppLovinUtils.appLovinAdSizeFromAdMobAdSize(context, adConfiguration.getAdSize()); if (adSize == null) { String errorMessage = createAdapterError( ERROR_BANNER_SIZE_MISMATCH, "Failed to request banner with unsupported size."); callback.onFailure(errorMessage); return; } AppLovinSdk sdk = AppLovinUtils.retrieveSdk(adConfiguration.getServerParameters(), context); adView = new AppLovinAdView(sdk, adSize, context); adView.setAdDisplayListener(this); adView.setAdClickListener(this); adView.setAdViewEventListener(this); // Load ad! sdk.getAdService().loadNextAdForAdToken(adConfiguration.getBidResponse(), this); }
Example #15
Source File: AppLovinNativeAdapter.java From googleads-mobile-android-mediation with Apache License 2.0 | 5 votes |
@Override public void requestNativeAd( final Context context, final MediationNativeListener mediationNativeListener, final Bundle serverParameters, final NativeMediationAdRequest nativeMediationAdRequest, final Bundle mediationExtras) { if (!nativeMediationAdRequest.isUnifiedNativeAdRequested() && !nativeMediationAdRequest.isAppInstallAdRequested()) { String errorMessage = createAdapterError( ERROR_REQUIRES_UNIFIED_NATIVE_ADS, "Failed to request native ad. " + "Unified Native Ad or App install Ad should be requested"); Log.e(TAG, errorMessage); mediationNativeListener.onAdFailedToLoad(this, ERROR_REQUIRES_UNIFIED_NATIVE_ADS); return; } if (!(context instanceof Activity)) { String adapterError = createAdapterError( ERROR_CONTEXT_NOT_ACTIVITY, "AppLovin requires an Activity context to load ads."); log(ERROR, "Failed to load native ad from AppLovin: " + adapterError); mediationNativeListener.onAdFailedToLoad( AppLovinNativeAdapter.this, ERROR_CONTEXT_NOT_ACTIVITY); return; } final AppLovinSdk sdk = AppLovinUtils.retrieveSdk(serverParameters, context); AppLovinNativeAdListener listener = new AppLovinNativeAdListener( this, mediationNativeListener, sdk, context, nativeMediationAdRequest); sdk.getNativeAdService().loadNativeAds(1, listener); }
Example #16
Source File: InterstitialBasicIntegrationActivity.java From Android-SDK-Demo with MIT License | 5 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate( savedInstanceState ); setContentView( R.layout.activity_interstitial_basic_integration ); adStatusTextView = (TextView) findViewById( R.id.status_label ); interstitialAd = AppLovinInterstitialAd.create( AppLovinSdk.getInstance( this ), this ); showButton = (Button) findViewById( R.id.showButton ); showButton.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { showButton.setEnabled( false ); log( "Showing..." ); // // Optional: Set ad load, ad display, ad click, and ad video playback callback listeners // interstitialAd.setAdLoadListener( InterstitialBasicIntegrationActivity.this ); interstitialAd.setAdDisplayListener( InterstitialBasicIntegrationActivity.this ); interstitialAd.setAdClickListener( InterstitialBasicIntegrationActivity.this ); interstitialAd.setAdVideoPlaybackListener( InterstitialBasicIntegrationActivity.this ); // This will only ever be used if you have video ads enabled. interstitialAd.show(); } } ); }
Example #17
Source File: AppLovinNativeAdListener.java From googleads-mobile-android-mediation with Apache License 2.0 | 5 votes |
public AppLovinNativeAdListener( AppLovinNativeAdapter adapter, MediationNativeListener nativeListener, AppLovinSdk sdk, Context context, NativeMediationAdRequest mediationAdRequest) { mAdapter = adapter; mNativeListener = nativeListener; mSdk = sdk; mContextWeakReference = new WeakReference<>(context); mMediationAdRequest = mediationAdRequest; }
Example #18
Source File: MainActivity.java From Android-SDK-Demo with MIT License | 5 votes |
private Drawable getMuteIconForCurrentSdkMuteSetting() { AppLovinSdk sdk = AppLovinSdk.getInstance( this ); int drawableId = sdk.getSettings().isMuted() ? R.drawable.mute : R.drawable.unmute; if ( Build.VERSION.SDK_INT >= 22 ) { return getResources().getDrawable( drawableId, getTheme() ); } else { return getResources().getDrawable( drawableId ); } }
Example #19
Source File: AppLovinBaseAdapterConfiguration.java From aptoide-client-v8 with GNU General Public License v3.0 | 5 votes |
@Override public void initializeNetwork(@NonNull Context context, @Nullable Map<String, String> configuration, @NonNull OnNetworkInitializationFinishedListener listener) { AppLovinSdk.initializeSdk(context); listener.onNetworkInitializationFinished(this.getClass(), MoPubErrorCode.ADAPTER_INITIALIZATION_SUCCESS); }
Example #20
Source File: NativeAdCarouselUIActivity.java From Android-SDK-Demo with MIT License | 5 votes |
public void loadNativeAds(final int numAdsToLoad) { final AppLovinSdk sdk = AppLovinSdk.getInstance( getApplicationContext() ); sdk.getNativeAdService().loadNativeAds( numAdsToLoad, new AppLovinNativeAdLoadListener() { @Override public void onNativeAdsLoaded(final List list) { // Native ads loaded; do something with this, e.g. render into your custom view. runOnUiThread( new Runnable() { @Override public void run() { log( "Native ad loaded, assets not retrieved yet." ); nativeAd = (AppLovinNativeAd) list.get( 0 ); precacheButton.setEnabled( true ); } } ); } @Override public void onNativeAdsFailedToLoad(final int errorCode) { // Native ads failed to load for some reason, likely a network error. // Compare errorCode to the available constants in AppLovinErrorCodes. log( "Native ad failed to load with error code " + errorCode ); if ( errorCode == AppLovinErrorCodes.NO_FILL ) { // No ad was available for this placement } // else if (errorCode == .... ) { ... } } } ); }
Example #21
Source File: InlineCarouselAdapter.java From Android-SDK-Demo with MIT License | 5 votes |
public InlineCarouselAdapter(Context context, AppLovinSdk sdk, AppLovinCarouselView parentView) { this.sdk = sdk; this.context = context; this.parentView = parentView; this.existingCards = new SparseArray<WeakReference<InlineCarouselCardView>>(); }
Example #22
Source File: MainActivity.java From Android-SDK-Demo with MIT License | 5 votes |
private void checkSdkKey() { final String sdkKey = AppLovinSdk.getInstance( getApplicationContext() ).getSdkKey(); if ( "YOUR_SDK_KEY".equalsIgnoreCase( sdkKey ) ) { new AlertDialog.Builder( this ) .setTitle( "ERROR" ) .setMessage( "Please update your sdk key in the manifest file." ) .setCancelable( false ) .setNeutralButton( "OK", null ) .show(); } }
Example #23
Source File: MainActivity.java From Android-SDK-Demo with MIT License | 5 votes |
private Intent getContactIntent() { Intent intent = new Intent( Intent.ACTION_SENDTO ); intent.setType( "text/plain" ); intent.setData( Uri.parse( "mailto:" + "[email protected]" ) ); intent.putExtra( Intent.EXTRA_SUBJECT, "Android SDK support" ); intent.putExtra( Intent.EXTRA_TEXT, "\n\n\n---\nSDK Version: " + AppLovinSdk.VERSION ); return intent; }
Example #24
Source File: MainActivity.java From Android-SDK-Demo with MIT License | 5 votes |
/** * Toggling the sdk mute setting will affect whether your video ads begin in a muted state or not. */ private void toggleMute() { AppLovinSdk sdk = AppLovinSdk.getInstance( this ); sdk.getSettings().setMuted( !sdk.getSettings().isMuted() ); muteToggleMenuItem.setIcon( getMuteIconForCurrentSdkMuteSetting() ); }
Example #25
Source File: AppLovinCustomEventNative.java From aptoide-client-v8 with GNU General Public License v3.0 | 5 votes |
/** * Retrieves the appropriate instance of AppLovin's SDK from the SDK key given in the server * parameters, or Android Manifest. */ private static AppLovinSdk retrieveSdk(final Map<String, String> serverExtras, final Context context) { final String sdkKey = serverExtras != null ? serverExtras.get("sdk_key") : null; final AppLovinSdk sdk; if (!TextUtils.isEmpty(sdkKey)) { sdk = AppLovinSdk.getInstance(sdkKey, new AppLovinSdkSettings(), context); } else { sdk = AppLovinSdk.getInstance(context); } return sdk; }
Example #26
Source File: NativeAdRecyclerViewActivity.java From Android-SDK-Demo with MIT License | 4 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate( savedInstanceState ); setContentView( R.layout.activity_native_ad_recycler_view ); recyclerView = (RecyclerView) findViewById( R.id.nativeAdsRecyclerView ); // Load an initial batch of native ads. // In a real app, you'd ideally load smaller batches, and load more as the user scrolls. final AppLovinSdk sdk = AppLovinSdk.getInstance( this ); final Activity activityRef = this; final AppLovinNativeAdService nativeAdService = sdk.getNativeAdService(); nativeAdService.loadNativeAds( 10, new AppLovinNativeAdLoadListener() { @Override public void onNativeAdsLoaded(final List /* <AppLovinNativeAd> */ list) { runOnUiThread( new Runnable() { @Override public void run() { renderRecyclerView( list ); retrieveImageResources( nativeAdService, list ); } } ); } @Override public void onNativeAdsFailedToLoad(final int errorCode) { runOnUiThread( new Runnable() { @Override public void run() { Toast.makeText( activityRef, "Failed to load native ads: " + errorCode, Toast.LENGTH_LONG ).show(); } } ); } } ); }
Example #27
Source File: InlineCarouselCardMediaView.java From Android-SDK-Demo with MIT License | 4 votes |
public void setSdk(AppLovinSdk sdk) { this.sdk = sdk; }
Example #28
Source File: InlineCarouselCardMediaView.java From Android-SDK-Demo with MIT License | 4 votes |
public AppLovinSdk getSdk() { return sdk; }
Example #29
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 #30
Source File: InlineCarouselCardView.java From Android-SDK-Demo with MIT License | 4 votes |
public void setSdk(AppLovinSdk sdk) { this.sdk = sdk; }