Java Code Examples for com.google.android.gms.ads.AdRequest#ERROR_CODE_NETWORK_ERROR

The following examples show how to use com.google.android.gms.ads.AdRequest#ERROR_CODE_NETWORK_ERROR . 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: InterstitialListener.java    From ANEAdMob with Apache License 2.0 7 votes vote down vote up
@Override
public void onAdFailedToLoad(int errorCode)
{
  String errorReason = "";
  switch(errorCode)
  {
    case AdRequest.ERROR_CODE_INTERNAL_ERROR:
      errorReason = "Internal error";
      break;
    case AdRequest.ERROR_CODE_INVALID_REQUEST:
      errorReason = "Invalid request";
      break;
    case AdRequest.ERROR_CODE_NETWORK_ERROR:
      errorReason = "Network Error";
      break;
    case AdRequest.ERROR_CODE_NO_FILL:
      errorReason = "No fill";
      break;
  }
 
  _ctx.dispatchStatusEventAsync("AD_SHOW_FAIL", errorReason);
}
 
Example 2
Source File: GooglePlayAdListener.java    From mobile-sdk-android with Apache License 2.0 7 votes vote down vote up
@Override
public void onAdFailedToLoad(int errorCode) {
    super.onAdFailedToLoad(errorCode);
    printToClog("onAdFailedToLoad with error code " + errorCode);

    ResultCode code = ResultCode.INTERNAL_ERROR;

    switch (errorCode) {
        case AdRequest.ERROR_CODE_INTERNAL_ERROR:
            code = ResultCode.INTERNAL_ERROR;
            break;
        case AdRequest.ERROR_CODE_INVALID_REQUEST:
            code = ResultCode.INVALID_REQUEST;
            break;
        case AdRequest.ERROR_CODE_NETWORK_ERROR:
            code = ResultCode.NETWORK_ERROR;
            break;
        case AdRequest.ERROR_CODE_NO_FILL:
            code = ResultCode.UNABLE_TO_FILL;
            break;
        default:
            break;
    }

    if (mediatedAdViewController != null) {
        mediatedAdViewController.onAdFailed(code);
    }
}
 
Example 3
Source File: AdMobNativeListener.java    From mobile-sdk-android with Apache License 2.0 7 votes vote down vote up
@Override
public void onAdFailedToLoad(int errorCode) {
    Clog.e(Clog.mediationLogTag, "AdMob - onAdFailedToLoad");
    if (mBC != null) {
        ResultCode code = ResultCode.INTERNAL_ERROR;
        switch (errorCode) {
            case AdRequest.ERROR_CODE_INTERNAL_ERROR:
                code = ResultCode.INTERNAL_ERROR;
                break;
            case AdRequest.ERROR_CODE_INVALID_REQUEST:
                code = ResultCode.INVALID_REQUEST;
                break;
            case AdRequest.ERROR_CODE_NETWORK_ERROR:
                code = ResultCode.NETWORK_ERROR;
                break;
            case AdRequest.ERROR_CODE_NO_FILL:
                code = ResultCode.UNABLE_TO_FILL;
                break;
            default:
                break;
        }
        mBC.onAdFailed(code);
    }
}
 
Example 4
Source File: VerizonMediaBannerRenderer.java    From googleads-mobile-android-mediation with Apache License 2.0 6 votes vote down vote up
@Override
public void onError(final InlineAdFactory inlineAdFactory, final ErrorInfo errorInfo) {
  Log.i(TAG, "Verizon Ads SDK Inline Ad request failed (" + errorInfo.getErrorCode() + "): " +
      errorInfo.getDescription());

  final int errorCode;
  switch (errorInfo.getErrorCode()) {
    case VASAds.ERROR_AD_REQUEST_FAILED:
      errorCode = AdRequest.ERROR_CODE_INTERNAL_ERROR;
      break;
    case VASAds.ERROR_AD_REQUEST_TIMED_OUT:
      errorCode = AdRequest.ERROR_CODE_NETWORK_ERROR;
      break;
    default:
      errorCode = AdRequest.ERROR_CODE_NO_FILL;
  }
  ThreadUtils.postOnUiThread(new Runnable() {
    @Override
    public void run() {
      MediationBannerAdapter adapter = bannerAdapterWeakRef.get();
      if (bannerListener != null && adapter != null) {
        bannerListener.onAdFailedToLoad(adapter, errorCode);
      }
    }
  });
}
 
