Load local html in WebView?

前端 未结 5 601
悲&欢浪女
悲&欢浪女 2020-11-30 03:27

I want to load a local html into a WebView WITHOUT using \"file:///\" because that does not allow cookies. Is there a way to use something like \"localhost\" ?

Secon

5条回答
  •  广开言路
    2020-11-30 04:12

    Try this code. It works for me.

    WebView mDesc = findViewById(R.id.descWv);
    WebSettings settings = mDesc.getSettings();
    settings.setDefaultTextEncodingName("utf-8");
    mDesc.loadData(mDescText, "text/html; charset=utf-8",null);
    

提交回复
热议问题