How should the interaction between JS and Java native code be implemented in Android 9.0 webView?

< H1 > problem description < / H1 > < hr >

the situation is as follows: many users have upgraded to the Android 9.0 system. Then our colleagues found that the three commonly used ways of interacting between js and native Java have failed:

1: WebViewaddJavascriptInterface
@JavascriptInterface

2: WebViewClient shouldOverrideUrlLoading () url

3: WebChromeClient onJsAlert()onJsConfirm()onJsPrompt
JSalert()confirm()prompt 

3  jsJava  Android 9.0 

moreover, there are the following problems:

WebView  document.location.href = "https://www.baidu.com"



  Android 9.0  http  https://

shouldOverrideUrlLoading () url  

< hr > < hr > < H1 > the environmental background of the problem and what methods you have tried < / H1 > < hr >

it seems difficult to find relevant information on the Internet.

I only saw 2 articles on StackoverFlow that WebView does not work with loadUrl, but this seems to have nothing to do with this problem.

< hr > < hr > < H1 > related codes < / H1 > < hr >

because the source code is too long, I won"t post it here.


  Android  WebView  
  Android 8.1    Android 4.4.4  
  jsJava  


  Android 9.0  Android

< hr > < hr > < H1 > what result do you expect? What is the error message actually seen? < / H1 > < hr >

Android 9.0, what is the reason why you can"t interact between js and natives in the old way?

Does

need to modify some of the code because of the new 9.0 features?

are there any holes in WebView configuration that I haven"t noticed?

or what new approach should be taken to be compatible with the interaction between js and native Java on the Android 9.0 platform?

Do you have an answer to the question

?


the same question. How to solve this change.

Menu