Example 5
Source File: AdMobListener.java    From ANEAdMob with Apache License 2.0 6 votes vote down vote up
@Override
public void onAdFailedToLoad(int errorCode)
{
  String errorReason = "";
  switch(errorCode)
  {
    case AdRequest.ERROR_CODE_INTERNAL_ERROR:
      errorReason = "Internal error";
      break;
    case AdRequest.ERROR_CODE_INVALID_REQUEST:
      errorReason = "Invalid request";
      break;
    case AdRequest.ERROR_CODE_NETWORK_ERROR:
      errorReason = "Network Error";
      break;
    case AdRequest.ERROR_CODE_NO_FILL:
      errorReason = "No fill";
      break;
  }
 
  if(_who == "BANNER")
 	 _ctx.dispatchStatusEventAsync(_who+"_SHOW_FAIL", errorReason);
  else
 	 _ctx.dispatchStatusEventAsync(_who+"_CACHE_FAIL", errorReason);
}
 
Example 6
Source File: RNAdMobRewardedVideoAdModule.java    From react-native-admob with BSD 2-Clause "Simplified" License 6 votes vote down vote up
@Override
public void onRewardedVideoAdFailedToLoad(int errorCode) {
    String errorString = "ERROR_UNKNOWN";
    String errorMessage = "Unknown error";
    switch (errorCode) {
        case AdRequest.ERROR_CODE_INTERNAL_ERROR:
          errorString = "ERROR_CODE_INTERNAL_ERROR";
          errorMessage = "Internal error, an invalid response was received from the ad server.";
          break;
        case AdRequest.ERROR_CODE_INVALID_REQUEST:
          errorString = "ERROR_CODE_INVALID_REQUEST";
          errorMessage = "Invalid ad request, possibly an incorrect ad unit ID was given.";
          break;
        case AdRequest.ERROR_CODE_NETWORK_ERROR:
          errorString = "ERROR_CODE_NETWORK_ERROR";
          errorMessage = "The ad request was unsuccessful due to network connectivity.";
          break;
        case AdRequest.ERROR_CODE_NO_FILL:
          errorString = "ERROR_CODE_NO_FILL";
          errorMessage = "The ad request was successful, but no ad was returned due to lack of ad inventory.";
          break;
    }
    WritableMap event = Arguments.createMap();
    WritableMap error = Arguments.createMap();
    event.putString("message", errorMessage);
    sendEvent(EVENT_AD_FAILED_TO_LOAD, event);
    if (mRequestAdPromise != null) {
      mRequestAdPromise.reject(errorString, errorMessage);
      mRequestAdPromise = null;
    }
}
 
Example 7
Source File: AdUtils.java    From android-gradle-java-app-template with Apache License 2.0 6 votes vote down vote up
@NonNull
public static String getErrorReason(@IntRange(from = AdRequest.ERROR_CODE_INTERNAL_ERROR,
        to = AdRequest.ERROR_CODE_NO_FILL) int errorCode) {
    switch (errorCode) {
        default:
        case AdRequest.ERROR_CODE_INTERNAL_ERROR:
            return "Internal Error";

        case AdRequest.ERROR_CODE_INVALID_REQUEST:
            return "Invalid Request";

        case AdRequest.ERROR_CODE_NETWORK_ERROR:
            return "Network Error";

        case AdRequest.ERROR_CODE_NO_FILL:
            return "No Fill";
    }
}
 
