Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix onReceivedError deprecation #114

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
* Licensed under the MIT License (https://opensource.org/licenses/MIT)
*/

import android.annotation.SuppressLint;
import android.annotation.TargetApi;
import android.view.ViewGroup;
import android.app.DownloadManager;
import android.app.DownloadManager.Request;
Expand All @@ -24,6 +26,7 @@
import android.webkit.URLUtil;
import android.webkit.WebResourceRequest;
import android.webkit.WebResourceResponse;
import android.webkit.WebResourceError;
import android.os.Message;
import android.view.View;
import android.webkit.ConsoleMessage;
Expand Down Expand Up @@ -499,6 +502,13 @@ public void onReceivedError(WebView view, int errorCode, String description, Str
mCustomWebViewClient.onReceivedError(view, errorCode, description, failingUrl);
}
}

@TargetApi(android.os.Build.VERSION_CODES.M)
@Override
public void onReceivedError(WebView view, WebResourceRequest req, WebResourceError rerr) {
// Redirect to deprecated method, so you can use it in all SDK versions
onReceivedError(view, rerr.getErrorCode(), rerr.getDescription().toString(), req.getUrl().toString());
}

@Override
public boolean shouldOverrideUrlLoading(final WebView view, final String url) {
Expand Down