WebviewActivity.java
1.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package xdycom.abao.myapplication;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.webkit.WebChromeClient;
import android.webkit.WebResourceRequest;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.Button;
public class WebviewActivity extends AppCompatActivity {
private WebView mWebView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_webview);
mWebView= (WebView) this.findViewById(R.id.webview);
WebSettings webSettings=mWebView.getSettings();
webSettings.setJavaScriptEnabled(true);
// mWebView.addJavascriptInterface(new XdyJavaScript(), APIContants.NATIVE_JS_LINK);
mWebView.setWebChromeClient(new WebChromeClient(){
@Override
public void onConsoleMessage(String message, int lineNumber, String sourceID) {
super.onConsoleMessage(message, lineNumber, sourceID);
Log.e("浏览器message",message+"linumber"+lineNumber+"sourceId"+sourceID);
}
});
mWebView.setWebViewClient(new WebViewClient(){
@Override
public boolean shouldOverrideUrlLoading(WebView view, WebResourceRequest request) {
return super.shouldOverrideUrlLoading(view, request);
}
});
mWebView.loadUrl("http://10.118.1.155:8080/?classId=2006998200&userId=980&userName=base&userRole=normal&portalIP=112.126.80.182&portalPort=90&m=136d61bd4648286c40445b29acbd7edc");
}
}