com.facebook.ads.Ad Java Examples

The following examples show how to use com.facebook.ads.Ad. 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: FacebookListener.java    From mobile-sdk-android with Apache License 2.0 6 votes vote down vote up
@Override
public void onError(Ad ad, AdError adError) {
    Clog.d(Clog.mediationLogTag, className + " | Facebook - onError called for AdView with error message " + adError.getErrorMessage());
    ResultCode code;

    if (adError.getErrorCode() == AdError.NO_FILL.getErrorCode()) {
        code = ResultCode.UNABLE_TO_FILL;
    } else if (adError.getErrorCode() == AdError.LOAD_TOO_FREQUENTLY.getErrorCode()) {
        code = ResultCode.INVALID_REQUEST;
    } else if (adError.getErrorCode() == AdError.INTERNAL_ERROR.getErrorCode()) {
        code = ResultCode.INTERNAL_ERROR;
    } else if (adError.getErrorCode() == AdError.MISSING_PROPERTIES.getErrorCode()) {
        code = ResultCode.INVALID_REQUEST;
    } else {
        code = ResultCode.INTERNAL_ERROR;
    }

    if (mediatedAdViewController != null) {
        mediatedAdViewController.onAdFailed(code);
    }
}
 
Example #2
Source File: BannerView.java    From react-native-fbads with MIT License 6 votes vote down vote up
@Override
public void onAdLoaded(Ad ad) {
  this.removeAllViews();

  Resources r = mContext.getResources();
  DisplayMetrics dm = r.getDisplayMetrics();
  int pxW = mSize.getWidth() > 0 ?
    dp2px(mSize.getWidth(), dm)
    : r.getDisplayMetrics().widthPixels;
  int pxH = dp2px(mSize.getHeight(), dm);

  myAdView.measure(pxW, pxH);
  myAdView.layout(0, 0, pxW, pxH);

  addView(myAdView);

  mEventEmitter.receiveEvent(getId(), "onAdLoad", null);
}
 
Example #3
Source File: FacebookRewardedAd.java    From googleads-mobile-android-mediation with Apache License 2.0 6 votes vote down vote up
@Override
public void onError(Ad ad, AdError adError) {
  String errorMessage = createSdkError(adError);

  if (showAdCalled.get()) {
    Log.w(TAG, "Failed to present rewarded ad: " + errorMessage);
    if (mRewardedAdCallback != null) {
      mRewardedAdCallback.onAdFailedToShow(errorMessage);
    }
  } else {
    Log.w(TAG, "Failed to load rewarded ad: " + errorMessage);
    if (mMediationAdLoadCallback != null) {
      mMediationAdLoadCallback.onFailure(errorMessage);
    }
  }

  rewardedAd.destroy();
}
 
Example #4
Source File: FacebookAdapter.java    From googleads-mobile-android-mediation with Apache License 2.0 5 votes vote down vote up
@Override
public void onError(Ad ad, AdError adError) {
  String errorMessage = createSdkError(adError);
  if (!TextUtils.isEmpty(adError.getErrorMessage())) {
    Log.w(TAG, errorMessage);
  }
  FacebookAdapter.this.mNativeListener.onAdFailedToLoad(
      FacebookAdapter.this, adError.getErrorCode());
}
 
Example #5
Source File: MainActivity.java    From Instagram-Profile-Downloader with MIT License 5 votes vote down vote up
@Override
public void onInterstitialDismissed(Ad ad) {
    isFbAdsLoading = false;
    loadFbFullscreenAd();
    loadFullscreenAd();

}
 
Example #6
Source File: FacebookRtbBannerAd.java    From googleads-mobile-android-mediation with Apache License 2.0 5 votes vote down vote up
@Override
public void onAdClicked(Ad ad) {
  if (mBannerAdCallback != null) {
    // TODO: Upon approval, add this callback back in.
    //mBannerAdCallback.reportAdClicked();
    mBannerAdCallback.onAdOpened();
    mBannerAdCallback.onAdLeftApplication();
  }
}
 
Example #7
Source File: FacebookRtbBannerAd.java    From googleads-mobile-android-mediation with Apache License 2.0 5 votes vote down vote up
@Override
public void onLoggingImpression(Ad ad) {
  if (mBannerAdCallback != null) {
    // TODO: Upon approval, add this callback back in.
    //mBannerAdCallback.reportAdImpression();
  }
}
 
Example #8
Source File: FacebookRtbInterstitialAd.java    From googleads-mobile-android-mediation with Apache License 2.0 5 votes vote down vote up
@Override
public void onLoggingImpression(Ad ad) {
  if (mInterstitalAdCallback != null) {
    // TODO: Upon approval, add this callback back in.
    // mInterstitalAdCallback.reportAdImpression();
  }
}
 
Example #9
Source File: FacebookRtbInterstitialAd.java    From googleads-mobile-android-mediation with Apache License 2.0 5 votes vote down vote up
@Override
public void onAdClicked(Ad ad) {
  if (mInterstitalAdCallback != null) {
    // TODO: Upon approval, add this callback back in.
    // mInterstitalAdCallback.reportAdClicked();
    mInterstitalAdCallback.onAdLeftApplication();
  }
}
 
