android – 是`shouldOverrideUrlLoading`真的被弃用了吗?我可以用什么呢?

“shouldOverrideUrlLoading”真的被弃用了吗?如果是这样,我可以使用什么呢?

看起来似乎已经弃用了针对Android N的shouldOverrideUrlLoading并且我需要使应用程序从API 19开始工作直到最新的Android N(测试版),我使用Android N中的一些新功能(如Data Saver),所以定位Marshmallow无法解决这个问题,因为我需要使用这些新功能,这是我使用的代码的一部分:

public boolean shouldOverrideUrlLoading(WebView webview, String url) {
    if (url.startsWith("http:") || url.startsWith("https:")) {
        ...
    } else if (url.startsWith("sms:")) {
        ...
    }
    ...
}

这是Android Studio给我的消息:

Overrides deprecated method in ‘android.webkit.WebViewClient’
This inspection reports where deprecated code is used in the specified inspection scope.

Google says nothing about that deprecation.

我想知道使用@SuppressWarnings(“弃用”)是否会让我在API 19之后使用所有设备,直到最新的Android N Beta(以及它发布时的最终版本),我无法自己测试,我从未使用过我需要确定它是否有效,所以,任何人都能说出来?

解决方法:

The version I’m using I think is the good one, since is the exact same as the Android Developer Docs, except for the name of the string, they used “view” and I used “webview”, for the rest is the same

不它不是.

N Developer Preview的新功能具有以下方法签名:

public boolean shouldOverrideUrlLoading(WebView view, WebResourceRequest request)

所有Android版本(包括N)支持的版本都具有以下方法签名:

public boolean shouldOverrideUrlLoading(WebView view, String url)

So why should I do to make it work on all versions?

覆盖不推荐的那个,即将String作为第二个参数的那个.

相关文章

Android性能优化——之控件的优化 前面讲了图像的优化,接下...
前言 上一篇已经讲了如何实现textView中粗字体效果,里面主要...
最近项目重构,涉及到了数据库和文件下载,发现GreenDao这个...
WebView加载页面的两种方式 一、加载网络页面 加载网络页面,...
给APP全局设置字体主要分为两个方面来介绍 一、给原生界面设...
前言 最近UI大牛出了一版新的效果图,按照IOS的效果做的,页...