WebView in Android supports file upload instance code in the page

Android WebView does not support file upload in web pages by default;

If there is < input type = "file" / > in the web page, the browse file button will also appear when accessing in Android WebView

But no response after clicking the button

So how can Android WebView respond to this Browse button? I checked a lot of information on the Internet, many of which are the same, but I missed one place, which made it impossible to read the full address of the file ("C: \ upfile \ 233232. JPG"). Sort out the final code into the following:

We need to set up webchromeclient for WebView and override the file selection method in the implementation class of webchromeclient:

The above is the whole content of this article. I hope it will be helpful to your study, and I hope you can support programming tips.

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>