|
|
|
@ -16,6 +16,7 @@ import android.view.KeyEvent; |
|
|
|
import android.view.View; |
|
|
|
import android.view.WindowManager; |
|
|
|
import android.webkit.ConsoleMessage; |
|
|
|
import android.webkit.CookieManager; |
|
|
|
import android.webkit.JavascriptInterface; |
|
|
|
import android.webkit.WebChromeClient; |
|
|
|
import android.webkit.WebResourceRequest; |
|
|
|
@ -97,8 +98,8 @@ public class WebViewActivity extends BaseActivity { |
|
|
|
static final int TYPE_HINT_PASSWORD = 3;//隐藏密码输入框
|
|
|
|
static final int TYPE_START_SERVER = 4;//重新启动web服务
|
|
|
|
static final int TYPE_SHENG_HTML_MAG = 5;//返回接口请求值给h5
|
|
|
|
static String HtmlUrl = "http://127.0.0.1:8080/index.html";//webServer服务地址
|
|
|
|
//static String HtmlUrl = "http://192.168.0.109:5173/";
|
|
|
|
//static String HtmlUrl = "http://127.0.0.1:8080/index.html";//webServer服务地址
|
|
|
|
static String HtmlUrl = "http://192.168.1.196:5501/index.html"; |
|
|
|
int time = 0; |
|
|
|
String interfaceRequestData=""; |
|
|
|
// 语音听写对象
|
|
|
|
@ -197,7 +198,12 @@ public class WebViewActivity extends BaseActivity { |
|
|
|
webSettings.setBuiltInZoomControls(false); |
|
|
|
webSettings.setDisplayZoomControls(false); |
|
|
|
webSettings.setCacheMode(WebSettings.LOAD_NO_CACHE); |
|
|
|
// 启用 WebGL(关键设置)
|
|
|
|
webSettings.setDomStorageEnabled(true); |
|
|
|
webSettings.setDatabaseEnabled(true); |
|
|
|
webSettings.setAllowContentAccess(true); |
|
|
|
webSettings.setAllowFileAccess(true); |
|
|
|
|
|
|
|
webSettings.setJavaScriptCanOpenWindowsAutomatically(true); |
|
|
|
webSettings.setLoadsImagesAutomatically(true); |
|
|
|
webSettings.setDefaultTextEncodingName("utf-8"); |
|
|
|
@ -206,7 +212,9 @@ public class WebViewActivity extends BaseActivity { |
|
|
|
|
|
|
|
// 适配HTTPS/HTTP混合内容
|
|
|
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { |
|
|
|
webSettings.setMixedContentMode(WebSettings.MIXED_CONTENT_COMPATIBILITY_MODE); |
|
|
|
//webSettings.setMixedContentMode(WebSettings.MIXED_CONTENT_COMPATIBILITY_MODE);
|
|
|
|
webSettings.setMixedContentMode(WebSettings.MIXED_CONTENT_ALWAYS_ALLOW); |
|
|
|
CookieManager.getInstance().setAcceptThirdPartyCookies(binding.web, true); |
|
|
|
} |
|
|
|
|
|
|
|
//加载web
|
|
|
|
|