WebView:如何在 8.0 WebView 中加载 .php 文件

WebView: How to load .php file in the 8.0 WebView

我正在尝试在 WebView 中加载 .php 文件。在我更新到 API 级别 28 之后它在 API 级别 28 之前工作正常它不工作它显示白屏。没有任何显示我尝试了所有选项。

这是代码

我也在清单文件中添加了安全浏览错误。 我尝试在 google 中搜索没有任何帮助,如果有人完成请帮助解决这种情况。

  String url="https://xxx/xxx/abc.php";
          @Override
        protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    handleSSLHandshake();
    WebView mWebView = (WebView) findViewById(R.id.webView);
   // PackageInfo webViewPackageInfo = null;

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
     //   webViewPackageInfo = WebView.getCurrentWebViewPackage();
        mWebView.getSettings().setSafeBrowsingEnabled(false);
       // Log.d("MY_APP_TAG", "WebView version: " + webViewPackageInfo.versionName);
    }
    WebViewClientImpl webViewClient = new WebViewClientImpl(this);
    mWebView.setWebViewClient(webViewClient);
    mWebView.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);
    mWebView.getSettings().setBuiltInZoomControls(false);
    mWebView.getSettings().setJavaScriptEnabled(true);
    mWebView.loadUrl(url);


    if (18 < Build.VERSION.SDK_INT ){
        //18 = JellyBean MR2, KITKAT=19
        mWebView.getSettings().setCacheMode(WebSettings.LOAD_NO_CACHE);
    }
}

   public class WebViewClientImpl extends WebViewClient {

    private Activity activity = null;

    public WebViewClientImpl(Activity activity) {
        this.activity = activity;
    }

    @Override
    public boolean shouldOverrideUrlLoading(WebView webView, String url) {

        webView.loadUrl(url);
        // Log.i(TAG,url);
        return true;

    }

    @Override
    public void onLoadResource(WebView view, String url) {
        super.onLoadResource(view, url);
    }

    @Override
    public void onReceivedError(WebView view, WebResourceRequest request, WebResourceError error) {
        super.onReceivedError(view, request, error);

    }

    @Override
    public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
        super.onReceivedError(view, errorCode, description, failingUrl);


    }

    @Override
    public void onPageStarted(WebView view, String url, Bitmap favicon) {
        super.onPageStarted(view, url, favicon);

    }

    @Override
    public void onPageFinished(WebView view, String url) {


    }
}

我解决了我的问题。这是证书问题,我刚刚添加了以下代码,现在工作正常

    @TargetApi(Build.VERSION_CODES.N)
    @Override
    public boolean shouldOverrideUrlLoading(WebView view, WebResourceRequest request) {
        view.loadUrl(request.getUrl().toString());
        return true;
    }
   @Override
    public void onReceivedSslError(WebView view, SslErrorHandler handler, SslError error) {
        handler.proceed();
    }