Example #10
Source File: FacebookRtbInterstitialAd.java    From googleads-mobile-android-mediation with Apache License 2.0 5 votes vote down vote up
@Override
public void onError(Ad ad, AdError adError) {
  String errorMessage = createSdkError(adError);
  Log.w(TAG, errorMessage);

  if (showAdCalled.get()) {
    if (mInterstitalAdCallback != null) {
      mInterstitalAdCallback.onAdOpened();
      mInterstitalAdCallback.onAdClosed();
    }
    return;
  }

  callback.onFailure(errorMessage);
}
 
Example #11
Source File: InterstitialFragment.java    From kognitivo with Apache License 2.0 5 votes vote down vote up
@Override
public void onInterstitialDismissed(Ad ad) {
    Toast.makeText(this.getActivity(), "Interstitial Dismissed", Toast.LENGTH_SHORT).show();

    // Cleanup.
    interstitialAd.destroy();
    interstitialAd = null;
}
 
Example #12
Source File: FragmentSocialTimeline.java    From aptoide-client with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void onAdLoaded(Ad ad) {
    Logger.d("FragmentSocialTimeline","onAdLoaded , ad: "+ad.toString());
    if(getActivity() != null){
        adapter.addNativeAd((NativeAd) ad,getActivity(),apks);
    }

}
 
Example #13
Source File: FacebookRtbNativeAd.java    From googleads-mobile-android-mediation with Apache License 2.0 5 votes vote down vote up
@Override
public void onAdClicked(Ad ad) {
  // TODO: Upon approval, add this callback back in.
  // mNativeAdCallback.reportAdClicked();
  mNativeAdCallback.onAdOpened();
  mNativeAdCallback.onAdLeftApplication();
}
 
Example #14
Source File: FacebookRewardedAd.java    From googleads-mobile-android-mediation with Apache License 2.0 5 votes vote down vote up
@Override
public void onLoggingImpression(Ad ad) {
  if (mRewardedAdCallback != null) {
    if (isRtbAd) {
      // TODO: Upon approval, add this callback back in.
      // mRewardedAdCallback.reportAdImpression();
    } else {
      mRewardedAdCallback.reportAdImpression();
    }
  }
}
 
Example #15
Source File: FacebookRewardedAd.java    From googleads-mobile-android-mediation with Apache License 2.0 5 votes vote down vote up
@Override
public void onAdClicked(Ad ad) {
  if (mRewardedAdCallback != null) {
    if (isRtbAd) {
      // TODO: Upon approval, add this callback back in.
      // mRewardedAdCallback.reportAdClicked();
    } else {
      mRewardedAdCallback.reportAdClicked();
    }
  }
}
 
Example #16
Source File: FacebookAdapter.java    From googleads-mobile-android-mediation with Apache License 2.0 5 votes vote down vote up
@Override
public void onAdClicked(Ad ad) {
  FacebookAdapter.this.mBannerListener.onAdClicked(FacebookAdapter.this);
  FacebookAdapter.this.mBannerListener.onAdOpened(FacebookAdapter.this);
  // The test Facebook ads leave the application when the ad is clicked. Assuming all
  // the ads do the same, sending onAdLeftApplication callback when the ad is clicked.
  FacebookAdapter.this.mBannerListener.onAdLeftApplication(FacebookAdapter.this);
}
 
Example #17
Source File: FacebookAdapter.java    From googleads-mobile-android-mediation with Apache License 2.0 5 votes vote down vote up
@Override
public void onError(Ad ad, AdError adError) {
  String errorMessage = createSdkError(adError);
  if (!TextUtils.isEmpty(adError.getErrorMessage())) {
    Log.w(TAG, errorMessage);
  }
  FacebookAdapter.this.mNativeListener.onAdFailedToLoad(
      FacebookAdapter.this, adError.getErrorCode());
}
 
Example #18
Source File: FacebookAdapter.java    From googleads-mobile-android-mediation with Apache License 2.0 5 votes vote down vote up
@Override
public void onLoggingImpression(Ad ad) {
  if (mIsImpressionRecorded) {
    Log.d(TAG, "Received onLoggingImpression callback for a native whose impression"
        + " is already recorded. Ignoring the duplicate callback.");
    return;
  }
  FacebookAdapter.this.mNativeListener.onAdImpression(FacebookAdapter.this);
  mIsImpressionRecorded = true;
}
 
Example #19
Source File: FacebookAdapter.java    From googleads-mobile-android-mediation with Apache License 2.0 5 votes vote down vote up
@Override
public void onError(Ad ad, AdError adError) {
  String errorMessage = createSdkError(adError);
  Log.w(TAG, errorMessage);
  FacebookAdapter.this.mBannerListener
      .onAdFailedToLoad(FacebookAdapter.this, adError.getErrorCode());
}
 
