Most of the places I see the file upload function in WebView implemented using the openFileChooser() method. Is it legal / safe to use this method? If I use this in code, will my code break anywhere? Any security issues if I use this method?
WebView
openFileChooser()
Why does android hide this API in older versions? Only in / above 5.0 did they introduce the onShowFileChooser () method, which means that they do not officially support downloading files in web views below 5.0?
Using old openFileChooser(...) callbacks has no security implications. This is just great. The only drawback is that it will not be called at some levels of the platform and therefore does not work.
openFileChooser(...)
void openFileChooser(ValueCallback<Uri> uploadMsg)
openFileChooser(ValueCallback<Uri> uploadMsg, String acceptType)
openFileChooser(ValueCallback<Uri> uploadMsg, String acceptType, String capture)
onShowFileChooser(WebView webView, ValueCallback<Uri[]> filePathCallback, WebChromeClient.FileChooserParams fileChooserParams)
You can use a library that abstracts it and takes care of all these callbacks at different levels of the platform so that it just works. Example:
https://github.com/delight-im/Android-AdvancedWebView
You can also check how this is done in the source:
https://github.com/delight-im/Android-AdvancedWebView/blob/0f06e73ecee13ebc4552ac00bc0848e18662a25d/Source/src/im/delight/android/webview/AdvancedWebView.java#L597
https://github.com/delight-im/Android-AdvancedWebView/blob/0f06e73ecee13ebc4552ac00bc0848e18662a25d/Source/src/im/delight/android/webview/AdvancedWebView.java#L1044
The fact that it is undocumented means that you cannot rely on it. When it was introduced in Android 2.2, no one could know that it would stop working in Android 4.4, but you have to accept it.
Since this is not described in WebChromeClient , no , it is not a secure API, but yes it is legal.
But you can still use it. Be sure to understand any mistake. But the process cannot be guaranteed to work.
Source: https://habr.com/ru/post/986661/More articles:Google Cloud Print APIs - javascriptshort + short! = short? - c #Why is my adding 2 short circuits causing a compilation error due to ints? - castingCould not find a valid certification path for the requested target - java - javaAll possible characters to represent a number as a string, Integer.java - javaSSL: how a client decrypts a message from a server - securityCan I regenerate random values ββin AutoFixture using a seed? - c #Gatling check for java.io.IOException: remotely closed - scalaHow to simulate geom_boxplot () with outliers using geom_boxplot (stat = "identity") - rIs Java Atomics simply atomic to a virtual machine - javaAll Articles