Home > Mobile >  For help: the webView setWebViewClient with registerHandler conflict?
For help: the webView setWebViewClient with registerHandler conflict?

Time:10-12

The following setWebViewClient code once open, registerHandler code will be invalid, is conflict? Consult a great god how broken?
 
//webView. SetWebViewClient (new WebViewClient () {
//@ Override
//public Boolean shouldOverrideUrlLoading (WebView view, String url) {
//
//if (url. StartsWith (tel: "") | | url. StartsWith (" mailto:")) {
////open the android phone or email
//Intent Intent=new Intent (Intent. ACTION_VIEW, Uri, parse (url));
//startActivity (intent);
//
//}
//
//return true;
//}
//});

 
WebView. RegisterHandler (" login ", new BridgeHandler () {

@ Override
Public void handler (String data, CallBackFunction function) {
Function. OnCallBack (" login ");
}
});

CodePudding user response:

Do you solved

CodePudding user response:

reference 1st floor Mr_IT520 response:
excuse me, can you solve it


No, to find other ways to go round,

CodePudding user response:

In what ways around the past, ask next

CodePudding user response:

Installed setWebViewClient BridgeWebView initialized in the constructor, if you again setWebViewClient overrides registerHandler failure,

CodePudding user response:

In BridgeWebViewClient onPageFinished method can be implemented (not sure will there be other effects), the code is as follows:

The class MyWebViewClient extends BridgeWebViewClient {
Public MyWebViewClient (BridgeWebView webView) {
Super (webView);
}

@ Override
Public void onPageFinished (WebView view, String url) {
Super. OnPageFinished (view, url);
/* *
* front end sends a message to the client submitFromWeb is js the method called android is returned to the js
*/
WebView. RegisterHandler (" AndroidQRcode ", new BridgeHandler () {
@ Override
Public void handler (String data, CallBackFunction function) {
//display the message received
//showToast (data);
ShowToast (js calls "qr code");
//is returned to the news of the HTML
//function. OnCallBack (" back to the Toast alert ");
}
});
}
}

CodePudding user response:

https://github.com/liulingfeng/CommonWebview to see the solution on my side
  • Related