Webview's loadData() is not working in android 10.0 (Q)

前端 未结 6 1285
暖寄归人
暖寄归人 2021-01-19 06:16

Here i am trying to load Html code as string in webview\'s loadData() .Nothing is happen over this mehtod but same method is working like charm in below sdk 29.

6条回答
  •  南方客
    南方客 (楼主)
    2021-01-19 07:15

    Try calling

    String encodedHtml = Base64.encodeToString(html_code.getBytes(), Base64.NO_PADDING);
    
    webview.getSettings().setJavaScriptEnabled(true);
    

    before

    webview.loadData(encodedHtml , "text/html", "base64");
    

    like below

        String html_code= "Your Actualtext.";
        String encodedHtml = Base64.encodeToString(html_code.getBytes(), Base64.NO_PADDING);
     webview.getSettings().setJavaScriptEnabled(true);
        webview.loadData(encodedHtml , "text/html", "base64");
    

    for more details refer to this link

提交回复
热议问题