Example #20
Source File: FacebookAdapter.java    From googleads-mobile-android-mediation with Apache License 2.0 5 votes vote down vote up
@Override
public void onAdClicked(Ad ad) {
  FacebookAdapter.this.mInterstitialListener.onAdClicked(FacebookAdapter.this);
  // The test Facebook ads leave the application when the ad is clicked. Assuming all
  // the ads do the same, sending onAdLeftApplication callback when the ad is clicked.
  FacebookAdapter.this.mInterstitialListener.onAdLeftApplication(FacebookAdapter.this);
}
 
Example #21
Source File: FacebookAdapter.java    From googleads-mobile-android-mediation with Apache License 2.0 5 votes vote down vote up
@Override
public void onAdClicked(Ad ad) {
  FacebookAdapter.this.mNativeListener.onAdClicked(FacebookAdapter.this);
  FacebookAdapter.this.mNativeListener.onAdOpened(FacebookAdapter.this);
  // The test Facebook ads leave the application when the ad is clicked. Assuming all
  // the ads do the same, sending onAdLeftApplication callback when the ad is clicked.
  FacebookAdapter.this.mNativeListener.onAdLeftApplication(FacebookAdapter.this);
}
 
Example #22
Source File: FacebookAdapter.java    From googleads-mobile-android-mediation with Apache License 2.0 5 votes vote down vote up
@Override
public void onLoggingImpression(Ad ad) {
  if (mIsImpressionRecorded) {
    Log.d(TAG, "Received onLoggingImpression callback for a native whose impression"
        + " is already recorded. Ignoring the duplicate callback.");
    return;
  }
  FacebookAdapter.this.mNativeListener.onAdImpression(FacebookAdapter.this);
  mIsImpressionRecorded = true;

}
 
Example #23
Source File: FacebookAdapter.java    From googleads-mobile-android-mediation with Apache License 2.0 5 votes vote down vote up
@Override
public void onError(Ad ad, AdError adError) {
  String errorMessage = createSdkError(adError);
  Log.w(TAG, errorMessage);

  if (showInterstitialCalled.get()) {
    FacebookAdapter.this.mInterstitialListener.onAdOpened(FacebookAdapter.this);
    FacebookAdapter.this.mInterstitialListener.onAdClosed(FacebookAdapter.this);
    return;
  }

  FacebookAdapter.this.mInterstitialListener.onAdFailedToLoad(
      FacebookAdapter.this, adError.getErrorCode());
}
 
Example #24
Source File: FacebookAdapter.java    From googleads-mobile-android-mediation with Apache License 2.0 5 votes vote down vote up
@Override
public void onAdClicked(Ad ad) {
  FacebookAdapter.this.mNativeListener.onAdClicked(FacebookAdapter.this);
  FacebookAdapter.this.mNativeListener.onAdOpened(FacebookAdapter.this);
  // The test Facebook ads leave the application when the ad is clicked. Assuming all
  // the ads do the same, sending onAdLeftApplication callback when the ad is clicked.
  FacebookAdapter.this.mNativeListener.onAdLeftApplication(FacebookAdapter.this);

}
 
Example #25
Source File: BannerView.java    From react-native-fbads with MIT License 5 votes vote down vote up
@Override
public void onError(Ad ad, AdError adError) {
  WritableMap event = Arguments.createMap();

  event.putInt("errorCode", adError.getErrorCode());
  event.putString("errorMessage", adError.getErrorMessage());
  mEventEmitter.receiveEvent(getId(), "onAdError", event);

  myAdView = null;
}
 
Example #26
Source File: FacebookListener.java    From mobile-sdk-android with Apache License 2.0 4 votes vote down vote up
@Override
public void onInterstitialDismissed(Ad ad) {
    if (mediatedAdViewController != null) {
        mediatedAdViewController.onAdCollapsed();
    }
}
 
Example #27
Source File: FacebookRtbInterstitialAd.java    From googleads-mobile-android-mediation with Apache License 2.0 4 votes vote down vote up
@Override
public void onAdLoaded(Ad ad) {
  mInterstitalAdCallback = callback.onSuccess(this);
}
 
Example #28
Source File: FacebookListener.java    From mobile-sdk-android with Apache License 2.0 4 votes vote down vote up
@Override
public void onInterstitialDisplayed(Ad ad) {
    if (mediatedAdViewController != null) {
        mediatedAdViewController.onAdExpanded();
    }
}
 
Example #29
Source File: FacebookAdapter.java    From googleads-mobile-android-mediation with Apache License 2.0 4 votes vote down vote up
@Override
public void onMediaDownloaded(Ad ad) {
  Log.d(TAG, "onMediaDownloaded");
}
 
Example #30
Source File: FacebookListener.java    From mobile-sdk-android with Apache License 2.0 4 votes vote down vote up
@Override
public void onAdClicked(Ad ad) {
    if (mediatedAdViewController != null) {
        mediatedAdViewController.onAdClicked();
    }
}