The image file is not accessible from the Android Web view.

Asked 2 years ago, Updated 2 years ago, 73 views

I'm making a simple website and an Android application.

After accessing the website through Android webview, I need to register the photo. When I access the website with a computer browser, the file window appears, but the file window does not appear in Android Web View.

How can I access files from a web view? The website is writing the following code to access the file

<input id="..." type="file"></input>

android webview

2022-09-22 21:56

1 Answers

In order to display the file dialog in the Android web view, a little bit of hacky code is needed because it requires version-specific processing. The basic action is to overwrite the WebChromeClient's openFileChooser and onShowFileChooser (Android > 5.0) functions to create a code that floats the file dialog. The detailed code seems to be explained well in the following link, so I will replace it with the link.

And in that blog, it says it doesn't work on Android 4.2, but if I remember correctly, it doesn't work on 4.4 KitKat. (Refer to the link below)

Also, Android 4.4 is not without a solution. Since this method injects custom Js objects into web pages, it can be processed if you manage the web page source code directly, but otherwise, it is good for your mental health to handle it with a known-issue :)


2022-09-22 21:56

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.