Example 8
Source File: InMobiAdapter.java    From googleads-mobile-android-mediation with Apache License 2.0 6 votes vote down vote up
/**
 * Converts a {@link com.inmobi.ads.InMobiAdRequestStatus.StatusCode} to Google Mobile Ads SDK
 * readable error code.
 *
 * @param statusCode the {@link com.inmobi.ads.InMobiAdRequestStatus.StatusCode} to be converted.
 * @return an {@link AdRequest} error code.
 */
private static int getAdRequestErrorCode(InMobiAdRequestStatus.StatusCode statusCode) {
  switch (statusCode) {
    case INTERNAL_ERROR:
      return AdRequest.ERROR_CODE_INTERNAL_ERROR;
    case AD_ACTIVE:
    case REQUEST_INVALID:
    case REQUEST_PENDING:
    case EARLY_REFRESH_REQUEST:
    case MISSING_REQUIRED_DEPENDENCIES:
      return AdRequest.ERROR_CODE_INVALID_REQUEST;
    case REQUEST_TIMED_OUT:
    case NETWORK_UNREACHABLE:
      return AdRequest.ERROR_CODE_NETWORK_ERROR;
    case NO_FILL:
    case SERVER_ERROR:
    case AD_NO_LONGER_AVAILABLE:
    case NO_ERROR:
    default:
      return AdRequest.ERROR_CODE_NO_FILL;
  }
}
 
Example 9
Source File: AndroidAdMobRewardedVideo.java    From QtAndroidTools with MIT License 6 votes vote down vote up
@Override
public void onRewardedVideoAdFailedToLoad(int errorCode)
{
    int errorId = 0;

    switch(errorCode)
    {
        case AdRequest.ERROR_CODE_INTERNAL_ERROR:
            errorId = ERROR_INTERNAL;
            break;
        case AdRequest.ERROR_CODE_NETWORK_ERROR:
            errorId = ERROR_NETWORK;
            break;
        case AdRequest.ERROR_CODE_INVALID_REQUEST:
            errorId = ERROR_INVALID_REQUEST;
            break;
        case AdRequest.ERROR_CODE_NO_FILL:
            errorId = ERROR_NO_FILL;
            break;
    }

    rewardedVideoError(errorId);
}
 
Example 10
Source File: VerizonMediaNativeRenderer.java    From googleads-mobile-android-mediation with Apache License 2.0 6 votes vote down vote up
@Override
public void onError(final NativeAdFactory nativeAdFactory, final ErrorInfo errorInfo) {
  Log.i(TAG, "Verizon Ads SDK Native Ad request failed (" + errorInfo.getErrorCode() + "): " +
      errorInfo.getDescription());
  final int errorCode;
  switch (errorInfo.getErrorCode()) {
    case VASAds.ERROR_AD_REQUEST_FAILED:
      errorCode = AdRequest.ERROR_CODE_INTERNAL_ERROR;
      break;
    case VASAds.ERROR_AD_REQUEST_TIMED_OUT:
      errorCode = AdRequest.ERROR_CODE_NETWORK_ERROR;
      break;
    default:
      errorCode = AdRequest.ERROR_CODE_NO_FILL;
  }
  ThreadUtils.postOnUiThread(new Runnable() {
    @Override
    public void run() {
      MediationNativeAdapter adapter = nativeAdapterWeakRef.get();
      if (nativeListener != null && adapter != null) {
        nativeListener.onAdFailedToLoad(adapter, errorCode);
      }
    }
  });
}
 
Example 11
Source File: AdapterHelper.java    From googleads-mobile-android-mediation with Apache License 2.0 6 votes vote down vote up
/**
 * Convert i-mobile fail reason to AdMob error code.
 *
 * @param reason i-mobile fail reason
 * @return AdMob error code
 */
public static int convertToAdMobErrorCode(FailNotificationReason reason) {
  // Convert i-mobile fail reason to AdMob error code.
  switch (reason) {
    case RESPONSE:
    case UNKNOWN:
      return AdRequest.ERROR_CODE_INTERNAL_ERROR;
    case PARAM:
    case AUTHORITY:
    case PERMISSION:
      return AdRequest.ERROR_CODE_INVALID_REQUEST;
    case NETWORK_NOT_READY:
    case NETWORK:
      return AdRequest.ERROR_CODE_NETWORK_ERROR;
    case AD_NOT_READY:
    case NOT_DELIVERY_AD:
    case SHOW_TIMEOUT:
      return AdRequest.ERROR_CODE_NO_FILL;
    default:
      return AdRequest.ERROR_CODE_INTERNAL_ERROR;
  }
}
 
