Click a hyperlink in the android WebView application and do not call the system browser.
Public class MainActivity extends Activity {
Private WebView mWebView;
@ Override
Public void onCreate (Bundle savedInstanceState ){
Super. onCreate (savedInstanceState );
SetContentView (R. layout. activity_main );
MWebView = (WebView) findViewById (R. id. webview );
WebSettings setting = mWebView. getSettings ();
Setting. setPluginState (PluginState. ON );
Setting. setJavaScriptEnabled (true );
MWebView. setScrollBarStyle (0 );
// Rewrite the shouldOverrideUrlLoading () method of WebViewClient
// If event processing is required, false is returned; otherwise, true is returned. This solves the problem.
MWebView. setWebViewClient (new WebViewClient (){
@ Override
Public boolean shouldOverrideUrlLoading (WebView view, String url ){
Lodurl (view, url );
Return false;
}
});
This. mWebView. loadUrl (http: // 192.168.1.59/assets/widget /);
}
Public void lodurl (final WebView webView, final String url ){
New Thread (new Runnable (){
@ Override
Public void run (){
WebView. loadUrl (url );
}
});
}
}