private void initWebView() {
webView = findViewById(R.id.webView);
WebSettings webSettings = webView.getSettings();
webSettings.setJavaScriptEnabled(true);
webView.getSettings().setDomStorageEnabled(true);
webView.getSettings().setAllowFileAccess(true);
webView.setWebViewClient(new WebViewClient(){
@Override
public boolean shouldOverrideUrlLoading(WebView view, WebResourceRequest request) {
return false;
}
@Override
public void onPageFinished(WebView view, String url) {
super.onPageFinished(view, url);
// if (getMainActivity().isLoadSuccess){//无网络处理临时屏蔽
// imageView.setVisibility(View.GONE);//无网络处理临时屏蔽
// refreshBtn.setVisibility(View.GONE);//无网络处理临时屏蔽
// }//无网络处理临时屏蔽
// 没作用,不管页面是否成功加载,都会调用至此处
}
@Override
public void onReceivedError(WebView view, WebResourceRequest request, WebResourceError error)
{
super.onReceivedError(webView,request,error);
// reload();
// imageView.setVisibility(View.VISIBLE);//无网络处理临时屏蔽
// refreshBtn.setVisibility(View.VISIBLE);//无网络处理临时屏蔽
// getMainActivity().isLoadSuccess = false ;//无网络处理临时屏蔽
}
@Override
public void onReceivedSslError(WebView view, SslErrorHandler handler, SslError error)
{
super.onReceivedSslError(view,handler,error);
// reload();
}
});
//屏幕常亮
webView.setKeepScreenOn(true);
// double t1 = Math.random();
long t1 = System.currentTimeMillis();
// double t1 = System.currentTimeMillis();
String url = String.format(URL, t1, IP, PORT);
webView.loadUrl(url);
jsInterface = new JSInterface(this);
platform = new PlatformAndroid(this);
webView.addJavascriptInterface(jsInterface,"android");
// StatisticsManager.initAppLog(MainActivity.this,TouTiaoAppID,"toutiao");
// imageView = findViewById(R.id.abnormalImg) ;//无网络处理临时屏蔽
// refreshBtn = findViewById(R.id.refreshButton) ;//无网络处理临时屏蔽
// refreshBtn.setOnClickListener(new View.OnClickListener() {//无网络处理临时屏蔽
// @Override//无网络处理临时屏蔽
// public void onClick(View v) {//无网络处理临时屏蔽
// getMainActivity().isLoadSuccess = true ;//无网络处理临时屏蔽
// reload();//无网络处理临时屏蔽
// }//无网络处理临时屏蔽
// });//无网络处理临时屏蔽
}
/**
* 设置全屏
*/
private void fullScreen() {
WindowManager.LayoutParams lp = getWindow().getAttributes();
lp.flags |= WindowManager.LayoutParams.FLAG_FULLSCREEN;
getWindow().setAttributes(lp);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY); //底部导航栏自动隐藏
}
package com.kgjh.xcx.wd;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.net.Uri;
import android.net.wifi.WifiInfo;
import android.net.wifi.WifiManager;
import android.os.Build;
import android.webkit.JavascriptInterface;
//import com.gyyx.androidsdk.UAMain;
//import com.reyun.tracking.sdk.Tracking;
//import com.umeng.analytics.MobclickAgent;
import androidx.annotation.RequiresApi;
import com.zhangyou.sdk.ZYSDK;
import com.zhangyou.sdk.api.RoleType;
import java.util.HashMap;
import java.util.Map;