Example 12
Source File: ErrorUtil.java    From googleads-mobile-android-mediation with Apache License 2.0 6 votes vote down vote up
static int convertErrorCodeFromNendVideoToAdMob(int errorCode) {
  switch (errorCode) {
    case HttpURLConnection.HTTP_NO_CONTENT:
      return AdRequest.ERROR_CODE_NO_FILL;

    case HttpURLConnection.HTTP_BAD_REQUEST:
      return AdRequest.ERROR_CODE_INVALID_REQUEST;

    case NEND_SDK_NETWORK_ERROR_CODE:
      return AdRequest.ERROR_CODE_NETWORK_ERROR;

    case HttpURLConnection.HTTP_INTERNAL_ERROR:
    default:
      return AdRequest.ERROR_CODE_INTERNAL_ERROR;
  }
}
 
Example 13
Source File: AdImpl.java    From rebootmenu with GNU General Public License v3.0 6 votes vote down vote up
private static void adErrorCodeReport(int errorCode) {
    switch (errorCode) {
        case AdRequest.ERROR_CODE_INTERNAL_ERROR:
            EventStatistics.record(EventStatistics.AD_STATUS_CODE, adStatusCode[0]);
            break;
        case AdRequest.ERROR_CODE_NETWORK_ERROR:
            EventStatistics.record(EventStatistics.AD_STATUS_CODE, adStatusCode[1]);
            break;
        case AdRequest.ERROR_CODE_INVALID_REQUEST:
            EventStatistics.record(EventStatistics.AD_STATUS_CODE, adStatusCode[2]);
            break;
        case AdRequest.ERROR_CODE_NO_FILL:
            EventStatistics.record(EventStatistics.AD_STATUS_CODE, adStatusCode[3]);
            break;
    }
}
 
Example 14
Source File: AndroidAdMobInterstitial.java    From QtAndroidTools with MIT License 6 votes vote down vote up
public void onAdFailedToLoad(int errorCode)
{
    int errorId = 0;

    switch(errorCode)
    {
        case AdRequest.ERROR_CODE_INTERNAL_ERROR:
            errorId = ERROR_INTERNAL;
            break;
        case AdRequest.ERROR_CODE_NETWORK_ERROR:
            errorId = ERROR_NETWORK;
            break;
        case AdRequest.ERROR_CODE_INVALID_REQUEST:
            errorId = ERROR_INVALID_REQUEST;
            break;
        case AdRequest.ERROR_CODE_NO_FILL:
            errorId = ERROR_NO_FILL;
            break;
    }

    interstitialError(errorId);
}
 
Example 15
Source File: AndroidAdMobBanner.java    From QtAndroidTools with MIT License 6 votes vote down vote up
public void onAdFailedToLoad(int errorCode)
{
    int errorId = 0;

    switch(errorCode)
    {
        case AdRequest.ERROR_CODE_INTERNAL_ERROR:
            errorId = ERROR_INTERNAL;
            break;
        case AdRequest.ERROR_CODE_NETWORK_ERROR:
            errorId = ERROR_NETWORK;
            break;
        case AdRequest.ERROR_CODE_INVALID_REQUEST:
            errorId = ERROR_INVALID_REQUEST;
            break;
        case AdRequest.ERROR_CODE_NO_FILL:
            errorId = ERROR_NO_FILL;
            break;
    }

    bannerError(errorId);
}
 
Example 16
Source File: VerizonMediaInterstitialRenderer.java    From googleads-mobile-android-mediation with Apache License 2.0 5 votes vote down vote up
@Override
public void onError(final InterstitialAdFactory interstitialAdFactory,
    final ErrorInfo errorInfo) {
  Log.w(TAG, "Verizon Ads SDK interstitial request failed (" + errorInfo.getErrorCode()
      + "): " + errorInfo.getDescription());
  final int errorCode;
  switch (errorInfo.getErrorCode()) {
    case VASAds.ERROR_AD_REQUEST_FAILED:
      errorCode = AdRequest.ERROR_CODE_INTERNAL_ERROR;
      break;
    case VASAds.ERROR_AD_REQUEST_TIMED_OUT:
      errorCode = AdRequest.ERROR_CODE_NETWORK_ERROR;
      break;
    default:
      errorCode = AdRequest.ERROR_CODE_NO_FILL;
  }
  ThreadUtils.postOnUiThread(new Runnable() {
    @Override
    public void run() {
      MediationInterstitialAdapter adapter = interstitialAdapterWeakRef.get();

      if (adapter != null && interstitialListener != null) {
        interstitialListener.onAdFailedToLoad(adapter, errorCode);
      }
    }
  });
}
 
Example 17
Source File: AppLovinUtils.java    From googleads-mobile-android-mediation with Apache License 2.0 5 votes vote down vote up
/** Convert the given AppLovin SDK error code into the appropriate AdMob error code. */
public static int toAdMobErrorCode(int applovinErrorCode) {
  //
  // TODO: Be more exhaustive
  //
  if (applovinErrorCode == AppLovinErrorCodes.NO_FILL) {
    return AdRequest.ERROR_CODE_NO_FILL;
  } else if (applovinErrorCode == AppLovinErrorCodes.FETCH_AD_TIMEOUT) {
    return AdRequest.ERROR_CODE_NETWORK_ERROR;
  } else {
    return AdRequest.ERROR_CODE_INTERNAL_ERROR;
  }
}
 
Example 18
Source File: AppLovinCustomEventBanner.java    From SDK-Network-Adapters with MIT License 5 votes vote down vote up
private static int toAdMobErrorCode(final int applovinErrorCode)
{
    if ( applovinErrorCode == AppLovinErrorCodes.NO_FILL )
    {
        return AdRequest.ERROR_CODE_NO_FILL;
    }
    else if ( applovinErrorCode == AppLovinErrorCodes.NO_NETWORK || applovinErrorCode == AppLovinErrorCodes.FETCH_AD_TIMEOUT )
    {
        return AdRequest.ERROR_CODE_NETWORK_ERROR;
    }
    else
    {
        return AdRequest.ERROR_CODE_INTERNAL_ERROR;
    }
}
 
Example 19
Source File: ApplovinAdapter.java    From SDK-Network-Adapters with MIT License 5 votes vote down vote up
private static int toAdMobErrorCode(final int applovinErrorCode)
{
    if ( applovinErrorCode == AppLovinErrorCodes.NO_FILL )
    {
        return AdRequest.ERROR_CODE_NO_FILL;
    }
    else if ( applovinErrorCode == AppLovinErrorCodes.NO_NETWORK || applovinErrorCode == AppLovinErrorCodes.FETCH_AD_TIMEOUT )
    {
        return AdRequest.ERROR_CODE_NETWORK_ERROR;
    }
    else
    {
        return AdRequest.ERROR_CODE_INTERNAL_ERROR;
    }
}
 
Example 20
Source File: AppLovinCustomEventInterstitial.java    From SDK-Network-Adapters with MIT License 5 votes vote down vote up
private static int toAdMobErrorCode(final int applovinErrorCode)
{
    if ( applovinErrorCode == AppLovinErrorCodes.NO_FILL )
    {
        return AdRequest.ERROR_CODE_NO_FILL;
    }
    else if ( applovinErrorCode == AppLovinErrorCodes.NO_NETWORK || applovinErrorCode == AppLovinErrorCodes.FETCH_AD_TIMEOUT )
    {
        return AdRequest.ERROR_CODE_NETWORK_ERROR;
    }
    else
    {
        return AdRequest.ERROR_CODE_INTERNAL_ERROR;
    }
}